Created
June 6, 2010 21:09
-
-
Save rubiii/427900 to your computer and use it in GitHub Desktop.
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
# rubygems.org/gems/savon by examples | |
# overview of examples at: http://gist.github.com/gists/427837 | |
require "savon" | |
# = Instantiation | |
# | |
# Savon is based on the Savon::Client object. So the first thing you want to do, is to create a new | |
# Savon::Client instance. A few examples on using the Savon::Client with or without a WSDL are at: | |
# http://gist.github.com/427832 | |
client = Savon::Client.new do | |
wsdl.location = "http://users.example.com?wsdl" | |
end | |
# = SOAP actions | |
# | |
# When using Savon with a WSDL, you can ask Savon::WSDL about available SOAP actions. | |
client.wsdl.soap_actions # => [:get_user_by_id, :get_all_users] | |
# = Executing a SOAP request | |
# | |
# To execute a SOAP request, you just call the name of the SOAP action on the Savon::Client instance. | |
# | |
# When using Savon with a WSDL, you can name the method in snake_case without a problem. When you don't, | |
# Savon don't knows anything about your service, so it uses the convention of converting the method into | |
# lowerCamelCase. In case that doesn't work for you, please have a look at: http://gist.github.com/427897 | |
# | |
# To specify the payload for the SOAP action to receive, you can pass a Hash to Savon::SOAP#body. | |
# The Hash will be converted into XML via Hash#to_soap_xml. More information: http://gist.github.com/427915 | |
# | |
# You can also pass the raw XML as a String in case Hash#to_soap_xml does not work for you. | |
client.get_user_by_id do | |
soap.body = { :id => 12 } | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment