Scott
Scott

Reputation: 1310

Node soap change header prefix

I'm trying to change the header prefix from <​soap:​Header>​​ to <​soapenv:​Header>​​

Here's my code:

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

 });  

It produces the following xml but it inserts <​soapenv:​Header>​​ is inside <​soap:​Header>​​.

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

Is it possible to change the prefix of <​soap:​Header>​​?

Upvotes: 0

Views: 1424

Answers (1)

Scott
Scott

Reputation: 1310

I managed to figure it out, you can pass 'soapenv' in the envelope key, this will change the header prefix:

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

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

}

Which produces

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

Upvotes: 4

Related Questions