How do I remove namespaces from envelope?

1,147 views
Skip to first unread message

John Dyer

unread,
Nov 4, 2011, 4:50:05 PM11/4/11
to sav...@googlegroups.com

Failing ( default) : 
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:xsd="http://connectsm.ws.bwse.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ins0="http://connectsm.ws.bwse.com/xsd" xmlns:ins1="http://connectsm.model.api.bwse.com/xsd" xmlns:ins2="http://model.api.ccb.primalsw.com/xsd">
  <soap:Body>
    <ins0:findCustomerEntity>
      <ins0:companyCd>290</ins0:companyCd>
      <ins0:customerCd>000808</ins0:customerCd>
    </ins0:findCustomerEntity>
  </soap:Body>
</soap:Envelope>


Working ( from SoapUI): 

<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://connectsm.ws.bwse.com/xsd">
  <soap:Body>
    <xsd:findCustomerEntity2>
      <xsd:companyCd>290</xsd:companyCd>
      <xsd:customerCd>000997</xsd:customerCd>
    </xsd:findCustomerEntity2>
  </soap:Body>
</soap:Envelope>

Notice how the envelopse are diffuerent, how can I remove xmlns:ins0,  xmlns:ins1,  xmlns:ins0, and  xmlns:ins2  ?  
 

Steffen Roller

unread,
Nov 4, 2011, 5:08:13 PM11/4/11
to sav...@googlegroups.com
Which version of Savon do you use?

John Dyer

unread,
Nov 4, 2011, 5:10:46 PM11/4/11
to sav...@googlegroups.com
I have savon (0.9.7, 0.9.2) installed

Steffen Roller

unread,
Nov 4, 2011, 5:17:21 PM11/4/11
to sav...@googlegroups.com
I think you have to do it the other way around. You need to inject those namespaces into your request. That's what I did at least.

-st

John Dyer

unread,
Nov 4, 2011, 5:20:14 PM11/4/11
to sav...@googlegroups.com
There are two SOAP requests, one w/ the extra stuff in the header and the other w/o it.  The one w/o it works:


So the way I see it we need to remove the extra items from the envelope to get this working

-John

John Dyer

unread,
Nov 6, 2011, 8:42:25 AM11/6/11
to sav...@googlegroups.com
Any thoughts on my last post?  I am not sure what you mean by "they are reversed", I was attempting to show that was not the case by my last gist (  https://gist.github.com/20238a7af1f9e5bf31aa ).  Standing by for your response.

-John

Steffen Roller

unread,
Nov 6, 2011, 2:31:23 PM11/6/11
to sav...@googlegroups.com
Hi John,

I'm only on my BB for the next days. Therefore I can only quote from
memorym When I faced the problem you're in I injected the namespaces
in question into my request doing something like this:

soap.namespaces['ns1'] = 'ns1=xmlns:namspace'

That way you create a valid request. It worked for me at least.

Regards,
Steffen

--
Sent from my mobile device

John Dyer

unread,
Nov 6, 2011, 2:34:35 PM11/6/11
to sav...@googlegroups.com
Hello Steffen,

   The envelope being generated by Savon has extra namespaces which are the problem:

This fails:
this works:

So what I need to do is get savon to NOT put the extra stuff somehow... I hope that helps you get an idea of what my problem is and what I am looking to accomplish. Again to be clear I am looking to NOT have savon include these extra elements in the envelope.

Regards,
John

Steffen Roller

unread,
Nov 6, 2011, 2:51:57 PM11/6/11
to sav...@googlegroups.com
Hi John,

There is a different way to get over this problem. You can create the
XML body manually. If my memory serves me correctly you have to set
soap.xml for this.

-st

On 06.11.2011, John Dyer <john...@gmail.com> wrote:
> Hello Steffen,
>
> The envelope being generated by Savon has extra namespaces which are the
> problem:
>
> This fails:
>
> <soap:Envelope xmlns:xsd="http://connectsm.ws.bwse.com/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:ins0="http://connectsm.ws.bwse.com/xsd"
> xmlns:ins1="http://connectsm.model.api.bwse.com/xsd"
> xmlns:ins2="http://model.api.ccb.primalsw.com/xsd">
>

> *this works:*
> *
> *

John Dyer

unread,
Nov 6, 2011, 3:13:45 PM11/6/11
to sav...@googlegroups.com
If I used soap.xml would I have to build the entire soap body?  There is any way to only modify the envelope? 

-John

Steffen Roller

unread,
Nov 6, 2011, 3:29:02 PM11/6/11
to sav...@googlegroups.com
You have to build the entire payload if you go that way.

-st

On 06.11.2011, John Dyer <john...@gmail.com> wrote:

--

John Dyer

unread,
Nov 6, 2011, 5:44:23 PM11/6/11
to sav...@googlegroups.com
Where are these values coming from?  I dont understand why I am having to rewrite the payload to remove some extraneous values?  This seems a bit drastic, a bit like cutting off the nose to spite the face.  There has got to be a way to do this better? 

John Dyer

unread,
Nov 6, 2011, 5:47:11 PM11/6/11
to sav...@googlegroups.com
I mean where is this crap even coming from?  
Why is it so much trouble to remove it? 

John Dyer

unread,
Nov 6, 2011, 7:26:29 PM11/6/11
to sav...@googlegroups.com
Since 'namespaces' appeared to be a hash I took a guess and tried clearing it by reinitializing it

 soap.namespaces=Hash.new
      soap.namespaces["xmlns:soap"] = "http://www.w3.org/2003/05/soap-envelope"
      soap.namespaces["xmlns:ins0"]  = @soap_namespace                              

That worked for me... 

Your help was very valuable, I dont think I would have been capable of solving this one w/o your assistance.

-John

Steffen Roller

unread,
Nov 6, 2011, 8:33:43 PM11/6/11
to sav...@googlegroups.com
No problem. You're very welcome. I was often a beneficiary of help
from the net over the last 20 some years. I'm happy that I'm able to
give some of it back.
Reply all
Reply to author
Forward
0 new messages