diff --git a/src/client.ts b/src/client.ts index 8f773feb2..ac123d910 100644 --- a/src/client.ts +++ b/src/client.ts @@ -409,7 +409,7 @@ export class Client extends EventEmitter { this.wsdl.xmlnsInEnvelope + '>' + ((decodedHeaders || this.security) ? ( - '<' + envelopeKey + ':Header>' + + '<' + envelopeKey + ':Header' + (this.wsdl.xmlnsInHeader ? (' ' + this.wsdl.xmlnsInHeader) : '') + '>' + (decodedHeaders ? decodedHeaders : '') + (this.security && !this.security.postProcess ? this.security.toXML() : '') + '' diff --git a/src/wsdl/index.ts b/src/wsdl/index.ts index a05d8139c..d5c39bb40 100644 --- a/src/wsdl/index.ts +++ b/src/wsdl/index.ts @@ -70,6 +70,7 @@ export class WSDL { public valueKey = '$value'; public xmlKey = '$xml'; public xmlnsInEnvelope: string; + public xmlnsInHeader: string; public uri: string; public definitions: elements.DefinitionsElement; public options: IInitializedOptions; diff --git a/test/client-test.js b/test/client-test.js index c08d57ad4..e220eca17 100644 --- a/test/client-test.js +++ b/test/client-test.js @@ -1537,6 +1537,20 @@ var fs = require('fs'), }); }); +it('shall generate correct header for custom defined header arguments', function(done) { + soap.createClientAsync(__dirname + '/wsdl/default_namespace.wsdl').then(function (client) { + client.addSoapHeader('test-header-namespace') + client.wsdl.xmlnsInHeader = 'xmlns="https://example.com/v1"'; + var expectedDefinedHeader = ''; + + client.MyOperation(function(err, result, rawResponse, soapHeader, rawRequest) { + var definedSoapHeader = client.lastRequest.match(/)/)[0]; + assert.ok(definedSoapHeader === expectedDefinedHeader); + done(); + }); + }); +}); + it('should create async client without options', function (done) { soap.createClientAsync(__dirname + '/wsdl/default_namespace.wsdl').then(function (client) { assert.ok(client);