forked from savonrb/savon
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
145 additions
and
156 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,71 @@ | ||
= Savon | ||
h1. Savon | ||
|
||
Savon::Service is a SOAP client library to enjoy. The goal is to minimize | ||
the overhead of working with SOAP services and provide a lightweight | ||
alternative to other libraries. | ||
p. Savon can be installed as a gem from the "gemcutter":http://gemcutter.org repository. | ||
Please follow the steps on their website to set up your rubygems installation. | ||
|
||
== Install | ||
bc. $ gem install savon | ||
|
||
The gem for Savon is in the {gemcutter}[http://gemcutter.org] repository. | ||
Please follow the steps on their website to set up your rubygems installation. | ||
Afterwards you can install the gem like this: | ||
h3. Dependencies | ||
|
||
bc. cobravsmongoose = 0.0.2 | ||
hpricot 0.8.2 (JRuby-compatible version) | ||
|
||
h2. Getting started | ||
|
||
p. Instantiate a new instance of Savon::Service, passing in the WSDL of your service. | ||
|
||
bc. proxy = Savon::Service.new 'http://example.com/UserService?wsdl' | ||
|
||
$ gem install savon | ||
h3. The WSDL | ||
|
||
== Dependencies | ||
p. Use the WSDL object to find out about the SOAP actions offered by the service. | ||
|
||
cobravsmongoose = 0.0.2 | ||
hpricot 0.8.2 (JRuby-compatible version) | ||
bc. proxy.wsdl.soap_actions | ||
=> ["getAllUsers", "getUserById"] | ||
|
||
== How to use | ||
p. Find out more about the [[WSDL]] object. | ||
|
||
Instantiate a new Savon::Service instance passing in the WSDL of your service. | ||
h3. Calling a SOAP action | ||
|
||
proxy = Savon::Service.new("http://example.com/ExampleService?wsdl") | ||
p. Now without any setup (assuming your service applies to the default [[Options]]), | ||
you can just call any available SOAP action. | ||
|
||
Call the SOAP service method of your choice on your Savon::Service instance. | ||
bc. response = proxy.getAllUsers | ||
|
||
response = proxy.get_all_users | ||
p. In case your SOAP actions are named in lowerCamelCase or CamelCase you can also | ||
call them using snake_case, which feels much more natural. | ||
|
||
Or pass in a Hash of options for the SOAP service to receive. | ||
bc. response = proxy.get_all_users | ||
|
||
response = proxy.find_user_by_id(:id => 123) | ||
h3. Parameters | ||
|
||
Or specify a custom XPath-Expression to start translating the SOAP response at. | ||
By default the response is translated starting at "//return". | ||
p. Specifying parameters to be received by the SOAP service, can be done by passing | ||
a Hash to the SOAP action call. | ||
|
||
response = proxy.find_user_by_id(nil, "//user/email") | ||
bc. response = proxy.get_user_by_id 'id' => { '$' => "666" } | ||
|
||
=== Check for available SOAP actions | ||
p. Like to learn more about Parameters? Then take a look at: [[BadgerFish]]. | ||
|
||
Access the WSDL to get an Array of SOAP actions found in the WSDL document. | ||
h3. The response | ||
|
||
proxy.wsdl.soap_actions | ||
# => [ "getAllUsers", "findUserById" ] | ||
p. The SOAP (XML) response is translated into a Hash following the [[BadgerFish]] | ||
convention. By default (see [[Options]]) translation starts at the '//return' (XPath | ||
expression) node of the XML response. | ||
|
||
=== Handle HTTP error and SOAP faults | ||
bc. p proxy.get_user_by_id 'id' => { '$' => "666" } | ||
=> { 'user' => { '@id' => '666', '@username' => 'dude', '$' => 'biography' } } | ||
|
||
Savon::Service raises a Savon::SOAPFault in case of a SOAP fault and a | ||
Savon::HTTPError in case of an HTTP error. | ||
h3. HTTP errors and SOAP faults | ||
|
||
=== Logging request and response | ||
p. Savon raises a Savon::SOAPFault in case of a SOAP fault and a Savon::HTTPError | ||
in case of an HTTP error. More information about [[Errors]]. | ||
|
||
You should specify the logger to use before working with any service. | ||
h3. Logging | ||
|
||
# example for Ruby on Rails | ||
Savon.logger = RAILS_DEFAULT_LOGGER | ||
p. Savon logs each request and response, but you need to specify the logger and | ||
log level to use. | ||
|
||
Of course you can also specify the log level if needed. By default it's set to :debug. | ||
bc. Savon.logger = Logger.new STDOUT | ||
Savon.log_level = :info | ||
|
||
Savon.log_level = :info | ||
Read more about [[Logging]]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.