Simple "pass-thru" SOAP4R web service

K

Kevin Turner

I'm trying to write a simple "pass-thru" web service using SOAP4R. This
web service will take the message passed and write it as XML to a file.
I don't want the web service to have to understand the format of the
incoming message,just write it to a file. I also want the service to
take the contents of an xml file and return it to the caller. I've
played with the soap marshal methods, and got close but I think the
answer is much easier than what I've been doing. I'm brand new to Ruby
and would appreciate any advice.

Thanks,
-Kevin

INBOUND SOAP MESSAGE:

<?xml version='1.0'?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<postorder xmlns="http://testit.com/webservices">
<request>
<order_no>123</order_no>
<order_date>20060216</order_date>
<line_items>
<item color="red">Sample item ONE</item>
<item color="blue">Sample item TWO</item>
</line_items>
</request>
</postorder>
</soap:Body>
</soap:Envelope>

SIMPLE WEB SERVICE:

require 'soap/marshal'
require 'xmlsimple'

class Order

def postorder(request)
# How do I take request and write to file as xml?
puts "inspect: #{request.inspect}"

# Now I want the web service return message to
# be the xml from a file.
retxml = XmlSimple.xml_in('returnxml.xml')
# The following is close but not right.
# The caller gets a single string, not xml data.
XmlSimple.xml_out(retxml)
end


end

VALUE OF request.inspect

inspect: #<SOAP::Mapping::Object:0x2ecdb5c {}order_no="123"
{}order_date="20060216" {}line_items=#<SOAP::Mapping::Object:0x2ecd61c
{}item=["Sample item ONE", "Sample item TWO"]>>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,585
Members
45,080
Latest member
mikkipirss

Latest Threads

Top