Skip to content

Commit

Permalink
Merge pull request #282 from ankush-garg/errJsAttach
Browse files Browse the repository at this point in the history
Adding ability to inspect and clear soap headers
  • Loading branch information
jsdevel committed Mar 7, 2014
2 parents a2f00a1 + 3683084 commit 8e81ccb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions test/client-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});

0 comments on commit 8e81ccb

Please sign in to comment.