Heavy metal SOAP client

Savon v2 

The response provides a few convenience methods for you to work with the XML in any way you want.

Translates the response and returns the SOAP header as a Hash.

response.header  # => { token: "secret" }


Translates the response and returns the SOAP body as a Hash.

response.body  # => { response: { success: true, name: "luke" } }


Translates the response and returns it as a Hash.

response.hash  # => { envelope: { header: { ... }, body: { ... } } }

Savon uses Nori to translate the SOAP response XML to a Hash. You can change how the response is translated through a couple of global and local options. The following example shows the options available to configure Nori and their defaults.

client = Savon.client do
  # Savon defaults to strip namespaces from the response
  strip_namespaces true

  # Savon defaults to convert Hash key Symbols to lowerCamelCase XML tags
  convert_request_keys_to :camelcase
end do
  # Savon defaults to activate "advanced typecasting"
  advanced_typecasting true

  # Savon defaults to the Nokogiri parser
  response_parser :nokogiri

These options map to Nori's options and you can find more information about how they work in the README.


Returns the raw SOAP response.

response.to_xml  # => "<response><success>true</success><name>luke</name></response>"


Returns the SOAP response as a Nokogiri document.

response.doc  # => #<Nokogiri::XML::Document:0x1017b4268 ...


Delegates to Nokogiri's xpath method.

response.xpath("//v1:authenticateResponse/return/success").first.inner_text.should == "true"


Returns the HTTPI response.

response.http  # => #<HTTPI::Response:0x1017b4268 ...

In case you disabled the global :raise_errors option, you can ask the response for its state.

response.success?     # => false
response.soap_fault?  # => true
response.http_error?  # => false