Savon: Adding an encoding to the body tag-Collection of common programming errors
How can I add an encoding attribute to the body tag using Savon?
Some background: I am trying to use savon to connect to a SOAP resource. I can get the WSDL file and browse through the methods.
@client = Savon::Client.new("http://some.domain.com/v2messaging/service?WSDL")
when I try to use the login method
response = @client.request :service, :login do
soap.body = {
"String_1" => "username",
"String_2" => "password"
}
end
I get this error:
Failure/Error: response = @client.request :service, :login do Savon::SOAP::Fault: (env:Client) caught exception while handling request: unexpected encoding style: expected=http://schemas.xmlsoap.org/soap/encoding/, actual
The difference in the body tag. Here is the expected xml (found through SOAPUI application):
username
password
Savon sends:
username
password
There are a few difference between these, but the error returned has to do with the env:encodingStyle attribute on the env:login tag. How can add this attribute?