Forum: Ruby SOAP Client -getting data from SOAP::Mapping::Object?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
B907abfe7cbd49bb1d6496ff15613612?d=identicon&s=25 Mason Brown (masonbrown)
on 2007-05-23 04:42
I've been staring at this for too long, and at this point my mind can't
think clearly enough to continue without help...   I've never worked
with SOAP before, so forgive me if I'm overlooking something simple.

I'm using Ruby to access data via SOAP from a server (using soap4r and
http-access2).  I know I'm connecting successfully and getting the right
information, but don't know how to access the data from the response.
I've been testing with irb using the following:

require 'soap/wsdlDriver'
require 'http-access2'
wsdl = './proton.wsdl'
driver =
driver.options["protocol.http.cookie_store_file"] = './cookie.file'
driver.login('username', 'password')
result = driver.getEntities('2588676', 'IPv4Network', '0', '0')

The URL for the SOAP server is read correctly from the wsdl file, and
the methods "login" and "getEntityById" are also read from the wsdl.
"result" is an array with only one element:
"result[0].class => SOAP::Mapping::Object"

The result itself looks like a single string concatenating each of the
elements received in the response:

irb(main):013:0> result[0]
=> #<SOAP::Mapping::Object:0xac7e34

According to the WSDL, the response should be type APIEntity.Array,
which is composed of APIEntity objects with "id", "name", "properties",
and "type" elements (all defined in the wsdl).  So it looks like I'm
very close to having the data where I can actually use it (as an
accessible object or even an array), but I'm just not there yet.  Can
anyone tell me how to get the data out of the SOAP::Mapping::Object

8310c5a7c769345114597bcdef111488?d=identicon&s=25 (Guest)
on 2007-05-23 05:27
(Received via mailing list)
I've only messed with SOAP4r on one project, but I found that I could
get at the data in the response by treating it like a hash (a nested
hash, actually).

If you look at the wsdl for the service you're calling, it should
define the response you're expecting back... use the element names in
there as the hash keys. Or, you might be able to find some way of
iterating through the keys (.each_key maybe) in the response...

Or maybe I'm totally off base here.... :-)


This topic is locked and can not be replied to.