在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)
但是如何将xmlns
添加到authenticationRequest
代码?
答案 0 :(得分:5)
您必须将该属性添加到呼叫中,例如
client.call('CreateRequest', :attributes => { 'xmlns' => 'xyz' })
答案 1 :(得分:0)
#!/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>