Savon

Savon can be installed as a gem via:

$ gem install savon

Dependencies

builder >= 2.1.2
crack >= 0.1.4

Warning

To use this heavy metal library, you should be familiar with SOAP, WSDL and tools like soapUI.

Instantiate Savon::Client

Instantiate a new instance of Savon::Client, passing in the WSDL of your service.

proxy = Savon::Client.new "http://example.com/UserService?wsdl"

The WSDL

You can find out about the SOAP actions available on the webservice by using the WSDL object.

proxy.wsdl.soap_actions
=> [:get_all_users, :get_user_by_id, :user_magic]

Find out more about the WSDL object.

Calling a SOAP action

Now, assuming your service applies to the default Options, you can just call any available SOAP action.

response = proxy.get_all_users

Savon lets you call SOAP actions using snake_case, because even though they will propably be written in lowerCamelCase or CamelCase, it just feels much more natural.

Parameters

Specifying parameters for the SOAP service, can be done by simply passing a Hash to the SOAP action.

response = proxy.get_user_by_id :id => 666

Learn more about [[Parameters]].

The response

By default, the SOAP response is translated into a Hash. Take a look at the Options for more information.

proxy.get_user_by_id :id => 666
=> { :user_response => { :id => "666", :username => "gorilla" } }

HTTP errors and SOAP faults

Savon raises a Savon::SOAPFault in case of a SOAP fault and a Savon::HTTPError in case of an HTTP error. More information about Errors.

Logging

By default Savon logs each request and response to STDOUT. Specifying your own logger is as easy as it gets:

Savon::Request.logger = RAILS_DEFAULT_LOGGER

Read more about Logging.

RDoc and Wiki

Further information: Wiki and RDoc