Savon
Heavy metal SOAP client
Documentation | Support | Mailing list
Installation
Savon is available through Rubygems and can be installed via:
$ gem install savon
or add it to your Gemfile like this:
gem 'savon', '~> 2.17'
Usage example
require 'savon'
# create a client for the service
client = Savon.client(wsdl: 'http://service.example.com?wsdl')
# or: create a client with a wsdl provided as a string
client = Savon.client do |config|
wsdl_content = File.read("/path/to/wsdl")
config.wsdl wsdl_content
end
client.operations
# => [:find_user, :list_users]
# call the 'findUser' operation
response = client.call(:find_user, message: { id: 42 })
response.body
# => { find_user_response: { id: 42, name: 'Hoff' } }
For more examples, you should check out the integration tests.
Faraday transport
Savon uses HTTPI for HTTP by default. To opt into Faraday instead, add faraday to your Gemfile and set transport: :faraday:
client = Savon.client(
transport: :faraday,
wsdl: "http://service.example.com?wsdl"
)
Configure SSL, auth, timeouts, middleware, and anything else transport-related on the Faraday::Connection before making calls:
client.faraday.ssl.verify = false
client.faraday..timeout = 30
client.faraday..open_timeout = 5
client.faraday.headers["Authorization"] = "Bearer #{token}"
client.faraday.use Faraday::Response::Logger
Ruby version support
Every savon release is tested with contemporary supported versions of ruby. Historical compatibility information:
main- same support as Ruby- 2.15.x - MRI 3.0, 3.1, 3.2, 3.3
- 2.13.x, 2.14.x - MRI 2.7, 3.0, 3.1
- 2.12.x - MRI 2.2, 2.3, 2.4, 2.5
- 2.11.x - MRI 2.0, 2.1, 2.2, and 2.3
If you are running MRI 1.8.7, try a 2.6.x release.
Most changes are not backported to older versions of savon, or unsupported ruby versions.
Running tests
$ bundle install
$ bundle exec rspec
FAQ
- URI::InvalidURIError -- if you see this error, then it is likely that the http client you are using cannot parse the URI for your WSDL. Try
gem install httpclientor add it to yourGemfile.- See https://github.com/savonrb/savon/issues/488 for more info
Known limitations
WSDL imports are not followed
Savon uses Wasabi to parse WSDL documents. Wasabi parses only the root document. It does not fetch or inline documents referenced by wsdl:import or wsdl:include (wasabi#1, wasabi#56). All messages, portTypes, and bindings must be defined in the root WSDL file for Savon to see them.
Workaround: if you have access to the imported documents, manually merge their wsdl:message and wsdl:portType elements into the root document and pass that to Savon.
If you need full import support, consider WSDL as an alternative.
Documentation
Please be sure to read the documentation.