dongx
dongx

Reputation: 1800

node-soap change namespace of operation

client.lastRequest from the following code is:

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

Here is the source code:

    var soap = require('soap');
    var url = 'http://www.example.com?sap-client=080';
    var args = { INPUT: '0001386669' };
    var auth = "Basic " + new Buffer("username" + ":" + "password").toString("base64");

    soap.createClient(url, { wsdl_headers: { Authorization: auth } }, function (err, client) {
        client.setSecurity(new soap.BasicAuthSecurity('admin', 'password'));
        client.getImagesDefinition(args, function(err, result){
            //console.log(err);
            //console.log(result);
        });
        console.log(client.lastRequest);
    });

The request that I want should be:

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

How can I do that?

Upvotes: 2

Views: 2805

Answers (1)

Zetian
Zetian

Reputation: 503

var args = {
    attributes:{
        'xmlns':"urn:services.example.com"
    },
    'INPUT': '0001386669'
};

Change the args may have the same result

Upvotes: 3

Related Questions