1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
require 'soap/wsdlDriver' URL = 'http://localhost/hello_world.wsdl' factory = SOAP::WSDLDriverFactory.new(URL) driver = factory.create_rpc_driver driver.wiredump_dev = STDERR begin // Invoke on the webservice here result = driver.sayHi result = driver.greetMe("dave") puts result rescue Exception => e #Handle SOAP Faults here end |
Invoking backend SOAP/HTTP Web Services with Ruby
Posted by dave
on October 06, 2006 @ 10:54 AM
So ya wanna invoke on a backend SOAP/HTTP Web Service from Rails do ye? SOAP4R (SOAP 4 Ruby) gets the job done as follows:
This code snippet uses SOAP4R 1.5.5. This is a somewhat simplified example as theres only two methods defined in the wsdl, sayHi takes 0 parameters and greetMe just takes a string. Needless to say, this can be placed inside your Ruby on Rails controller too. If you have complextypes it looks as though you need to use wsdl2ruby to generate helper classes for the complextypes.
I might be doing something wrong, but this version of SOAP4R looks to have some problems handling one particular rpc/literal wsdl I have here, but a bit more digging is required.