1

在 Savon 1 中,我可以使用soap.input添加xmlns如下:

soap_client = Savon.client("http://pathtowsdl.com/a.svc?wsdl")

response = soap_client.request "AnAction" do
  http.headers["soapAction"] = "AnAction"
  soap.input = ["AnAction", {"xmlns" => "http://apathtosomething.com"}]
  soap.body = {
    "SomeAttribute" => "SomeValue"
  }
end

在 Savon 2 中,我可以做,client.call(:authenticate, message_tag: :authenticationRequest) 但如何添加xmlnsauthenticationRequest标签?

4

2 回答 2

5

您必须将属性添加到调用中,例如。

client.call('CreateRequest', :attributes => { 'xmlns' => 'xyz' })
于 2013-09-10T03:34:37.127 回答
1
#!/usr/bin/env ruby

require 'savon'

soap_client = Savon.client( endpoint: 'http://example.com',
                            namespace: 'http://v1.example.com')
soap_client.call(:authenticate, 
                 message_tag: :authenticationRequest, 
                 :attributes => { "xmlns" => "http://apathtosomething.com" })

输出

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns:wsdl="http://v1.example.com"
              xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <wsdl:authenticationRequest xmlns="http://apathtosomething.com">
    </wsdl:authenticationRequest>
  </env:Body>
</env:Envelope>
于 2013-09-10T03:32:57.783 回答