GithubHelp home page GithubHelp logo

savon's Introduction

Savon

Heavy metal Ruby SOAP client library

Documentation | Metrics

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

savon's People

Contributors

rubiii avatar futuremint avatar dwnoble avatar xymbol avatar snarglebritchet avatar keviningolfsland avatar lucascs avatar andrewmbenton avatar

Stargazers

Jérémy Lecour avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.