{"id":7013,"date":"2014-05-17T00:20:34","date_gmt":"2014-05-17T00:20:34","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/05\/17\/savon-adding-an-encoding-to-the-body-tag-collection-of-common-programming-errors\/"},"modified":"2014-05-17T00:20:34","modified_gmt":"2014-05-17T00:20:34","slug":"savon-adding-an-encoding-to-the-body-tag-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/05\/17\/savon-adding-an-encoding-to-the-body-tag-collection-of-common-programming-errors\/","title":{"rendered":"Savon: Adding an encoding to the body tag-Collection of common programming errors"},"content":{"rendered":"<p>How can I add an encoding attribute to the body tag using Savon?<\/p>\n<p>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.<\/p>\n<pre><code>@client = Savon::Client.new(\"http:\/\/some.domain.com\/v2messaging\/service?WSDL\")\n<\/code><\/pre>\n<p>when I try to use the login method<\/p>\n<pre><code>response = @client.request :service, :login do\n  soap.body = { \n    \"String_1\" =&gt; \"username\",\n    \"String_2\" =&gt; \"password\"\n  }\nend\n<\/code><\/pre>\n<p>I get this error:<\/p>\n<p><em>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<\/em><\/p>\n<p>The difference in the body tag. Here is the expected xml (found through SOAPUI application):<\/p>\n<pre><code>\n   \n   \n      \n        username\n        password\n      \n   \n\n<\/code><\/pre>\n<p>Savon sends:<\/p>\n<pre><code>\n\n    \n        \n            username\n            password\n        \n    \n\n<\/code><\/pre>\n<p>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?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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(&#8220;http:\/\/some.domain.com\/v2messaging\/service?WSDL&#8221;) when I try to use the login method response = @client.request :service, :login do [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7013","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7013"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7013\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}