class Savon::Client
client.request
You can also access Savon::Request via:
== Savon::Request
client.wsdl
You can access Savon::WSDL via:
== Savon::WSDL
client = Savon::Client.new “example.com/UserService?wsdl”, :gzip => true
Sending gzipped SOAP requests can be specified per client instance.
== Gzipped SOAP requests
client = Savon::Client.new “example.com/UserService?wsdl”, :soap_endpoint => “localhost/UserService”
another SOAP endpoint.
In case you don’t want to use the SOAP endpoint specified in the WSDL, you can tell Savon to use
== Forcing a particular SOAP endpoint
client = Savon::Client.new “example.com/UserService?wsdl”, :proxy => “proxy.example.com”
You can specify the URI to a proxy server via optional hash arguments.
== Using a proxy server
for Savon::WSDL for more information about how to disable it.
It is recommended to not use Savon::WSDL for production. Please take a look at the Documentation
client = Savon::Client.new “example.com/UserService”
Client instance with a SOAP endpoint (for using Savon without a WSDL):
client = Savon::Client.new “example.com/UserService?wsdl”
Client instance with a WSDL endpoint:
Savon::Client by passing in the WSDL or SOAP endpoint.
Depending on whether you aim to use Savon with or without Savon::WSDL, you need to instantiate
== Instantiation
both the Savon::WSDL and Savon::Request object.
Savon::Client is the main object for connecting to a SOAP service. It includes methods to access
= Savon::Client
def call(method, *args, &block)
Same as method_missing. Workaround for SOAP actions that method_missing does not catch
def call(method, *args, &block) method_missing method, *args, &block end
def initialize(endpoint, options = {})
[gzip] whether to gzip SOAP requests
[proxy] the proxy server to use
==== Options:
Expects a SOAP +endpoint+ string. Also accepts a Hash of +options+.
def initialize(endpoint, options = {}) soap_endpoint = options.delete(:soap_endpoint) @request = Request.new endpoint, options @wsdl = WSDL.new @request, soap_endpoint end
def method_missing(method, *args, &block) #:doc:
Dispatches requests to SOAP actions matching a given +method+ name.
def method_missing(method, *args, &block) #:doc: soap_action = soap_action_from method.to_s super unless @wsdl.respond_to? soap_action setup_objects *@wsdl.operation_from(soap_action), &block Response.new @request.soap(@soap) end
def respond_to?(method)
def respond_to?(method) return true if @wsdl.respond_to? method super end
def setup_objects(action, input, &block)
Expects a SOAP operation Hash and sets up Savon::SOAP and Savon::WSSE. Yields them to a given
def setup_objects(action, input, &block) @soap, @wsse = SOAP.new(action, input, soap_endpoint), WSSE.new yield_objects &block if block @soap.namespaces["xmlns:wsdl"] ||= @wsdl.namespace_uri if @wsdl.enabled? @soap.wsse = @wsse end
def soap_action_from(method)
Sets whether to use Savon::WSDL by a given +method+ name and returns the original method name
def soap_action_from(method) @wsdl.enabled = !method.ends_with?("!") method.chop! if method.ends_with?("!") method.to_sym end
def soap_endpoint
def soap_endpoint @wsdl.enabled? ? @wsdl.soap_endpoint : @request.endpoint end
def yield_objects(&block)
Yields either Savon::SOAP or Savon::SOAP and Savon::WSSE to a given +block+, depending on
def yield_objects(&block) case block.arity when 1 then yield @soap when 2 then yield @soap, @wsse end end