Skip to content
This repository has been archived by the owner on Sep 7, 2019. It is now read-only.

MGPalmer/savon

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Savon

Heavy metal Ruby SOAP client library

Documentation | Twitter

Installation

$ gem install savon

Savon expects you to be familiar with SOAP, WSDL and tools like soapUI.

Instantiate a client

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

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

For production, it is highly recommended to not use Savon::WSDL. Information on how to disable the WSDL.

Calling a SOAP action

Assuming your service applies to the defaults, you can now call any available SOAP action.

response = client.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.

The WSDL object

Savon::WSDL represents the WSDL of your service, including information like the namespace URI and available SOAP actions.

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

The SOAP object

Savon::SOAP represents the SOAP request. Pass a block to your SOAP call and the SOAP object is passed to it as the first argument. The object allows setting the SOAP version, header, body and namespaces per request.

response = client.get_user_by_id { |soap| soap.body = { :id => 666 } }

The WSSE object

Savon::WSSE represents WSSE authentication. Pass a block to your SOAP call and the WSSE object is passed to it as the second argument. The object allows setting the WSSE username, password and whether to use digest authentication.

response = client.get_user_by_id do |soap, wsse|
  wsse.username = "gorilla"
  wsse.password = "secret"
  soap.body = { :id => 666 }
end

The Response object

Savon::Response represents the HTTP and SOAP response. It contains and raises errors in case of an HTTP error or SOAP fault (unless disabled). Also you can get the response as XML (for parsing it with an XML library) or translated into a Hash.

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: Errors

Logging

Savon logs each request and response to STDOUT. But there are a couple of options to change the default behavior. More information: Logging

About

Heavy metal Ruby SOAP client

Resources

License

Stars

Watchers

Forks

Packages

No packages published