Created
April 3, 2012 20:09
-
-
Save beneggett/2295197 to your computer and use it in GitHub Desktop.
Soap API for connecting to NS Savvi services
This file contains hidden or 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
require "savon" | |
# client = Savon::Client.new("http://api.savvistaging.com/account.svc?wsdl") | |
client = Savon::Client.new do | |
wsdl.namespace = "http://api.savvistaging.com/account.svc?wsdl" | |
wsdl.endpoint = "http://api.savvistaging.com/Account.svc/www/account" | |
end | |
response = client.request "CreateAccount" do | |
namespaces = { | |
"xmlns:soapenv" => "http://schemas.xmlsoap.org/soap/envelope/", | |
"xmlns:tem" => "http://tempuri.org/", | |
"xmlns:sav" => "http://schemas.datacontract.org/2004/07/Savvi.Services.Core.Common", | |
} | |
soap.element_form_default = :qualified | |
client.http.headers["SOAPAction"] = '"http://tempuri.org/IAccountService/CreateAccount"' | |
# soap.version = 2 | |
soap.xml(:xml) do |xml| | |
xml.soapenv(:Envelope, namespaces) do |xml| | |
xml.soapenv(:Header) | |
xml.soapenv(:Body) do |xml| | |
xml.tem(:CreateAccount) do |xml| | |
xml.tem(:apiUserName, "API_USERNAME") | |
xml.tem(:apiPassword, "API_PASSWORD") | |
xml.tem(:accountData) do |xml| | |
xml.sav(:Address) do |xml| | |
xml.sav(:Address1, "123 Fake Street") | |
xml.sav(:Address2, "Apt. C200") | |
xml.sav(:Address3, "Atn. Sir") | |
xml.sav(:AddressID, '1') | |
xml.sav(:City, "Holladay") | |
xml.sav(:CountryCode, "US") | |
xml.sav(:County, "Salt Lake") | |
xml.sav(:FirstName, "John") | |
xml.sav(:LastName, "Dover") | |
xml.sav(:Phone, "555-123-3214") | |
xml.sav(:PostalCode, "84117") | |
xml.sav(:State, "UT") | |
end | |
xml.sav(:Email, "[email protected]") | |
xml.sav(:FirstName, "John") | |
xml.sav(:LastName, "Dover") | |
xml.sav(:MiddleName, "Jackson") | |
xml.sav(:Password, "pass123") | |
xml.sav(:Phone, "555-123-3214") | |
xml.sav(:SubscriptionType, "BasicMember") | |
xml.sav(:TaxNumber, "2131312") | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment