Skip to content

Instantly share code, notes, and snippets.

@dotemacs
Created June 18, 2013 17:08
Show Gist options
  • Save dotemacs/5807298 to your computer and use it in GitHub Desktop.
Save dotemacs/5807298 to your computer and use it in GitHub Desktop.
require 'savon'
# setup
auth = {
"company" => "yes",
"username" => "aha",
"password" => "secret"
}
client = Savon.client headers: auth do
wsdl "/full/path/to/some.wsdl"
end
# I then run
puts client.operations
# one of the operations returned:
change_password
# whose request in SoapUI looks like this:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="urn:some-url">
<soapenv:Header>
<soap:niceheaders>
<soap:company>yes</soap:company>
<soap:username>aha</soap:username>
<soap:password>secret</soap:password>
</soap:niceheaders>
</soapenv:Header>
<soapenv:Body>
<soap:ChangePassword>
<soap:newpwd>abcabcabc8</soap:newpwd>
<!--Optional:-->
<soap:confirmpwd>bcdbcdbcd7</soap:confirmpwd>
</soap:ChangePassword>
</soapenv:Body>
</soapenv:Envelope>
# when I run the following:
client.call(:change_password, :message => {'newpwd' => "yesyesyes"})
# the debug gives me this:
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tns="urn:some-url"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<tns:ChangePassword07a>
<newpwd>yesyesyes</newpwd>
</tns:ChangePassword>
</env:Body>
</env:Envelope>
# This ouput of this is not valid, so I get an error back.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment