0

我目前正在从事新项目,我对 savon 非常陌生。我目前正在使用 ruby​​-1.8.7 和 savon-1.0.0 并且我有以下 SOAP XML 请求

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webservices">
<soapenv:Header/>
<soapenv:Body>
<web:InvokeComponent1 soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<PartnerName xsi:type="xsd:string">ABC</PartnerName>
<ComponentName xsi:type="xsd:string">TestingServices</ComponentName>
<arg1Value xsi:type="xsd:string">[CONTROL]
RequestID=83f6baab
RequestTime=13:14:15
RequestDate=08/08/2013
GenerateLead=N
Auto=Y
</arg1Value>
<RaUID xsi:type="xsd:string">username</RaUID>
<RaPW xsi:type="xsd:string">password1</RaPW>
<AgNO xsi:type="xsd:string">12345</AgNO>
</web:InvokeComponent1>
</soapenv:Body>
</soapenv:Envelope>

这是我为此请求自动化编写的 Savon 代码,显然下面提到的代码不起作用,因为我需要一些输入。

  1. 我不确定在哪里包含soapenv:Header,我尝试将请求放入如下代码所示(当前已注释),但我得到'undefined method `header =' for # (NoMethodError)'。在 savon 请求中包含标头的位置?

  2. 在 SOAP 请求名称中,我有一个附加属性 soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" 我应该在哪里包含这个附加属性。

    client = Savon::Client.new do |wsdl|
    wsdl.document = "https://www.abc.com/webservices/RemotePublicGateway.cfc?wsdl"  # this is not actual WSDL
    end
    
    testing_string = '[CONTROL]
    RequestID=83f6baab
    RequestTime=13:14:15
    RequestDate=08/08/2013
    GenerateLead=N
    Auto=Y'
    
     response = client.request :web, "InvokeComponent1" do
    #client.header = { }
     soap.body = {
    :PartnerName  => 'ABC', :attributes! => { :PartnerName => { 'xsi:type' => "xsd:string" } },
    :ComponentName => 'TestingServices', :attributes! => { :ComponentName => { 'xsi:type' => "xsd:string" } },
    :arg1Value => testing_string, :attributes! => { :arg1Value => { 'xsi:type' => "xsd:string" } },
    :RaUID => 'username', :attributes! => { :RaUID => { 'xsi:type' => "xsd:string" } },
    :RaPW => 'password1', :attributes! => { :RaPW => { 'xsi:type' => "xsd:string" } },
    :AgNO=> '12345', :attributes! => { :AgNO => { 'xsi:type' => "xsd:string" } }
    }
    end
    
4

1 回答 1

0

在“soap.body”值之后添加以下行,它也适用于 SAVON 1.0.0 和 Ruby 1.8.7

:AgNO=> 'XXXXXXXXX...}},
:order!     => [:PartnerName, :ComponentName,:arg1Value,:RaUID,:RaPW,:AgNO]
}
于 2014-07-29T14:09:21.693 回答