如何使用 Savon 将属性添加到 SOAP 标头?
我需要将此属性(xmlns:wsa="http://www.w3.org/2005/08/addressing")添加到soap标头中,如下所示:
<env:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
</env:Header>
我该怎么做,使用萨翁?
I need to add this attribute (xmlns:wsa="http://www.w3.org/2005/08/addressing") to the soap header, like this:
<env:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
</env:Header>
How do I do this, using Savon?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实际上,我能够对我的案例中的问题采取另一种解决方法,因为我的端点会接受这一点:
调查原始问题,这是 Savon 创建者的回应:
“嘿 magne,
查看创建 header 和 body 标签的代码,似乎没有
现在可以添加任何属性/命名空间而无需猴子修补:
https://github.com/rubiii/savon/blob/v0.9.7/lib/savon/soap/xml.rb#L151
如果您仍然需要此功能,请开票,我会看看我能做什么:
https://github.com/rubiii/savon/issues
我目前正在积极参与改进图书馆的新方法,
所以我不确定什么时候能解决你的问题。但是……我一起砍了
一个小猴子补丁,在实现此功能之前应该有所帮助:
https://gist.github.com/1698636
,
丹尼尔”
I was actually able to make another workaround to the problem in my case, since my endpoint would accept this:
Investigating the original question, here's the response from the Savon creator:
"hey magne,
looking at the code which creates the header and body tags, it doesn't seem
possible to add any attributes/namespaces without monkey-patching right now:
https://github.com/rubiii/savon/blob/v0.9.7/lib/savon/soap/xml.rb#L151
if you still need this feature, please open a ticket and i'll see what i can do:
https://github.com/rubiii/savon/issues
i'm currently very involved in taking a new approach to improve the library,
so i'm not sure when i'll be able to solve your problem. but ... i hacked together
a small monkey-patch that should help until this feature is implemented:
https://gist.github.com/1698636
cheers,
daniel"
您可以将自己的名称空间添加到请求中,如下所示:
You can add your own namespace to the request like this:
foo = client.request 做
soap.header['xmlns:wsa'] = 'http://www.w3.org/2005/08/addressing'
结尾
foo = client.request do
soap.header['xmlns:wsa'] = 'http://www.w3.org/2005/08/addressing'
end