fhollste
fhollste

Reputation: 795

Node.js soap request remove namespace from argument

I am unable to send the correct argument to the service.

Code used:

var soap = require('soap');
var url = 'http://example.com';

soap.WSDL.prototype.ignoredNamespaces = ['targetNamespace', 'typedNamespace'];

var args = {'name':'test'};

soap.createClient(url, function(err, client) {
    client.Hello(args, function(err,result,res){
        console.log(result);
        console.log(client.lastRequest);
    });
});

The Hello-function should return string "Hello test !". However, I get:

'Hello null !'

The request being sent is:

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

where test is the interesting part. The service is expecting

<name>test</name>

without namespace (i tested this with http://www.soapclient.com/)

So, the question is: how do I send the request argument without tns attached? (tns:name => name) Thanks!

Upvotes: 0

Views: 3721

Answers (2)

Oscar Rico
Oscar Rico

Reputation: 389

The correct way to override namespace is to send the parameters like this:

var params = { ':name' : 'test' }

It's in documentation: Overriding the namespace prefix

Upvotes: 3

user3350549
user3350549

Reputation: 1

In your code instead of passing argument as

var args = {'name':'test'};

try

var args = {arg0: 'testName'};

I am not an expert but it worked for me to pass an argument from node.js while invoking SOAP client.

Upvotes: 0

Related Questions