Simple "pass-thru" SOAP4R web service


#1

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


<order_no>123</order_no>
<order_date>20060216</order_date>
<line_items>
Sample item ONE
Sample item TWO
</line_items>


</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”]>>