将此 XML 请求转换为正确的 Savon 请求 [英] Convert this XML request to a proper Savon request
本文介绍了将此 XML 请求转换为正确的 Savon 请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以转换一下吗:
<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 方法可以处理的正确语法编写它?
now using Soap gem SAVON, how can I write this in a correct syntax that the client.request method can deal with it?
我试过了:
client.request :tem, :authenticate, body: { "authenticationDet" => { "AccountType" => 0, "Password" => "bacon", "UserName" => "smith"}}
但我收到 HTTP 400 错误.
but I get a HTTP 400 error.
有什么建议吗?
推荐答案
您需要设置额外的命名空间.SOAP 操作必须用引号引起来以匹配您的操作.
You need to set the additional namespace. The SOAP action has to be in quotes to match yours.
脚本可能如下所示:
#!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
这篇关于将此 XML 请求转换为正确的 Savon 请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文