diff --git a/lib/client.js b/lib/client.js index 1dcd2b94c..6393dfc91 100644 --- a/lib/client.js +++ b/lib/client.js @@ -30,6 +30,14 @@ Client.prototype.addSoapHeader = function(soapHeader, name, namespace, xmlns) { this.soapHeaders.push(soapHeader); }; +Client.prototype.getSoapHeaders = function() { + return this.soapHeaders; +}; + +Client.prototype.clearSoapHeaders = function() { + this.soapHeaders = null; +}; + Client.prototype.setEndpoint = function(endpoint) { this.endpoint = endpoint; this._initializeServices(endpoint); diff --git a/test/client-test.js b/test/client-test.js index 936587313..1cab7cca3 100644 --- a/test/client-test.js +++ b/test/client-test.js @@ -11,4 +11,22 @@ describe('SOAP Client', function() { done(); }); }); + + it('should add and clear soap headers', function(done) { + soap.createClient(__dirname+'/wsdl/default_namespace.wsdl', function(err, client) { + assert.ok(client); + assert.ok(!client.getSoapHeaders()); + + client.addSoapHeader('header1'); + client.addSoapHeader('header2'); + + assert.ok(client.getSoapHeaders().length === 2); + assert.ok(client.getSoapHeaders()[0] === 'header1'); + assert.ok(client.getSoapHeaders()[1] === 'header2'); + + client.clearSoapHeaders(); + assert.ok(!client.getSoapHeaders()); + done(); + }); + }); });