有人可以转换这个:
<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>
现在使用Soap gem SAVON,如何用client.request方法可以处理的正确语法编写呢?
我试过了:
client.request :tem, :authenticate, body: { "authenticationDet" => { "AccountType" => 0, "Password" => "bacon", "UserName" => "smith"}}
但是我收到了HTTP 400错误。
有什么建议吗?
答案 0 :(得分:0)
您需要设置其他命名空间。 SOAP操作必须用引号来匹配你的。
脚本可能如下所示:
#!ruby
require "savon"
Savon.configure do |c|
c.pretty_print_xml = true
c.env_namespace = :soapenv
end
client = Savon::Client.new do
wsdl.namespace = "http://test.org"
wsdl.endpoint = "http://localhost"
end
resp = client.request :tem, 'Authenticate' do
soap.namespaces["xmlns:hon"] = "http://schemas.datacontract.org/2004/08/TEST.RVU.Entity"
soap.body = { "tem:authenticationDet" =>
{ "hon:AccountType" => 0,
"hon:Password" => "bacon",
"hon:UserName" => "smith" }
}
end