Search code examples
rubysoapsavonws-addressing

How do I add an attribute to a SOAP header with Savon?


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?


Solution

  • 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"