Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby 正确构造这个SOAP头?_Ruby_Soap_Savon - Fatal编程技术网

Ruby 正确构造这个SOAP头?

Ruby 正确构造这个SOAP头?,ruby,soap,savon,Ruby,Soap,Savon,我正在尝试构建一个合适的SOAP头: <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/"

我正在尝试构建一个合适的SOAP头:

<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>
我收到以下SOAP错误:

fault=>
  {:faultcode=>"soapenv:Server",
  :faultstring=>"java.lang.NullPointerException",
  :detail=>nil}}
如何获取
sapoenv:mustUserstand=“0”
行,它是什么

此外,我还不知道如何设置
xmlns:ns=”http://webservices.averittexpress.com/authn“>

我几乎没有使用SOAP请求的经验,我来自Ruby/Rails RESTful背景。任何帮助都将不胜感激

Savon用于将SOAP头和体转换为XML。
按照此惯例,您的哈希需要如下所示:

soap_header = {
  "ns:authnHeader" => {
    "@soapenv:mustUnderstand" => 0,
    "@xmlns:ns" => "http://webservices.averittexpress.com/authn",
    "Username"  => "x",
    "Password"  => "x"
  }
}

Savon.client(:soap_header => soap_header)
Savon用于将SOAP标头和正文转换为XML。
按照此惯例,您的哈希需要如下所示:

soap_header = {
  "ns:authnHeader" => {
    "@soapenv:mustUnderstand" => 0,
    "@xmlns:ns" => "http://webservices.averittexpress.com/authn",
    "Username"  => "x",
    "Password"  => "x"
  }
}

Savon.client(:soap_header => soap_header)

谢谢你。不过,有一个问题是,在我的回答中,我仍然只收到一个{:fault=>{:faultcode=>“soapenv:Server”,:faultstring=>“java.lang.NullPointerException”}}错误。根据你的经验,这到底意味着什么?lolit表示服务缺少测试:)这是一个非常基本的代码问题。什么都可以。再次感谢你的帮助。我必须将我的命名空间指定为“”,因为wsdl文件出于某种原因正在设置它。现在我得到了一些实际有用的错误。谢谢你。不过,有一个问题是,在我的回答中,我仍然只收到一个{:fault=>{:faultcode=>“soapenv:Server”,:faultstring=>“java.lang.NullPointerException”}}错误。根据你的经验,这到底意味着什么?lolit表示服务缺少测试:)这是一个非常基本的代码问题。什么都可以。再次感谢你的帮助。我必须将我的命名空间指定为“”,因为wsdl文件出于某种原因正在设置它。现在我得到了实际有用的错误。