Friday, May 14, 2010

Calling a SOAP 1.2 webservice from Ruby

An earlier post showed how easy it is to call a SOAP 1.1 webservice from Ruby, but what happens when you've got a SOAP 1.2 service?

soap4r is out(?) - SOAP 1.2 support is on the roadmap, but doesn't look like it's been touched in a long time.

Luckily, there's a SOAP 1.2 client available for ruby called Savon (http://github.com/rubiii/savon).

Savon seems very easy to install and use:
sudo gem install savon
In your code, you'll need to do something like:
require 'savon'

Savon::SOAP.version=2

client = Savon::Client.new 'http://foo.bar.com/someService?wsdl'

response = client.some_soap_method_in_snake_case

# to see what's avail. as a SOAP method
# client.wsdl.soap_actions

No comments: