Ruby Syntax and SOAP Web Service

I need a good tutorial to show how to create a RUBY
SOAP request when I have an example SOAP request file. The example in my
book is next to useless. Also, how can I see that SOAP xml is being
sent
and the client response?

An example, I am attempting to call this service
(http://www.webservicex.net/uszip.asmx?op=GetInfoByZIP).

What I need to know is which namespace to use for the request. Also, do
I
need to add anything to specify the Envelope namespaces.

Thanks

P.S.
This is the example Soap request.

POST /uszip.asmx HTTP/1.1
Host: www.webservicex.net
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: “http://www.webserviceX.NET/GetInfoByZIP

<?xml version="1.0" encoding="utf-8"?>

<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

string

</soap:Body>
</soap:Envelope>

I never did find a decent tutorial on using SOAP in Ruby. However, I
did find bits and pieces in blogs and list archives. There’s actually
quite a bit of information in the SOAP4r trac (the Ruby SOAP code is
SOAP4r):

http://dev.ctor.org/soap4r

The biggest “ah-hah” moment for me was figuring out that you don’t
have generate a bunch of classes from WSDL in Ruby like in other
languages… you can, but Ruby is dynamic enough that you can just
create a driver instance from the WSDL and all the signatures in that
WSDL become available as method calls on the driver [1]. Similarly,
the SOAP response object is accessible as a nested hash of data or as
pseudo-method calls.

Hope this helps some!

Ben

[1] Here’s how I created my driver:

soap_driver = SOAP::WSDLDriverFactory.new(RAILS_ROOT + ‘/config/
somewebservice.wsdl’).create_rpc_driver

Then I can call every SOAP call listed in that wsdl just by calling
the name on the driver:

response = soap_driver.someWebService({ hash of params })

So in your example would be:
mH=Hash.new()
mH[“USZip”]=“92210”

response = soap_driver.someWebService(mH)

but this is not working…

Do you know why?

Thanks.

[email protected] wrote:

I never did find a decent tutorial on using SOAP in Ruby. However, I
did find bits and pieces in blogs and list archives. There’s actually