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

Wrong namespace if value is in WSDL #274

Closed
DriesS opened this issue Mar 7, 2012 · 5 comments
Closed

Wrong namespace if value is in WSDL #274

DriesS opened this issue Mar 7, 2012 · 5 comments
Milestone

Comments

@DriesS
Copy link

DriesS commented Mar 7, 2012

Hello,

I'm using savon 0.9.9 to get some information from a service but if I use the following code to do the call he put namespaces before the values I entered if these values are in the WSDL list. The code I'm using to do some testing :

require "savon"

class SoColissimo

  def self.call_action
    response = client.request :find_point_retrait do
      soap.body = {:password => "test", :city => "london", :test => "not a field in wsdl"}
    end
  end

  protected

    def self.client
      @@client ||= Savon::Client.new do
         wsdl.document = "http://ws.colissimo.fr/pointretrait-ws-cxf/PointRetraitServiceWS?WSDL"
         wsdl.element_form_default = :qualified
      end
    end
end

This output the following request xml :

HTTPI executes HTTP GET using the net_http adapter
SOAP request: http://ws.colissimo.fr/pointretrait-ws-cxf/PointRetraitServiceWS
Content-Length: 486, Content-Type: text/xml;charset=UTF-8, 
SOAPAction: "findPointRetrait"
<?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:wsdl="http://pointretrait.geopost.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ins0="http://pointretrait.geopost.com/" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">
  <env:Body>
    <ins0:findPointRetrait>
      <wsdl:test>not a field in wsdl</wsdl:test>
      <ins0:city>london</ins0:city>
      <ins0:password>test</ins0:password>
    </ins0:findPointRetrait>
  </env:Body>
</env:Envelope>

The fields city and password are in the WSDL and for these values he puts ins0 as namespace, how can I bypass this and remove this namespace? I tried with the wsdl.element_form_default = :qualified like in the doc but it doesn't change anything.

@jkingdon
Copy link
Contributor

jkingdon commented Mar 8, 2012

I think you want an elementFormDefault of unqualified (that's what's in the WSDL file in your example). If Savon isn't following the WSDL, that would be a bug (certainly possible), but at least as of when I was last hacking on Savon, it was designed to follow the namespaces in the WSDL, not to provide a lot of mechanisms to override the WSDL.

@bosko
Copy link

bosko commented Apr 26, 2012

It seems that Savon isn't following WSDL now. In the add_namespace_to_body method, called from body_to_xml, if namespaces exist they are used no matter what is the value of element_form_default

if used_namespaces[newpath]
  newhash.merge(
              "#{used_namespaces[newpath]}:#{camelcased_key}" =>
                add_namespaces_to_body(value, types[newpath] ? [types[newpath]] : newpath)
            )
else
  newhash.merge(key => value)
end

rubiii added a commit that referenced this issue Jun 6, 2012
@rubiii
Copy link
Contributor

rubiii commented Jun 6, 2012

@bosko could you test against v0.9.11 to see if i understood and fixed the problem?!

@rubiii rubiii closed this as completed Jun 6, 2012
@bosko
Copy link

bosko commented Jun 7, 2012

I just tested it and it is working in v0.9.11.

@rubiii
Copy link
Contributor

rubiii commented Jun 7, 2012

great :) thank you!

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

4 participants