Savon
Savon::Service is a SOAP client library to enjoy. The goal is to minimize the overhead of working with SOAP services and provide a lightweight alternative to other libraries.
Install
$ gem install rubiii-savon -s http://gems.github.com
Dependencies
rubiii-apricoteatsgorilla >= 0.5.2
hpricot 0.8.241 (the latest JRuby-compatible version)
Hpricot 0.8.241 is also available at: Apricot eats Gorilla Downloads
How to use
Instantiate a new Savon::Service instance passing in the WSDL of your service.
proxy = Savon::Service.new("http://example.com/ExampleService?wsdl")
Call the SOAP service method of your choice on your Savon::Service instance.
response = proxy.get_all_users
Or pass in a Hash of options for the SOAP service to receive.
response = proxy.find_user_by_id(:id => 123)
Or specify a custom XPath-Expression to start translating the SOAP response at. By default the response is translated starting at “//return”.
response = proxy.find_user_by_id(nil, "//user/email")
Check for available SOAP actions
Access the WSDL to get an Array of SOAP actions found in the WSDL document.
proxy.wsdl.soap_actions
# => [ "getAllUsers", "findUserById" ]
Handle HTTP error and SOAP faults
Savon::Service raises a Savon::SOAPFault in case of a SOAP fault and a Savon::HTTPError in case of an HTTP error.
Logging request and response
You should specify the logger to use before working with any service.
# example for Ruby on Rails
Savon.logger = RAILS_DEFAULT_LOGGER
Of course you can also specify the log level if needed. By default it’s set to :debug.
Savon.log_level = :info