如何阻止Savon向soap.body添加前缀
这就是我创建客户端的方式:
@client = Savon::Client.new do
wsdl.document = my_document
wsdl.endpoint = my_endpoint
end
这就是我获得响应的方式:
@response = @client.request :the_action do
soap.body = xml
soap.body = {"applicationId" => my_application_id }
end
但是,这会生成以下 xml:
"<ins5:applicationId>XXXXXXXXXXXXXX</ins5:applicationId>"
由于前缀,我的肥皂服务出现错误。如果我这样做,它会起作用:
@response = @client.request :the_action do
soap.body = "<applicationId>#{my_application_id}</applicationId>"
end
然而,由于各种原因,这很痛苦。有没有办法阻止 savon 附加前缀?
使用 savon 0.9.6。
This is how I am creating a a client:
@client = Savon::Client.new do
wsdl.document = my_document
wsdl.endpoint = my_endpoint
end
and this is how I'm getting a response:
@response = @client.request :the_action do
soap.body = xml
soap.body = {"applicationId" => my_application_id }
end
However, this generates the following xml:
"<ins5:applicationId>XXXXXXXXXXXXXX</ins5:applicationId>"
My soap service errors out because of the prefix. If I do this instead, it works:
@response = @client.request :the_action do
soap.body = "<applicationId>#{my_application_id}</applicationId>"
end
However this is a pain for various reasons. Is there a way to stop savon from attaching the prefix?
Using savon 0.9.6.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这看起来可能是 savon 0.9.6 中的错误。尝试更新您的客户端,创建如下代码:
编辑:如果其他人遇到此问题,则使用解决方案更新答案
事实证明,如果您提供 wsdl.document savon 将为您的元素添加前缀。您最好不要使用 wsdl 文档,而只定义您需要的名称空间,如下所示:
This looks like it might be a bug in savon 0.9.6. Try updating your client creating code like this:
Edit: updating answer with solution if someone else comes across this issue
It turns out if you provide a wsdl.document savon will prefix your elements. You're better off not using the wsdl document and just defining the namespaces you need like this: