2

如果我有以下 SOAP 请求:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:tem="http://test.org/" xmlns:hon="http://schemas.datacontract.org/2004/07/TEST.RVU.Entity">
   <soapenv:Header/>
   <soapenv:Body>
      <tem:Authenticate>
         <!--Optional:-->
         <tem:authenticationDet>
            <!--Optional:-->
            <hon:AccountType>0</hon:AccountType>
            <!--Optional:-->
            <hon:Password>bacon</hon:Password>
            <!--Optional:-->
            <hon:UserName>smith</hon:UserName>
         </tem:authenticationDet>
      </tem:Authenticate>
   </soapenv:Body>
</soapenv:Envelope>

如何使用包含 tem: 和 hon: 命名空间的 Savon gem 写下有效的肥皂请求?

谢谢

4

1 回答 1

1

您需要设置额外的命名空间。

脚本可能如下所示:

#!红宝石

需要“savon”

Savon.configure 做 |c|
  c.pretty_print_xml = 真
  c.env_namespace = :soapenv
结尾

客户 = Savon::Client.new 做
  wsdl.namespace = "http://test.org"
  wsdl.endpoint = "http://www.your-real-endpoint.com"
结尾

resp = client.request :tem, 'Authenticate' 做
  soap.namespaces["xmlns:hon"] = "http://schemas.datacontract.org/2004/08/TEST.RVU.Entity"
  soap.body = { "tem:authenticationDet" =>
                { "hon:AccountType" => 0,
                  "hon:密码" => "培根",
                  "hon:用户名" => "史密斯" }
              }
结尾

于 2012-10-17T04:12:13.707 回答