views:

319

answers:

3

Hi,

I use ruby to get a report by calling a soap based web service method. By calling such a method (soap_driver.method_foo(params)) I am getting a ruby object of this type SOAP::Mapping::Object.

I inspect the object and get a bunch of QNames, which I try using it to get the info out of the object.

Considering the soapResponse is the object returned by the web method I have tried things like soapResponse["//some_elem"] .. stuff like that. But I get nils (except for the root).

What should I do to parse the object?

thanks

A: 

It seems the way to access the information within a SOAP object is to call public_methods onto the response object and look for the method that accesses an element. The return on that method is another object. Once again you can see the public methods and so on, repeating those steps until you reach the desired value.

example

responseObject.dailyStatisticsRecords.dailyStatisticRecords.dailyStatisticsRecord.totalCommission

+1  A: 

Not a direct answer but you could take a look at handsoap as it is cleaner Ruby SOAP client.

A: 

The SOAP call (method1) returns a SOAP::Mapping::Object which you can access as a hash using strings as the keys. The root element is named after the method you called.

result = soap_driver.method1(:param1 => 'foo', :param2 => 'bar')
puts result['method1Result']['field1']
puts result['method1Result']['field2']
John Naegle