如何使用 Savon 将属性添加到 SOAP 标头?

发布于 2024-12-29 04:49:58 字数 231 浏览 0 评论 0原文

我需要将此属性(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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

可是我不能没有你 2025-01-05 04:49:58

实际上,我能够对我的案例中的问题采取另一种解决方法,因为我的端点会接受这一点:

<env:Header>
  <wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">value</wsa:Action>
</env:Header>

调查原始问题,这是 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:

<env:Header>
  <wsa:Action xmlns:wsa="http://www.w3.org/2005/08/addressing">value</wsa:Action>
</env:Header>

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"


罗罗贝儿 2025-01-05 04:49:58

您可以将自己的名称空间添加到请求中,如下所示:

resp = client.request :soap_action do
    soap.namespace['xmlns:wsa'] = 'http://www.w3.org/2005/08/addressing'
end

You can add your own namespace to the request like this:

resp = client.request :soap_action do
    soap.namespace['xmlns:wsa'] = 'http://www.w3.org/2005/08/addressing'
end
浮云落日 2025-01-05 04:49:58

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文