2

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?

Magne
  • 16,401
  • 10
  • 68
  • 88

3 Answers3

2

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"


Magne
  • 16,401
  • 10
  • 68
  • 88
0

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
Steffen Roller
  • 3,464
  • 25
  • 43
  • I know, but that won't add the attribute to the header in question. (And that's important for my soap request to be accepted by the other end). – Magne Jan 26 '12 at 11:00
0

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

chuck son
  • 194
  • 2
  • 8