Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.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 Savon返回命名错误错误_Ruby_Soap_Savon - Fatal编程技术网

Ruby Savon返回命名错误错误

Ruby Savon返回命名错误错误,ruby,soap,savon,Ruby,Soap,Savon,我是Savon的新手,在尝试发送soap请求时遇到nil:NilClass(NoMethodError)错误的configure_headers:undefined method% 我的代码如下所示 client = Savon.client do wsdl "http://sfds:9080/f/sca/BrokerService/WEBINF/wsdl/client/BrokerService_BrokerService.wsdl" soap_version "2" end res

我是Savon的新手,在尝试发送soap请求时遇到nil:NilClass(NoMethodError)错误的
configure_headers:undefined method
% 我的代码如下所示

client = Savon.client do
  wsdl "http://sfds:9080/f/sca/BrokerService/WEBINF/wsdl/client/BrokerService_BrokerService.wsdl"
  soap_version "2"
end

response =  client.call(:get_broker_details, message: { brokerId: 'testbroker' })
通过SoapUI的请求如下所示

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" 
 xmlns:oas="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-
 wssecurity-secext-1.0.xsd" 
 xmlns:xyz="http://xml.bnz.co.nz/bnzintegrationcommon/BNZServiceHeadeV120" 
 xmlns:brok="http://xml.xyz.co.nz/brokerservice/BrokerService">
   <soap:Header>
     <oas:Security>
     <!--Optional:-->
     <oas:UsernameToken>
        <oas:Username></oas:Username>
        <oas:Password></oas:Password>
     </oas:UsernameToken>
  </oas:Security>
     <x:serviceHeaderV120>
     <user>
        <channel>BKLP</channel>
        <!--Optional:-->
        <id idType="staffId">631447</id>
        <!--Optional:-->
        <subId></subId>
        <!--Optional:-->
        <location>BRCH0573</location>
     </user>
     <application>
        <id>1</id>
        <!--Optional:-->
        <correlationToken>11111</correlationToken>
     </application>
  </x:serviceHeaderV120>
</soap:Header>
 <soap:Body>
    <brok:getBrokerDetails>
       <getBrokerDetailsRequest>
         <brokerId>ZS1002</brokerId>
       </getBrokerDetailsRequest>
    </brok:getBrokerDetails>
 </soap:Body>
</soap:Envelope>

BKLP
631447
BRCH0573
1.
11111
ZS1002
非常感谢您的帮助。

如果您仔细查看,很容易找出错误的原因:

CONTENT_TYPE = {
  1 => "text/xml;charset=%s",
  2 => "application/soap+xml;charset=%s"
}

# ...

# This line was the cause of the error:
@http_request.headers["Content-Type"] ||= CONTENT_TYPE[@globals[:soap_version]] % @globals[:encoding]
该错误源于您在客户端中设置了
soap\u version“2”
(字符串)。相反,正如您从上面的散列中看到的,它需要是一个
整数

client = Savon.client do
  wsdl "http://sfds:9080/f/sca/BrokerService/WEBINF/wsdl/client/BrokerService_BrokerService.wsdl"
  soap_version 2 # <-- !!!
end
client=Savon.client do
wsdl“http://sfds:9080/f/sca/BrokerService/WEBINF/wsdl/client/BrokerService_BrokerService.wsdl"

soap#U版本2#棒极了。谢谢你,汤姆。它解决了我的问题。