Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,22 @@ Client.prototype.clearSoapHeaders = function() {
this.soapHeaders = null;
};

Client.prototype.addHttpHeader = function(name, value) {
if (!this.httpHeaders) {
this.httpHeaders = {};
}
this.httpHeaders[name] = value;
};

Client.prototype.getHttpHeaders = function() {
return this.httpHeaders;
};

Client.prototype.clearHttpHeaders = function() {
this.httpHeaders = {};
};


Client.prototype.addBodyAttribute = function(bodyAttribute, name, namespace, xmlns) {
if (!this.bodyAttributes) {
this.bodyAttributes = [];
Expand Down Expand Up @@ -168,6 +184,7 @@ Client.prototype._invoke = function(method, args, location, callback, options, e
options = options || {};

//Add extra headers
for (var header in this.httpHeaders ) { headers[header] = this.httpHeaders[header]; }
for (var attr in extraHeaders) { headers[attr] = extraHeaders[attr]; }

// Allow the security object to add headers
Expand Down
16 changes: 16 additions & 0 deletions test/client-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,22 @@ describe('SOAP Client', function() {
done();
});
});

it('should add http headers', function(done) {
soap.createClient(__dirname+'/wsdl/default_namespace.wsdl', function(err, client) {
assert.ok(client);
assert.ok(!client.getHttpHeaders());

client.addHttpHeader('foo', 'bar');

assert.ok(client.getHttpHeaders());
assert.equal(client.getHttpHeaders().foo, 'bar');

client.clearHttpHeaders();
assert.equal(Object.keys(client.getHttpHeaders()).length, 0);
done();
});
});

describe('Namespace number', function() {
var server = null;
Expand Down