Reputation: 2573
I'm attempting to build a proper SOAP header:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:sen="https://webservices.averittexpress.com/SendWebImageService">
<soapenv:Header
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ns:authnHeader
soapenv:mustUnderstand="0"
xmlns:ns="http://webservices.averittexpress.com/authn">
<Username>xxxxxxxx</Username> <Password>xxxxxxxx</Password>
</ns:authnHeader> </soapenv:Header>
This is my Savon client call, I'm using version 2:
client = Savon.client(
wsdl: api_url,
raise_errors: false,
convert_request_keys_to: :camelcase,
element_form_default: :qualified,
env_namespace: :soapenv,
soap_header: {'username' => username, 'password' => password }
)
I'm getting the following SOAP error:
fault=>
{:faultcode=>"soapenv:Server",
:faultstring=>"java.lang.NullPointerException",
:detail=>nil}}
How do I get the sapoenv:mustUserstand="0"
line, and what is it?
Plus I'm confused how to set the xmlns:ns="http://webservices.averittexpress.com/authn">
.
I've little experience using SOAP requests, and am coming from a Ruby/Rails RESTful background. Any help would be appreciated.
Upvotes: 2
Views: 2052
Reputation: 6983
Savon uses Gyoku to convert both SOAP header and body to XML.
Following this libraries conventions, here's what your Hash needs to look like:
soap_header = {
"ns:authnHeader" => {
"@soapenv:mustUnderstand" => 0,
"@xmlns:ns" => "http://webservices.averittexpress.com/authn",
"Username" => "x",
"Password" => "x"
}
}
Savon.client(:soap_header => soap_header)
Upvotes: 4