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 set multiple namespaces #376

Closed
jmarquesCC opened this issue Jan 24, 2013 · 7 comments
Closed

Savon set multiple namespaces #376

jmarquesCC opened this issue Jan 24, 2013 · 7 comments

Comments

@jmarquesCC
Copy link

Hi all,

I'm trying to invoke a webservice (with Savon version 2) and i need to inject some additional namespaces to my Envelope.

Something like:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:add="http://schemas.xmlsoap.org/ws/2003/03/addressing" 
xmlns:newNamespace1="http://someURL.pt/Test1" 
xmlns:newNamespace2="http://someURL.pt/Test2" 
xmlns:newNamespace3="http://someURL.pt/Test3"

My current code is:

client = Savon.client do
    wsdl "https://someValidURL?wsdl"

    namespace "http://someURL.pt/Test1" 
    namespace "http://someURL.pt/Test2" 
    namespace "http://someURL.pt/Test3"
end

response = client.call( ...the webservice call... )

...but in my request the Savon only puts the last namespace

<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xmlns:xsns="http://someURL.pt/Test3" 
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/">

I didn't find any documentation about this :S.

Does anyone have a solution/workaround for this problem??

PS - I notice that the version 1 have this feature (i didn't try yet):

 soap.namespaces["xmlns:g2"] = "http://g2.example.com"

Should i migrate to version 1?

@rubiii
Copy link
Contributor

rubiii commented Jan 25, 2013

unfortunately, there seems to be no option for setting namespaces in 2.x. i consider this to be a regression
and since the new wsdl parser will probably not be introduced in 2.x, this needs to be fixed.

@jmarquesCC would you be able to "donate" your wsdl for me to test is with the new parser?
the goal for it is to "just work" and this needs quite a lot of testing.

rubiii added a commit that referenced this issue Jan 25, 2013
@jmarquesCC
Copy link
Author

@rubiii I send you an email.

For now i migrate my application on Savon version 1 and it worked =)

If there's someone interested this is the code:

begin
    client = Savon::Client.new do
         wsdl.document = "https://someURL?wsdl"
    end

  @response = client.request :service do

    soap.namespaces["xmlns:test1"]  = "http:/someURLtest1"
    soap.namespaces["xmlns:test2"]  = "http:/someURLtest2" 

    soap.body = { #... the message....

    :"test1:something" => {}, 
    :"test2:something1" => {
       }
     }
   end


rescue Savon::Error => error
    #log error.to_s
   puts error.to_s
end

@rubiii
Copy link
Contributor

rubiii commented Jan 25, 2013

thank you very much :) if you like, you could point your gemfile to github master and test the new global namespaces option added i just added.

client = Savon.client do
  namespaces "xmlns:first" => "http://someURL.pt/Test1"
end

@jmarquesCC
Copy link
Author

@rubiii I've tested but I don't think that's working

I tested with this code:

      namespaces "xmlns:first" => "http://someURL.pt/Test1"
      namespaces "xmlns:two" => "http://someURL.pt/Testweewqwqeewq"

The first namespace is ignored.

@rubiii
Copy link
Contributor

rubiii commented Jan 25, 2013

like all options, this one is expected to be called only once and it accepts a hash:

namespaces(
  "xmlns:first" => "http://someURL.pt/Test1",
  "xmlns:two"   => "http://someURL.pt/Testweewqwqeewq"
)

@jmarquesCC
Copy link
Author

My bad, sorry.

It's working =)

Thanks.

@rubiii
Copy link
Contributor

rubiii commented Jan 25, 2013

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

2 participants