node-soap更改操作命名空间

时间:2016-12-12 13:32:47

标签: node.js soap node-soap

以下代码中的

client.lastRequest 是:

    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);
    });

以下是源代码:

<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>

我想要的请求应该是:

@region

我该怎么做?

1 个答案:

答案 0 :(得分:2)

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

更改args可能会有相同的结果