Savon soap请求ruby格式

时间:2013-08-21 02:43:15

标签: ruby soap savon

我目前正在开展新项目,而且我对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,我尝试将内部请求放入下面的代码中显示(目前已注释)但是我得到'未定义的方法`header ='用于#(NoMethodError)'。在savon请求中包含标题的位置?

  2. 在SOAP请求名称中的
  3. ,我有一个额外的属性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
    

1 个答案:

答案 0 :(得分:0)

在soap.body&#39;之后添加以下行。值和它也适用于SAVON 1.0.0和Ruby 1.8.7

:AgNO=> 'XXXXXXXXX...}},
:order!     => [:PartnerName, :ComponentName,:arg1Value,:RaUID,:RaPW,:AgNO]
}