节点soap更改标头前缀

时间:2018-02-19 14:07:54

标签: node.js soap

我试图将标题前缀从< soap:Header>更改为< soapenv:Header>

这是我的代码:

var args = { 

    "soapenv:Header": { }

};

soap.createClient(url, {"disableCache":true}, function(err, client) {


        client.addSoapHeader(args);


        client.myMethod( {}, function(err, result) {

            console.log("last: " + client.lastRequest); // <-- here
        });

 });  

它生成以下xml,但它插入&lt; soapenv:Header&gt;位于&lt; soap:Header&gt;内。

<​?xml version="1.​​0" encoding="utf-​​8"?>​​
    <​soap:​Envelope xmlns:​soap="http:​/​​/​​schemas.​​xmlsoap.​​org/​​soap/​​envelope/​​" xmlns:​xsi="http:​/​​/​​www.​​w3.​​org/​​2001/​​XMLSchema-​​instance" >​​
    <​soap:​Header>​​
     <​soapenv:​Header>​​
     <​/​​soapenv:​Header>​​
    <​/​​soap:​Header>
    ​​<​soap:​Body>
    <​/​​soap:​Body>
    ​​<​/​​soap:​Envelope>​​

是否可以更改&lt; soap:Header&gt;?

的前缀

1 个答案:

答案 0 :(得分:0)

我设法弄清楚了,你可以通过&#39; soapenv&#39;在信封密钥中,这将更改标头前缀:

const wsdlOptions = {
    "envelopeKey": 'soapenv',
    "disableCache":true
};

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

}

哪个产生

<​soapenv:​Header>​​
<​/​​soapenv:​Header>​​