Extract data from SOAP response

Hi everyone

I am using a SOAP web service to get some information. The SOAP4R
library is supposed to create methods for the elements in a SOAP
response. When I do my SOAP call these methods are not created. The
informations shows up when I do soap_response.inspect but I cannot
access it directly. Is there any way to get access to the raw XML
response so I can parse it myself?

Kindest regards and thanks in advance

Erik L.

Erik,

You can use REXML to parse the response directly, which I find easier
than messing with the generated methods. You have to learn a little
Xpath, but it’s pretty easy to pick up. I use code like this:

require ‘rexml/document’
require ‘rexml/formatters/pretty’

response = REXML::Document.new(soap_result)

element = xml.elements[’//result’] # can use any Xpath query here
if element.attributes[‘code’] == “100”

etc

else

etc

end

-Mike Subelsky
Hacker & Improvisor // subelsky.com

Erik L. wrote:

Great advice Mike. I will definitely use it. The problem (which feels
quite silly) is that I cannot get the raw SOAP response from the
SOAP::Mapping::Object instance that is the result of the SOAP call. I
would like to do xml_tree =REXML::Document.new(soap_result.raw_xml)
But what is the raw_xml method?

Many thanks in advance

Erik

Hi Erik,

Were you able to resolve this issue? I am also having the same issue…
please help…I don’t know how to parse my SOAP::Mapping::Object

Googled a lot…but no use…

Thanks
Anu

Great advice Mike. I will definitely use it. The problem (which feels
quite silly) is that I cannot get the raw SOAP response from the
SOAP::Mapping::Object instance that is the result of the SOAP call. I
would like to do xml_tree =REXML::Document.new(soap_result.raw_xml)
But what is the raw_xml method?

Many thanks in advance

Erik

hi all,

can you help me how i can use soap response as xml file in Rexml.

for example:

response = obj.createUser(createUsers)

response is my final result which i am getting by running script.

so if i use xml_tree =REXML::Document.new(response.raw_xml)

that time it gives me error.

so anyone can tell me how can i convert this file to xml and use for
rexml.

i want to use rexml for parsing attribute from response file.

Thanks

Rpatel

hi all,

can you help me how i can use soap response as xml file in Rexml.

for example:

response = obj.createUser(createUsers)

response is my final result which i am getting by running script.

so if i use xml_tree =REXML::Document.new(response.raw_xml)

that time it gives me error.

so anyone can tell me how can i convert this file to xml and use for
rexml.

i want to use rexml for parsing attribute from response file.

Thanks

Rpatel

To get raw XML from SOAP4R set wiredump_file_base attribute of
SOAP::RPC::Driver instance to some string value. It will be used as a
prefix for files to save raw XML request and response in the current
dir.

Or, alternatively, do ‘driver.wiredump_dev = STDOUT’ and SOAP4R
will push raw XML to the console.

Dm.L.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs