使用soap4r从ruby生成soap消息时如何将name.value添加到标头
我已经从 wsdl 创建了一个驱动程序,
当我调用我的请求时,我希望标头包含一个元素,即我希望看到类似以下内容的内容:
REPLACE_WITH_ACTUAL 等等等等等等
然而,环顾四周,每个人都在谈论子类化 SOAP::Header::SimpleHandler 然后将实例注入 driver.headerhandler
但是,如果我这样做,那么我最终会得到一个嵌套标头,即 REPLACE_WITH_ACTUAL
因此,必须有一种方法可以将一个元素添加到现有的 headerhandler 中,这样我就可以执行类似
driver.headerhandler.AddElement("session", "123") 的
操作,但我找不到任何方法来做到这一点。 我还尝试了
driver.headerhandler["session"]="123" 和其他类似的技巧,但我找不到任何方法来完成这项工作。
看看 driver.headerhandler.methods,我看不到任何明显的机制。
非常感谢您指出如何做到这一点。
I've created a driver from wsdl
When I invoke my request, I would like the header to contain an element, i.e, I want to see something like the following:
REPLACE_WITH_ACTUAL
blah blah blah
However, looking around, everyone talks about subclassing SOAP::Header::SimpleHandler and then injecting an instance into the driver.headerhandler
However, if I do that, then I end up with a nested header, i.e,
REPLACE_WITH_ACTUAL
So there must be a way to just add an element to the existing headerhandler so I can do something like
driver.headerhandler.AddElement("session", "123")
but I can't find any way to do that. I also tried things like
driver.headerhandler["session"]="123" and other such tricks, but I can't find any way to make this work.
Looking at driver.headerhandler.methods, I cannot see any obvious mechanism.
Would really appreciate a pointer to how to to this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我团队中的一位同事在查看了我之前找到的一些典型示例(包括 http://dev.ctor.org/soap4r/browser/trunk/sample/soapheader/authheader/client2.rb
事实证明,这是微不足道的(叹气)解决方案是替换
为
现在,如果您只是将标头命名为“session”(在 QName 创建中),您将获得未嵌套的标头,这正是我想要的。
我想我应该将我的解决方案粘贴到我自己的问题上,假设其他人可能会遇到同样的问题。
Well, a colleague in my team solved the problem above after looking at some of the typical examples that I had previously found including the one at http://dev.ctor.org/soap4r/browser/trunk/sample/soapheader/authheader/client2.rb
Turns out that the trivial (sigh) solution is to replace
with
Now, if you just name the header "session" (in the QName creation), you get the unnested header, exactly what I wanted.
I thought I'd paste my solution to my own problem on the assumption that others might be running into the same problem.