0

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

1 Answer 1

4

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>​​
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.