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 Confusion #384

Closed
ryanaghdam opened this issue Feb 1, 2013 · 18 comments
Closed

Namespace Confusion #384

ryanaghdam opened this issue Feb 1, 2013 · 18 comments

Comments

@ryanaghdam
Copy link

I'm having trouble making SOAP requests with Savon, whereas I'm able to make them using SoapUI. I'm convinced it has something to so with namespaces.

We are using the e-dialog WSDL, located here: https://sdk-staging.e-dialog.com/edialog-webservices/SdkService.wsdl. For your convenience, here is the beginning of the WSDL file:

<wsdl:definitions
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:sch0="uri:common.ws.sdk.edialog.com"
xmlns:sch1="uri:audience.ws.sdk.edialog.com"
xmlns:sch10="uri:ereport.ws.sdk.edialog.com"
xmlns:sch11="uri:exporter.ws.sdk.edialog.com"
xmlns:sch12="uri:grid.ws.sdk.edialog.com"
xmlns:sch13="uri:insightbuilder.ws.sdk.edialog.com"
xmlns:sch14="uri:urlmanagement.ws.sdk.edialog.com"
xmlns:sch15="uri:mailingcontrol.ws.sdk.edialog.com"
xmlns:sch16="uri:mailing.ws.sdk.edialog.com"
xmlns:sch17="uri:realtimemessaging.ws.sdk.edialog.com"
xmlns:sch18="uri:realtimemessagingconfiguration.ws.sdk.edialog.com"
xmlns:sch19="uri:udf.ws.sdk.edialog.com"
xmlns:sch2="uri:audiencetransfer.ws.sdk.edialog.com"
xmlns:sch20="uri:user.ws.sdk.edialog.com"
xmlns:sch3="uri:campaign.ws.sdk.edialog.com"
xmlns:sch4="uri:cell.ws.sdk.edialog.com"
xmlns:sch5="uri:content.ws.sdk.edialog.com"
xmlns:sch6="uri:cp.ws.sdk.edialog.com"
xmlns:sch7="uri:customerStatus.ws.sdk.edialog.com"
xmlns:sch8="uri:dataupload.ws.sdk.edialog.com"
xmlns:sch9="uri:deliverability.ws.sdk.edialog.com"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="uri:ws.sdk.edialog.com"
targetNamespace="uri:ws.sdk.edialog.com">

Here is the message that Savon sends:

<?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:sch8="uri:ws.sdk.edialog.com" 
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" 
xmlns:ins0="uri:audience.ws.sdk.edialog.com" 
xmlns:ins1="uri:audiencetransfer.ws.sdk.edialog.com" 
xmlns:ins2="uri:campaign.ws.sdk.edialog.com" 
xmlns:ins3="uri:cell.ws.sdk.edialog.com" 
xmlns:ins4="uri:content.ws.sdk.edialog.com"
xmlns:ins5="uri:cp.ws.sdk.edialog.com" 
xmlns:ins6="uri:customerStatus.ws.sdk.edialog.com" 
xmlns:ins7="uri:dataupload.ws.sdk.edialog.com" 
xmlns:ins8="uri:common.ws.sdk.edialog.com"
xmlns:ins9="uri:ereport.ws.sdk.edialog.com" 
xmlns:ins10="uri:exporter.ws.sdk.edialog.com"
xmlns:ins11="uri:grid.ws.sdk.edialog.com" 
xmlns:ins12="uri:insightbuilder.ws.sdk.edialog.com" 
xmlns:ins13="uri:urlmanagement.ws.sdk.edialog.com" 
xmlns:ins14="uri:mailingcontrol.ws.sdk.edialog.com" 
xmlns:ins15="uri:mailing.ws.sdk.edialog.com" 
xmlns:ins16="uri:realtimemessaging.ws.sdk.edialog.com" xmlns:ins17="uri:realtimemessagingconfiguration.ws.sdk.edialog.com" 
xmlns:ins18="uri:udf.ws.sdk.edialog.com"
xmlns:ins19="uri:user.ws.sdk.edialog.com">
  <env:Body>
    <sch8:listAllDataColumns/>
  </env:Body>
</env:Envelope>

And here is the response we're getting back:

<?xml version="1.0"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header/>
  <SOAP-ENV:Body>
    <SOAP-ENV:Fault>
      <faultcode>SOAP-ENV:Server</faultcode>
      <faultstring xml:lang="en">JAXB unmarshalling exception: null; nested exception is javax.xml.bind.UnmarshalException
 - with linked exception:
[org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'ns53154:listAllDataColumnsRequest'.]</faultstring>
    </SOAP-ENV:Fault>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

