Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

namespace of attributes not preserved in headers #18

Closed
akostadinov opened this issue Jun 7, 2016 · 2 comments
Closed

namespace of attributes not preserved in headers #18

akostadinov opened this issue Jun 7, 2016 · 2 comments

Comments

@akostadinov
Copy link
Contributor

[97] pry(#<CucuShift::DefaultWorld>)> Kernel.puts n.to_xml
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Header>
    <ns1:sessionID xmlns:ns1="http://ws.polarion.com/session" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">-2947384893281700987</ns1:sessionID>
  </soapenv:Header>
  <soapenv:Body>
    <logInResponse xmlns="http://ws.polarion.com/SessionWebService-impl"/>
  </soapenv:Body>
</soapenv:Envelope>
[99] pry(#<CucuShift::DefaultWorld>)> auth_xml = n.xpath("//*[local-name()='sessionID']")

Then I do:

get_user.header.__node__ << auth_xml

In the response I end up with:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:ns0="http://ws.polarion.com/types" xmlns:ns1="http://ws.polarion.com/ProjectWebService-types" xmlns:ns2="http://ws.polarion.com/ProjectWebService-impl" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <ns1:sessionID xmlns:ns1="http://ws.polarion.com/session" actor="http://schemas.xmlsoap.org/soap/actor/next" mustUnderstand="0">-2947384893281700987</ns1:sessionID>
  </soap:Header>
  <soap:Body>
    <ns2:getUser>
      <ns2:userID>akostadi</ns2:userID>
    </ns2:getUser>
  </soap:Body>
</soap:Envelope>

Basically the actor and mustUnderstand attributes have been washed off their namespaces. Any idea how to fix this?

@akostadinov
Copy link
Contributor Author

akostadinov commented Jun 9, 2016

I think it is actually this bug sparklemotion/nokogiri#1200

Basically adding non-cloned element to another element may well result in bad namespace handling. I think that this needs to be fixed in the underlying libraries as making losoap too smart would be a double edged sword.

But still it's worth putting this somewhere in lolsoap documentation to avoid user confusion. Using WSDL is a heavily namespaced business if I can say it like that. Adding headers is a common operation and a warning in the readme will be well worth it IMO.

i.e. when adding element(s) that are part of another document, they better be added like request.header.__node__ << element.dup

In the akamai use case this is not needed as this a new element created. dup would be redundant. But in most other cases I think a dup would be needed.

@eugenebolshakov
Copy link
Contributor

This example in the README https://github.com/loco2/lolsoap#wsse is for WSSE using akami gem only. The gem takes care of the namespaces.

If you need to build a customer header you can just do so in the same way you'd build a body (clarified this in the README in b5f22ea):

request.header do |header|
  header.sessionID "-2947384893281700987"
  header.sessionID do |sid|
    sid.action "..."
  end
end

I'm closing this as it's not a lolsoap bug.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants