11

I'm trying to consume a SOAP Webservice, but the WSDL is kind of broken, so I have to do some customization to node-soap.

The ideal SOAP Envelope that I would like to have would be this one:

<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/">
    <Body>
        <getImagesDefinition xmlns="http://services.example.com/"/>
    </Body>
</Envelope>

So far this is the nodejs code I have to invoke the service:

var soap = require('soap');
var url = 'http://www.example.com/services/imagesizes?wsdl';

soap.createClient(url, function(err, client) {

    client.setEndpoint('http://www.example.com/services/imagesizes');
    client.getImagesDefinition(null, function(err, result) {
        console.log(result);
    });
    console.log(client.lastRequest)

}); 

I had to set the endpoint manually because it is broken in the WSDL file

The envelope I get when printing client.lastRequest is this:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 
               xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
               xmlns:tns="http://services.example.com/">
    <soap:Body>
        <getImagesDefinition />
    </soap:Body>
</soap:Envelope>

I know that if I can force the namespace prefix on the body to have <tns:getImagesDefinition /> instead of <getImagesDefinition /> the request works perfectly.

Is there any way for me to force it?

I read the documentation saying that tns is a default ignored namespace, so I tried to change that by doing this:

var options = {
    ignoredNamespaces: {
        namespaces: [],
        override: true
    }
}

and sending that object to the soap.createClient method, but I see no difference on the Envelope.

Is there anyway for me to force this? or get to the ideal SOAP Envelope?

Thanks!

2 Answers 2

6

I ran into this exact problem and for me, the fix was to override the ignoredNamespaces - to remove 'tns' as an ignored namespace.

var options = { 
  ignoredNamespaces: {
    namespaces: ['targetNamespace', 'typedNamespace'],
    override: true
  }
}

I'm not sure why it didn't work for you, but maybe there was a bug in the library that has since been fixed. Or maybe because you didn't include any namespaces, but rather an empty array.

Sign up to request clarification or add additional context in comments.

Comments

2

See this thread discussing the same issue at github:

And especially https://github.com/vpulim/node-soap/issues/537#issuecomment-72041420

3 Comments

Temporary fix: Change line 1047 in wsdl.js to: WSDL.prototype.ignoredNamespaces = ['targetNamespace', 'typedNamespace'];
That link is broken. Can you please elaborate?
This is why answers that only contain links are not helpful

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.