I am guessing -- and I'm no expert on SOAP -- that the differences in the namespaces is confusing the server.

@rubiii
Copy link
Contributor

rubiii commented Feb 1, 2013

can you provide code to reproduce the problem?

@ryanaghdam
Copy link
Author

I have it in a Gist here: https://gist.github.com/4692074. The config.yml file it uses has the authentication information and the path to the WSDL file. If you need it, I can try to get you a temporary login. Thank you.

@ryanaghdam
Copy link
Author

I've been using soapUI to test the SOAP service and noticed that when trying to make the same call, soapUI sends the following message

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns:uri="uri:dataupload.ws.sdk.edialog.com">
   <soapenv:Header/>
   <soapenv:Body>
      <uri:listAllDataColumns/>
   </soapenv:Body>
</soapenv:Envelope>

Is it possible that Savon should also be sending only the necessary namespaces? Is there a way to have Savon send only the necessary namespaces?

@ryanaghdam
Copy link
Author

Could this be related to #305?

I used namespace_identifier to set the namespace to the prefix that I knew was correct, from the soapUI call. If I modify my client to have namespace_identifier :ins7, then the following is the message I send:

<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
                  xmlns:ins7="uri:dataupload.ws.sdk.edialog.com" 
                  xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" 
                  xmlns:ins0="uri:audience.ws.sdk.edialog.com" 
                  xmlns:ins1="uri:audiencetransfer.ws.sdk.edialog.com"
                  xmlns:ins2="uri:campaign.ws.sdk.edialog.com"
                  xmlns:ins3="uri:cell.ws.sdk.edialog.com"
                  xmlns:ins4="uri:content.ws.sdk.edialog.com"
                  xmlns:ins5="uri:cp.ws.sdk.edialog.com"
                  xmlns:ins6="uri:customerStatus.ws.sdk.edialog.com"
                  xmlns:ins8="uri:common.ws.sdk.edialog.com"
                  xmlns:ins9="uri:ereport.ws.sdk.edialog.com"
                  xmlns:ins10="uri:exporter.ws.sdk.edialog.com"
                  xmlns:ins11="uri:grid.ws.sdk.edialog.com"
                  xmlns:ins12="uri:insightbuilder.ws.sdk.edialog.com" 
                  xmlns:ins13="uri:urlmanagement.ws.sdk.edialog.com"                             
                  xmlns:ins14="uri:mailingcontrol.ws.sdk.edialog.com"
                  xmlns:ins15="uri:mailing.ws.sdk.edialog.com"
                  xmlns:ins16="uri:realtimemessaging.ws.sdk.edialog.com" 
                  xmlns:ins17="uri:realtimemessagingconfiguration.ws.sdk.edialog.com"
                  xmlns:ins18="uri:udf.ws.sdk.edialog.com"
                  xmlns:ins19="uri:user.ws.sdk.edialog.com">
  <soapenv:Body>
    <ins7:listAllDataColumns/>
  </soapenv:Body>
</soapenv:Envelope>

... and my response is as follows:

