[BioRuby] esoap.rb
Moses Hohman
mmhohman at northwestern.edu
Sun Dec 12 03:52:10 EST 2004
Agreed, sounds good.
I'm a bit of a SOAP and soap4r neophyte, so it took me way too long,
but I was able to make a successful efetch round-trip using a local
copy of the eUtils WSDL modified as David suggested. It also required a
modification of soap4r's soap/mapping/mapping.rb, because some of the
XML tags in the efetch response have names with -s in them, and
mapping.rb was calling Module#const_defined? on those names, which
results in a NameError, since they're not legal Ruby constant names,
even though they are legal XML element names. A patch to mapping.rb is
to change line 152 (the second line below:
def self.class_from_name(name)
if /^[A-Z]/ !~ name
return nil
end
.
.
.
to
def self.class_from_name(name)
if /^[A-Z]/ !~ name or /[^A-Za-z0-9_]/ =~ name
return nil
end
.
.
.
That patch allows you to perform a successful call, although I think
it's not quite the right patch, because the "offending" element
(GBSeq_other-seqids) should be a property on the resulting Ruby
SOAP::Mapping::Object response, but it isn't there (though it *is* in
the SOAP XML response).
With the mapping.rb patch, the following code will perform a successful
call on eUtils' eFetch:
#
# bio/io/eutils.rb - NCBI eUtils access class
#
require 'bio/io/soapwsdl'
require 'soap/element'
require 'xsd/datatypes'
module Bio
class NCBI
class EUtils < Bio::SOAPWSDL
SERVER_URI =
'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/eutils.wsdl'
EFETCH_NAMESPACE = 'http://eutils.ncbi.nlm.nih.gov/soap/eutils/efetch'
EFETCH_REQUEST_QNAME = XSD::QName.new(EFETCH_NAMESPACE,
'eFetchRequest')
def initialize(wsdl = nil, log = nil)
@wsdl = wsdl || SERVER_URI
@log = log
create_driver
end
def efetch(db, identifier)
request_body=SOAP::SOAPElement.new(EFETCH_REQUEST_QNAME)
request_body.add(SOAP::SOAPElement.new('db', db))
request_body.add(SOAP::SOAPElement.new('id', identifier))
request_header = nil
@driver.run_eFetch(request_header, request_body)
end
end # EUtils
end # NCBI
end # Bio
if __FILE__ == $0
serv = Bio::NCBI::EUtils.new("eutils.wsdl", STDOUT)
response_header, response_body = serv.efetch('nucleotide',
'NM_000027')
puts response_body.GBSeq.GBSeq_locus
puts response_body.GBSeq.GBSeq_definition
puts response_body.GBSeq.GBSeq_sequence
end
On Dec 11, 2004, at 3:38 PM, David Wheeler wrote:
> Moses:
>
> Yes, I think we're using non-standard syntax but I need to check with
> our
> developers to see if they agree. If so, they we'll change it and that
> should fix the eutils problem. But, if the author of SOAP4R feels that
> the
> syntax we're using now is common enough to be worth accommodating, I
> don't
> want to discourage that.
>
> David
>
> On Sat, 11 Dec 2004, Moses Hohman wrote:
>
>> So, David, you think it's actually a server-side WSDL problem? Just
>> confirming that I understand your email.
>>
>> That would be good news.
>>
>> Moses
>>
>> On Dec 11, 2004, at 8:37 AM, David Wheeler wrote:
>>
>>> Toshiaki:
>>>
>>> Great! In case it helps, I've been exploring the wsdl we're using in
>>> eutils_a.wsdl and I can eliminate most of the problems by replacing
>>> the
>>> wsdl:import statements with xsd:import statements and including the
>>> xsd
>>> namespace. Hence, if I replace the original import block, commented
>>> out
>>> below, with the wsdl:types block that follows, problem Number Two
>>> goes
>>> away. From what I read on the web, the syntax of the second block is
>>> not
>>> considered to be correct.
>>>
>>> David
>>>
>>> #need to add this to use xsd:schema tag
>>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
>>>
>>> #new import block that seems to work
>>>
>>> <wsdl:types>
>>> <xsd:schema
>>> targetNamespace="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/">
>>> <xsd:import
>>> namespace="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/"
>>> schemaLocation="egquery.xsd"/>
>>> <xsd:import
>>> namespace="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/"
>>> schemaLocation="einfo.xsd"/>
>>> <xsd:import
>>> namespace="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/"
>>> schemaLocation="elink.xsd"/>
>>> <xsd:import
>>> namespace="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/"
>>> schemaLocation="esearch.xsd"/>
>>> <xsd:import
>>> namespace="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/"
>>> schemaLocation="efetch.xsd"/>
>>> <xsd:import
>>> namespace="http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/"
>>> schemaLocation="esummary.xsd"/>
>>>
>>> </xsd:schema>
>>> </wsdl:types>
>>>
>>>
>>> #old import block that is giving parse errors
>>>
>>> <!--
>>> <wsdl:import
>>> namespace="http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/"
>>> location="http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/egquery.xsd"
>>> />
>>> <wsdl:import
>>> namespace="http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/"
>>> location="http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/einfo.xsd"
>>> />
>>> <wsdl:import
>>> namespace="http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/"
>>> location="http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/elink.xsd"
>>> />
>>> <wsdl:import
>>> namespace="http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/"
>>> location="http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/esearch.xsd"
>>> />
>>> <wsdl:import
>>> namespace="http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/"
>>> location="http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/
>>> esummary.xsd"
>>> />
>>> <wsdl:import
>>> namespace="http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/"
>>> location="http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/efetch.xsd"
>>> />
>>>
>>> -->
>>>
>>> On Sat, 11 Dec 2004, Toshiaki Katayama wrote:
>>>
>>>> Hi David,
>>>>
>>>> I have contacted the author of SOAP4R.
>>>> He will implement this function soon so that we can use
>>>> eutils_a.wsdl
>>>> without any modification on server side, hopefully. :)
>>>>
>>>> Regards,
>>>> Toshiaki Katayama
>>>>
>>>> On 2004/12/11, at 1:17, david wheeler wrote:
>>>>
>>>>> Moses, Toshiaki:
>>>>>
>>>>> Looks like the relative urls you saw in the wsdl were one
>>>>> problem...
>>>>> Our
>>>>> SOAP specialist has created a new wsdl for testing with absolute
>>>>> urls
>>>>> at:
>>>>>
>>>>> http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/eutils_a.wsdl
>>>>>
>>>>> Using this one, gets me to the new error that you also see when you
>>>>> curl the
>>>>> XSD files:
>>>>>
>>>>> /usr/lib/ruby/1.8/wsdl/xmlSchema/element.rb:76:in `parse_attr':
>>>>> NotImplementedError (NotImplementedError)
>>>>> from /usr/lib/ruby/1.8/wsdl/xmlSchema/parser.rb:141:in
>>>>> `decode_tag'
>>>>> from /usr/lib/ruby/1.8/wsdl/xmlSchema/parser.rb:121:in
>>>>> `each'
>>>>> from /usr/lib/ruby/1.8/wsdl/xmlSchema/parser.rb:121:in
>>>>> `decode_tag'
>>>>> from /usr/lib/ruby/1.8/wsdl/xmlSchema/parser.rb:79:in
>>>>> `start_element'
>>>>> from /usr/lib/ruby/1.8/xsd/xmlparser/parser.rb:67:in
>>>>> `start_element'
>>>>> from /usr/lib/ruby/1.8/xsd/xmlparser/rexmlparser.rb:34:in
>>>>> `tag_start'
>>>>> from /usr/lib/ruby/1.8/rexml/parsers/streamparser.rb:17:in
>>>>> `parse'
>>>>> from /usr/lib/ruby/1.8/rexml/document.rb:166:in
>>>>> `parse_stream'
>>>>> ... 18 levels...
>>>>> from /usr/lib/ruby/1.8/soap/wsdlDriver.rb:70:in `import'
>>>>> from /usr/lib/ruby/1.8/soap/wsdlDriver.rb:34:in
>>>>> `initialize'
>>>>> from ./ncbi_soap.rb:8:in `new'
>>>>> from ./ncbi_soap.rb:8
>>>>>
>>>>> I'll pursue this on our end but if you have any ideas, let me know.
>>>>>
>>>>>
>>>>> David
>>>>>
>>>>>
>>>>> -----Original Message-----
>>>>> From: bioruby-bounces at portal.open-bio.org
>>>>> [mailto:bioruby-bounces at portal.open-bio.org] On Behalf Of Moses
>>>>> Hohman
>>>>> Sent: Friday, December 10, 2004 2:21 AM
>>>>> To: bioruby at portal.open-bio.org
>>>>> Cc: BioRuby Project Discussion List
>>>>> Subject: Re: [BioRuby] esoap.rb
>>>>>
>>>>> I get a different error:
>>>>>
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:1283:in
>>>>> `initialize':
>>>>> Can't assign requested address - connect(2) (Errno::EADDRNOTAVAIL)
>>>>> from
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:1283:in
>>>>> `new'
>>>>> from
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:1283:in
>>>>> `create_socket'
>>>>> from
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:1252:in
>>>>> `connect'
>>>>> from
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:1251:in
>>>>> `timeout'
>>>>> from /usr/local/lib/ruby/1.8/timeout.rb:55:in `timeout'
>>>>> from
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:1251:in
>>>>> `connect'
>>>>> from
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:1111:in
>>>>> `query'
>>>>> from
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:833:in
>>>>> `query'
>>>>> ... 26 levels...
>>>>> from /usr/local/lib/ruby/1.8/soap/wsdlDriver.rb:71:in
>>>>> `import'
>>>>> from /usr/local/lib/ruby/1.8/soap/wsdlDriver.rb:35:in
>>>>> `initialize'
>>>>> from test_eruby.rb:12:in `new'
>>>>>
>>>>> The full backtrace is after the rest of my message.
>>>>>
>>>>> This seems to have something to do with the fact that eutils.wsdl
>>>>> has
>>>>> <wsdl:import> tags with locations that don't specify a base URL or
>>>>> something
>>>>> (I'm not very familiar with WSDL). soap4r apparently can't handle
>>>>> this, or
>>>>> maybe there's an option one has to set that I don't know. If you
>>>>> curl
>>>>> the
>>>>> various imported XSD files, the error goes away and a new error
>>>>> occurs:
>>>>>
>>>>> /usr/local/lib/ruby/1.8/wsdl/xmlSchema/element.rb:76:in
>>>>> `parse_attr':
>>>>> NotImplementedError (NotImplementedError)
>>>>> from
>>>>> /usr/local/lib/ruby/1.8/wsdl/xmlSchema/parser.rb:142:in
>>>>> `decode_tag'
>>>>> from
>>>>> /usr/local/lib/ruby/1.8/wsdl/xmlSchema/parser.rb:122:in
>>>>> `each'
>>>>> from
>>>>> /usr/local/lib/ruby/1.8/wsdl/xmlSchema/parser.rb:122:in
>>>>> `decode_tag'
>>>>> from
>>>>> /usr/local/lib/ruby/1.8/wsdl/xmlSchema/parser.rb:79:in
>>>>> `start_element'
>>>>> from /usr/local/lib/ruby/1.8/xsd/xmlparser/parser.rb:67:in
>>>>> `start_element'
>>>>> from
>>>>> /usr/local/lib/ruby/1.8/xsd/xmlparser/xmlscanner.rb:139:in
>>>>> `on_stag_end'
>>>>> from
>>>>> /usr/local/lib/ruby/1.8/xsd/xmlparser/xmlscanner.rb:134:in
>>>>> `on_stag_end_empty'
>>>>> from
>>>>> /usr/local/lib/ruby/site_ruby/1.8/xmlscan/scanner.rb:470:in
>>>>> `on_stag_end_empty'
>>>>> ... 28 levels...
>>>>> from /usr/local/lib/ruby/1.8/soap/wsdlDriver.rb:71:in
>>>>> `import'
>>>>> from /usr/local/lib/ruby/1.8/soap/wsdlDriver.rb:35:in
>>>>> `initialize'
>>>>> from test_eruby.rb:12:in `new'
>>>>> from test_eruby.rb:12
>>>>>
>>>>>
>>>>> I'm running 1.8.2 preview 3 on OS X 10.3.6. I've also installed a
>>>>> ton
>>>>> of
>>>>> ruby stuff, so it's possible my setup's errors will be unique : )
>>>>>
>>>>> Moses
>>>>>
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:1283:in
>>>>> `initialize'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:1283:in `new'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:1283:in
>>>>> `create_socket'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:1252:in `connect'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:1251:in `timeout'
>>>>> /usr/local/lib/ruby/1.8/timeout.rb:55:in `timeout'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:1251:in `connect'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:1111:in `query'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:833:in `query'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:383:in
>>>>> `do_get_block'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:327:in
>>>>> `conn_request'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:259:in `request'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:234:in `get'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/http-access2.rb:209:in
>>>>> `get_content'
>>>>> /usr/local/lib/ruby/1.8/wsdl/importer.rb:39:in `import'
>>>>> /usr/local/lib/ruby/1.8/wsdl/importer.rb:20:in `import'
>>>>> /usr/local/lib/ruby/1.8/wsdl/import.rb:65:in `import'
>>>>> /usr/local/lib/ruby/1.8/wsdl/import.rb:49:in `parse_attr'
>>>>> /usr/local/lib/ruby/1.8/wsdl/parser.rb:143:in `decode_tag'
>>>>> /usr/local/lib/ruby/1.8/wsdl/parser.rb:126:in `each'
>>>>> /usr/local/lib/ruby/1.8/wsdl/parser.rb:126:in `decode_tag'
>>>>> /usr/local/lib/ruby/1.8/wsdl/parser.rb:81:in `start_element'
>>>>> /usr/local/lib/ruby/1.8/xsd/xmlparser/parser.rb:67:in
>>>>> `start_element'
>>>>> /usr/local/lib/ruby/1.8/xsd/xmlparser/xmlscanner.rb:139:in
>>>>> `on_stag_end'
>>>>> /usr/local/lib/ruby/1.8/xsd/xmlparser/xmlscanner.rb:134:in
>>>>> `on_stag_end_empty'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/xmlscan/scanner.rb:470:in
>>>>> `on_stag_end_empty'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/xmlscan/scanner.rb:794:in
>>>>> `scan_stag'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/xmlscan/scanner.rb:826:in
>>>>> `scan_content'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/xmlscan/scanner.rb:1051:in
>>>>> `scan_prolog'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/xmlscan/scanner.rb:1058:in
>>>>> `scan_document'
>>>>> /usr/local/lib/ruby/site_ruby/1.8/xmlscan/scanner.rb:1073:in
>>>>> `parse'
>>>>> /usr/local/lib/ruby/1.8/xsd/xmlparser/xmlscanner.rb:25:in
>>>>> `do_parse'
>>>>> /usr/local/lib/ruby/1.8/wsdl/parser.rb:62:in `parse'
>>>>> /usr/local/lib/ruby/1.8/wsdl/importer.rb:43:in `import'
>>>>> /usr/local/lib/ruby/1.8/wsdl/importer.rb:20:in `import'
>>>>> /usr/local/lib/ruby/1.8/soap/wsdlDriver.rb:71:in `import'
>>>>> /usr/local/lib/ruby/1.8/soap/wsdlDriver.rb:35:in `initialize'
>>>>> test_eruby.rb:12:in `new'
>>>>>
>>>>>
>>>>> On Dec 9, 2004, at 10:53 PM, Toshiaki Katayama wrote:
>>>>>
>>>>>> Hi,
>>>>>>
>>>>>> I have not completed esoap.rb yet. :)
>>>>>>
>>>>>> It seems that wsdl:import fails when loading eutils.wsdl in Ruby
>>>>>> 1.8.1
>>>>>> (comes with SOAP4R). Any ideas?
>>>>>>
>>>>>> Regards,
>>>>>> Toshiaki Katayama
>>>>>>
>>>>>> esoap_test.rb:
>>>>>> -------------------------
>>>>>> #!/usr/bin/env ruby
>>>>>>
>>>>>> require 'soap/wsdlDriver'
>>>>>>
>>>>>> wsdl =
>>>>>> "http://eutils.ncbi.nlm.nih.gov/entrez/eutils/soap/eutils.wsdl"
>>>>>>
>>>>>> driver = SOAP::WSDLDriverFactory.new(wsdl).create_driver
>>>>>> -------------------------
>>>>>>
>>>>>> % ruby esoap.rb
>>>>>> /usr/local/lib/ruby/1.8/soap/netHttpClient.rb:121:in
>>>>>> `create_connection': Cannot connect to egquery.xsd (Not HTTP.)
>>>>>> (RuntimeError)
>>>>>> from /usr/local/lib/ruby/1.8/soap/netHttpClient.rb:91:in
>>>>>> `start'
>>>>>> from /usr/local/lib/ruby/1.8/soap/netHttpClient.rb:82:in
>>>>>> `get_content'
>>>>>> from /usr/local/lib/ruby/1.8/wsdl/importer.rb:39:in
>>>>>> `import'
>>>>>> from /usr/local/lib/ruby/1.8/wsdl/importer.rb:20:in
>>>>>> `import'
>>>>>> from /usr/local/lib/ruby/1.8/wsdl/import.rb:65:in `import'
>>>>>> from /usr/local/lib/ruby/1.8/wsdl/import.rb:49:in
>>>>>> `parse_attr'
>>>>>> from /usr/local/lib/ruby/1.8/wsdl/parser.rb:141:in
>>>>>> `decode_tag'
>>>>>> from /usr/local/lib/ruby/1.8/wsdl/parser.rb:124:in `each'
>>>>>> ... 9 levels...
>>>>>> from /usr/local/lib/ruby/1.8/soap/wsdlDriver.rb:69:in
>>>>>> `import'
>>>>>> from /usr/local/lib/ruby/1.8/soap/wsdlDriver.rb:33:in
>>>>>> `initialize'
>>>>>> from esoap_test.rb:5:in `new'
>>>>>> from esoap_test.rb:5
>>>>>>
>>>>>>
>>>>>>
>>>>>> On 2004/12/10, at 7:51, Moses Hohman wrote:
>>>>>>
>>>>>>> It would be great if you could help out. esoap.rb is not in CVS,
>>>>>>> so
>>>>>>> Toshiaki will have to email it : )
>>>>>>>
>>>>>>> Moses
>>>>>>>
>>>>>>> On Dec 9, 2004, at 4:35 PM, david wheeler wrote:
>>>>>>>
>>>>>>>> Hi:
>>>>>>>>
>>>>>>>> Is it still true that esoap.rb is not working? Is the current
>>>>>>>> version available? If so, I'd be happy to help if I could get a
>>>>>>>> copy.
>>>>>>>>
>>>>>>>> David Wheeler, NCBI
>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> BioRuby mailing list
>>>>>>>> BioRuby at open-bio.org
>>>>>>>> http://portal.open-bio.org/mailman/listinfo/bioruby
>>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> BioRuby mailing list
>>>>>>> BioRuby at open-bio.org
>>>>>>> http://portal.open-bio.org/mailman/listinfo/bioruby
>>>>>>
>>>>>> _______________________________________________
>>>>>> BioRuby mailing list
>>>>>> BioRuby at open-bio.org
>>>>>> http://portal.open-bio.org/mailman/listinfo/bioruby
>>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> BioRuby mailing list
>>>>> BioRuby at open-bio.org
>>>>> http://portal.open-bio.org/mailman/listinfo/bioruby
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> BioRuby mailing list
>>>>> BioRuby at open-bio.org
>>>>> http://portal.open-bio.org/mailman/listinfo/bioruby
>>>>
>>>> _______________________________________________
>>>> BioRuby mailing list
>>>> BioRuby at open-bio.org
>>>> http://portal.open-bio.org/mailman/listinfo/bioruby
>>>>
>>> _______________________________________________
>>> BioRuby mailing list
>>> BioRuby at open-bio.org
>>> http://portal.open-bio.org/mailman/listinfo/bioruby
>>>
>>
>> _______________________________________________
>> BioRuby mailing list
>> BioRuby at open-bio.org
>> http://portal.open-bio.org/mailman/listinfo/bioruby
>>
> _______________________________________________
> BioRuby mailing list
> BioRuby at open-bio.org
> http://portal.open-bio.org/mailman/listinfo/bioruby
>
More information about the BioRuby
mailing list