2

以下代码中的client.lastRequest是:

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

这是源代码:

    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>

我怎样才能做到这一点?

4

1 回答 1

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

更改 args 可能有相同的结果

于 2016-12-15T04:50:53.380 回答