<?xml version="1.0" encoding="utf-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
  <SOAP-ENV:Header/>
  <SOAP-ENV:Body>
    <ns19:listAllDataColumnsResponse xmlns:ns10="uri:mailingcontrol.ws.sdk.edialog.com"
                                     xmlns:ns11="uri:multichannel.ws.sdk.edialog.com"
                                     xmlns:ns12="uri:insightbuilder.ws.sdk.edialog.com"
                                     xmlns:ns13="uri:grid.ws.sdk.edialog.com"
                                     xmlns:ns14="uri:realtimemessaging.ws.sdk.edialog.com"
                                     xmlns:ns15="uri:audience.ws.sdk.edialog.com"
                                     xmlns:ns16="uri:audiencetransfer.ws.sdk.edialog.com"
                                     xmlns:ns17="uri:urlmanagement.ws.sdk.edialog.com"
                                     xmlns:ns18="uri:udf.ws.sdk.edialog.com"
                                     xmlns:ns19="uri:dataupload.ws.sdk.edialog.com"
                                     xmlns:ns2="uri:echo.ws.example.edialog.com"
                                     xmlns:ns20="uri:exporter.ws.sdk.edialog.com"
                                     xmlns:ns21="uri:customerStatus.ws.sdk.edialog.com"
                                     xmlns:ns22="uri:seq.ws.sdk.edialog.com"
                                     xmlns:ns23="uri:seq-bpe-callback.ws.sdk.edialog.com" 
                                     xmlns:ns24="uri:realtimemessagingconfiguration.ws.sdk.edialog.com"
                                     xmlns:ns25="uri:ereport.ws.sdk.edialog.com"
                                     xmlns:ns26="uri:user.ws.sdk.edialog.com"
                                     xmlns:ns27="uri:cp.ws.sdk.edialog.com"
                                     xmlns:ns3="uri:content.ws.sdk.edialog.com"
                                     xmlns:ns4="uri:etc.ws.sdk.edialog.com"
                                     xmlns:ns5="uri:mailing.ws.sdk.edialog.com"
                                     xmlns:ns6="uri:common.ws.sdk.edialog.com"
                                     xmlns:ns7="uri:deliverability.ws.sdk.edialog.com"
                                     xmlns:ns8="uri:campaign.ws.sdk.edialog.com"
                                     xmlns:ns9="uri:cell.ws.sdk.edialog.com">
      <ns19:column>
        <ns19:dictionaryId>184763628</ns19:dictionaryId>
        <ns19:tableName>T_MASTER</ns19:tableName>
        <ns19:columnName>EMAIL</ns19:columnName>
        <ns19:columnType>VARCHAR2</ns19:columnType>
        <ns19:maxLength>128</ns19:maxLength>
      </ns19:column>
      <ns19:column>
        <ns19:dictionaryId>184763622</ns19:dictionaryId>
        <ns19:tableName>T_MASTER</ns19:tableName>
        <ns19:columnName>FIRSTNAME</ns19:columnName>
        <ns19:columnType>VARCHAR2</ns19:columnType>
        <ns19:maxLength>50</ns19:maxLength>
      </ns19:column>
      <ns19:column>
        <ns19:dictionaryId>184763626</ns19:dictionaryId>
        <ns19:tableName>T_MASTER</ns19:tableName>
        <ns19:columnName>FULLNAME</ns19:columnName>
        <ns19:columnType>VARCHAR2</ns19:columnType>
        <ns19:maxLength>100</ns19:maxLength>
      </ns19:column>
      <ns19:column>
        <ns19:dictionaryId>184763624</ns19:dictionaryId>
        <ns19:tableName>T_MASTER</ns19:tableName>
        <ns19:columnName>LASTNAME</ns19:columnName>
        <ns19:columnType>VARCHAR2</ns19:columnType>
        <ns19:maxLength>50</ns19:maxLength>
      </ns19:column>
      <ns19:column>
        <ns19:dictionaryId>495847732</ns19:dictionaryId>
        <ns19:tableName>T_MEMBER</ns19:tableName>
        <ns19:columnName>EVENTINFO</ns19:columnName>
        <ns19:columnType>CLOB</ns19:columnType>
      </ns19:column>
    </ns19:listAllDataColumnsResponse>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Which is the response I am expecting. However, fixing the prefixes for each call is not a viable solution.

@rubiii
Copy link
Contributor

rubiii commented Feb 5, 2013

i'll try to take a look at this later today.

@ryanaghdam
Copy link
Author

To follow up with more information, if I try to retrieve the body of the response returned in my previous comment, I get an InvalidResponseError. I would guess that this would indicate the service I am trying to use is not responding correctly. Do you agree?

Thanks again for agreeing to help us out. I really appreciate it.

