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

savon doesn't namespace soap header elements set by client.config.soap_header #305

Closed
kjg opened this issue Jul 12, 2012 · 15 comments
Closed

Comments

@kjg
Copy link
Contributor

kjg commented Jul 12, 2012

The wsdl contains the correct namespace info for the headers from https://ws5.responsys.net/webservices/wsdl/ResponsysWS_Level1.wsdl

<message name="Header">
  <part element="tns:SessionHeader" name="SessionHeader"/>
</message>
<message name="AuthHeader">
  <part element="tns:AuthSessionHeader" name="AuthSessionHeader"/>
</message>

but when calling

client.config.soap_header = {:session_header => { :session_id => 12345 } }

it sets the output to

<env:Header>
  <sessionHeader>
    <sessionId>12345</sessionId>
  </sessionHeader>
</env:Header>

instead of

<env:Header>
  <tns:SessionHeader>
    <tns:sessionId>12345</tns:sessionId>
  </tns:SessionHeader>
</env:Header>
@m-koepke
Copy link

I've run into the same problem. What you can do is actually setting the "namespace" in the hash keys:

client.config.soap_header = {"tns:sessionHeader" => { "tns:sessionId" => 12345 } }

But this should be done by savon.

@wallace
Copy link

wallace commented Aug 29, 2012

👍

@rubiii
Copy link
Contributor

rubiii commented Dec 10, 2012

not too sure about how savon should handle this.

@plentz
Copy link

plentz commented Dec 18, 2012

I have almost the same problem. I have this code:

client = Savon.client("http://www.bimobile.com.br/Broker/Integrator.svc?wsdl")
response = client.request(:send_one_message) do
  soap.body = { :companyId => 1, :userName => "Foo", :password => "bar", :phoneNumber => "123", :mobileOperator => 1, :messageText => "test" }
end

Which generate this xml

<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:tns="http://tempuri.org/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
<env:Body>
<tns:SendOneMessage>
  <companyId>1</companyId>
  <userName>Foo</userName>
  <password>Bar</password>
  <phoneNumber>123</phoneNumber>
  <mobileOperator>1</mobileOperator>
  <messageText>test</messageText>
</tns:SendOneMessage>
</env:Body>
</env:Envelope>

Notice that the parameters companyId, etc aren't prefixed by tns, as expected. I think that this should be applied to body as well as the header.

@plentz
Copy link

plentz commented Dec 18, 2012

Sorry, just find out the wsdl.element_form_default = :qualified option that does exactly what I want. RTFM for me.

@kjg
Copy link
Contributor Author

kjg commented Dec 18, 2012

@plentz For companyId to be namespaced you need the following for your client config:

Savon.client do
  wsdl.endpoint = "http://www.bimobile.com.br/Broker/Integrator.svc?wsdl"
  wsdl.element_form_default = :qualified
end

Check out the section on Qualified Locals at http://savonrb.com/ for more info.

The reason you're having this problem is because that wsdl at bimobile is using schema import and elementFormDefault="qualified" is within those imported files instead of in the toplevel wsdl. Unfortunately savon doesn't follow and parse the imports (yet).

@rubiii
Copy link
Contributor

rubiii commented Dec 18, 2012

this needs to be addressed. i've created #340 to collect related issues.

@rubiii
Copy link
Contributor

rubiii commented Jan 3, 2013

closing this one as there is a "roadmap" ticket for this problem. thanks for reporting.

@rubiii rubiii closed this as completed Jan 3, 2013
@kjg
Copy link
Contributor Author

kjg commented Jan 3, 2013

Which roadmap ticket? #340? I'm not sure that one covers the issue with namespacing header elements

@rubiii
Copy link
Contributor

rubiii commented Jan 3, 2013

@kjg you're right. #340 only addresses the problem described by @plentz.

@rubiii
Copy link
Contributor

rubiii commented Jan 26, 2013

i'm aiming to fix this in 3.x, because then we should know the proper namespaces for all elements.

@stale
Copy link

stale bot commented Feb 20, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Feb 20, 2018
@stale
Copy link

stale bot commented Feb 27, 2018

This issue is now closed due to inactivity. If you believe this needs further action, please re-open to discuss.

@stale stale bot closed this as completed Feb 27, 2018
@schuylr
Copy link

schuylr commented Oct 3, 2018

This is still a problem, and I had to use the manual namespace myself for a SOAP server to correctly authenticate my session. Could this please be reopened?

@tylerhunt
Copy link

Ran into this issue today, too. The body elements are being properly namespaced, but the header elements aren't.

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

7 participants