response.body
Savon::InvalidResponseError: Unable to parse response body:
"<?xml version=\"1.0\" encoding=\"utf-8\" ?><SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\"><SOAP-ENV:Header/><SOAP-ENV:Body><ns19:listAllDataColumnsResponse xmlns:ns10=\"uri:mailingcontrol.ws.sdk.edialog.com\" xmlns:ns11=\"uri:multichannel.ws.sdk.edialog.com\" xmlns:ns12=\"uri:insightbuilder.ws.sdk.edialog.com\" xmlns:ns13=\"uri:grid.ws.sdk.edialog.com\" xmlns:ns14=\"uri:realtimemessaging.ws.sdk.edialog.com\" xmlns:ns15=\"uri:audience.ws.sdk.edialog.com\" xmlns:ns16=\"uri:audiencetransfer.ws.sdk.edialog.com\" xmlns:ns17=\"uri:urlmanagement.ws.sdk.edialog.com\" xmlns:ns18=\"uri:udf.ws.sdk.edialog.com\" xmlns:ns19=\"uri:dataupload.ws.sdk.edialog.com\" xmlns:ns2=\"uri:echo.ws.example.edialog.com\" xmlns:ns20=\"uri:exporter.ws.sdk.edialog.com\" xmlns:ns21=\"uri:customerStatus.ws.sdk.edialog.com\" xmlns:ns22=\"uri:seq.ws.sdk.edialog.com\" xmlns:ns23=\"uri:seq-bpe-callback.ws.sdk.edialog.com\" xmlns:ns24=\"uri:realtimemessagingconfiguration.ws.sdk.edialog.com\" xmlns:ns25=\"uri:ereport.ws.sdk.edialog.com\" xmlns:ns26=\"uri:user.ws.sdk.edialog.com\" xmlns:ns27=\"uri:cp.ws.sdk.edialog.com\" xmlns:ns3=\"uri:content.ws.sdk.edialog.com\" xmlns:ns4=\"uri:etc.ws.sdk.edialog.com\" xmlns:ns5=\"uri:mailing.ws.sdk.edialog.com\" xmlns:ns6=\"uri:common.ws.sdk.edialog.com\" xmlns:ns7=\"uri:deliverability.ws.sdk.edialog.com\" xmlns:ns8=\"uri:campaign.ws.sdk.edialog.com\" xmlns:ns9=\"uri:cell.ws.sdk.edialog.com\"><ns19:column><ns19:dictionaryId>184763628</ns19:dictionaryId><ns19:tableName>T_MASTER</ns19:tableName><ns19:columnName>EMAIL</ns19:columnName><ns19:columnType>VARCHAR2</ns19:columnType><ns19:maxLength>128</ns19:maxLength></ns19:column><ns19:column><ns19:dictionaryId>184763622</ns19:dictionaryId><ns19:tableName>T_MASTER</ns19:tableName><ns19:columnName>FIRSTNAME</ns19:columnName><ns19:columnType>VARCHAR2</ns19:columnType><ns19:maxLength>50</ns19:maxLength></ns19:column><ns19:column><ns19:dictionaryId>184763626</ns19:dictionaryId><ns19:tableName>T_MASTER</ns19:tableName><ns19:columnName>FULLNAME</ns19:columnName><ns19:columnType>VARCHAR2</ns19:columnType><ns19:maxLength>100</ns19:maxLength></ns19:column><ns19:column><ns19:dictionaryId>184763624</ns19:dictionaryId><ns19:tableName>T_MASTER</ns19:tableName><ns19:columnName>LASTNAME</ns19:columnName><ns19:columnType>VARCHAR2</ns19:columnType><ns19:maxLength>50</ns19:maxLength></ns19:column><ns19:column><ns19:dictionaryId>495847732</ns19:dictionaryId><ns19:tableName>T_MEMBER</ns19:tableName><ns19:columnName>EVENTINFO</ns19:columnName><ns19:columnType>CLOB</ns19:columnType></ns19:column></ns19:listAllDataColumnsResponse></SOAP-ENV:Body></SOAP-ENV:Envelope>"
from /Users/raghdam/.rvm/gems/ruby-1.9.3-p327/gems/savon-2.1.0/lib/savon/response.rb:75:in `raise_invalid_response_error!'

@rubiii
Copy link
Contributor

rubiii commented Feb 5, 2013

i'm glad you found the namespace_identifier workaround. i will have to look into some code to see why savon doesn't choose the right namespace.

the InvalidResponseError is only raised when you access the response#header or response#body convenience methods. could you try response#hash?

@ryanaghdam
Copy link
Author

response#hash does not raise an error, but both response#header and response#body do.

@rubiii
Copy link
Contributor

rubiii commented Feb 5, 2013

did you change the hash format? savon expects the hash to have snake_case symbols as keys.
specifically, it looks for hash[:envelope][:body] as you can see in the response#body method.

@ryanaghdam
Copy link
Author

No, the hash format wasn't changed.

@rubiii
Copy link
Contributor

rubiii commented Feb 5, 2013

well, how does it look like? if you need help, i need something to work with.

@ryanaghdam
Copy link
Author

The hash is below. I hope it's what you needed.

response.hash
=> {:"soap_env:envelope"=>
  {:"soap_env:header"=>nil,
   :"soap_env:body"=>
    {:"ns19:list_all_data_columns_response"=>
      {:"ns19:column"=>
        [{:"ns19:dictionary_id"=>"184763628",
          :"ns19:table_name"=>"T_MASTER",
          :"ns19:column_name"=>"EMAIL",
          :"ns19:column_type"=>"VARCHAR2",
          :"ns19:max_length"=>"128"},
         {:"ns19:dictionary_id"=>"184763622",
          :"ns19:table_name"=>"T_MASTER",
          :"ns19:column_name"=>"FIRSTNAME",
          :"ns19:column_type"=>"VARCHAR2",
          :"ns19:max_length"=>"50"},
         {:"ns19:dictionary_id"=>"184763626",
          :"ns19:table_name"=>"T_MASTER",
          :"ns19:column_name"=>"FULLNAME",
          :"ns19:column_type"=>"VARCHAR2",
          :"ns19:max_length"=>"100"},
         {:"ns19:dictionary_id"=>"184763624",
          :"ns19:table_name"=>"T_MASTER",
          :"ns19:column_name"=>"LASTNAME",
          :"ns19:column_type"=>"VARCHAR2",
          :"ns19:max_length"=>"50"},
         {:"ns19:dictionary_id"=>"495847732",
          :"ns19:table_name"=>"T_MEMBER",
          :"ns19:column_name"=>"EVENTINFO",
          :"ns19:column_type"=>"CLOB"}],
       :"@xmlns:ns10"=>"uri:mailingcontrol.ws.sdk.edialog.com",
       :"@xmlns:ns11"=>"uri:multichannel.ws.sdk.edialog.com",
       :"@xmlns:ns12"=>"uri:insightbuilder.ws.sdk.edialog.com",
       :"@xmlns:ns13"=>"uri:grid.ws.sdk.edialog.com",
       :"@xmlns:ns14"=>"uri:realtimemessaging.ws.sdk.edialog.com",
       :"@xmlns:ns15"=>"uri:audience.ws.sdk.edialog.com",
       :"@xmlns:ns16"=>"uri:audiencetransfer.ws.sdk.edialog.com",
       :"@xmlns:ns17"=>"uri:urlmanagement.ws.sdk.edialog.com",
       :"@xmlns:ns18"=>"uri:udf.ws.sdk.edialog.com",
       :"@xmlns:ns19"=>"uri:dataupload.ws.sdk.edialog.com",
       :"@xmlns:ns2"=>"uri:echo.ws.example.edialog.com",
       :"@xmlns:ns20"=>"uri:exporter.ws.sdk.edialog.com",
       :"@xmlns:ns21"=>"uri:customerStatus.ws.sdk.edialog.com",
       :"@xmlns:ns22"=>"uri:seq.ws.sdk.edialog.com",
       :"@xmlns:ns23"=>"uri:seq-bpe-callback.ws.sdk.edialog.com",
       :"@xmlns:ns24"=>"uri:realtimemessagingconfiguration.ws.sdk.edialog.com",
       :"@xmlns:ns25"=>"uri:ereport.ws.sdk.edialog.com",
       :"@xmlns:ns26"=>"uri:user.ws.sdk.edialog.com",
       :"@xmlns:ns27"=>"uri:cp.ws.sdk.edialog.com",
       :"@xmlns:ns3"=>"uri:content.ws.sdk.edialog.com",
       :"@xmlns:ns4"=>"uri:etc.ws.sdk.edialog.com",
       :"@xmlns:ns5"=>"uri:mailing.ws.sdk.edialog.com",
       :"@xmlns:ns6"=>"uri:common.ws.sdk.edialog.com",
       :"@xmlns:ns7"=>"uri:deliverability.ws.sdk.edialog.com",
       :"@xmlns:ns8"=>"uri:campaign.ws.sdk.edialog.com",
       :"@xmlns:ns9"=>"uri:cell.ws.sdk.edialog.com"}},
   :"@xmlns:soap_env"=>"http://schemas.xmlsoap.org/soap/envelope/"}}

@rubiii
Copy link
Contributor

rubiii commented Feb 5, 2013

as suspected, your hash doesn't look like savon expects it to look like. if you look at your first hash
key :"soap_env:envelope", that doesn't match :envelope.

savon (by default) strips the namespace identifiers from the hash keys, so i guess you disabled the
strip_namespaces option. if you choose to not strip the namespace identifiers, you need to use
response#hash instead of response#body.

@ryanaghdam
Copy link
Author

It turns out strip_namespaces was disabled, as you suspected. My workaround is functional, but I'd prefer to not need to do it. Would you be open to me submitting a pull request?

@rubiii
Copy link
Contributor

rubiii commented Feb 5, 2013

a pull request for not disabling strip_namespaces or for the namespace_identifier problem?
i would certainly accept a pull request for the second one.

@ryanaghdam
Copy link
Author

I'm working on the namespace_identifier problem... I'll submit a PR when it's finished. Thanks again for your help.

@rubiii
Copy link
Contributor

rubiii commented Feb 6, 2013

you're welcome.

@rubiii rubiii closed this as completed Feb 6, 2013
@jshorty
Copy link

jshorty commented Sep 11, 2015

Was an explanation for the namespace_identifier issue ever found? I'm now encountering the same issue with the same WSDL, and using SoapUI to figure out the necessary prefix for namespace_identifier for a given SOAP request.

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

3 participants