Skip to content

Commit

Permalink
fix for soap 1.2 content-type header, missing action key
Browse files Browse the repository at this point in the history
  • Loading branch information
gbar committed Jun 6, 2019
1 parent 80f4157 commit dbbc838
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 26 deletions.
6 changes: 1 addition & 5 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,6 @@ export class Client extends EventEmitter {
this.wsdl.options.overrideRootElement = options.overrideRootElement;
}
this.wsdl.options.forceSoap12Headers = !!options.forceSoap12Headers;
this.wsdl.options.addHeadersAction = !!options.addHeadersAction;
}

private _defineService(service: ServiceElement, endpoint?: string) {
Expand Down Expand Up @@ -361,10 +360,7 @@ export class Client extends EventEmitter {
}

if (this.wsdl.options.forceSoap12Headers) {
headers['Content-Type'] = 'application/soap+xml; charset=utf-8';
if (this.wsdl.options.addHeadersAction) {
headers['Content-Type'] += '; action=' + soapAction;
}
headers['Content-Type'] = `application/soap+xml; charset=utf-8; action="${soapAction}"`;
xmlnsSoap = 'xmlns:' + envelopeKey + '="http://www.w3.org/2003/05/soap-envelope"';
} else {
headers.SOAPAction = '"' + soapAction + '"';
Expand Down
2 changes: 0 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ export interface IWsdlBaseOptions {
wsdl_options?: { [key: string]: any };
/** set proper headers for SOAP v1.2. */
forceSoap12Headers?: boolean;
/** set content type header action for SOAP v1.2 */
addHeadersAction?: boolean;
}

/** @deprecated use IOptions */
Expand Down
1 change: 0 additions & 1 deletion src/wsdl/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,6 @@ export class WSDL {

// Works only in client
this.options.forceSoap12Headers = options.forceSoap12Headers;
this.options.addHeadersAction = options.addHeadersAction;
this.options.customDeserializer = options.customDeserializer;

if (options.overrideRootElement !== undefined) {
Expand Down
19 changes: 1 addition & 18 deletions test/client-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -422,24 +422,7 @@ var fs = require('fs'),
assert.ok(result);
assert.ok(client.lastRequestHeaders);
assert.ok(client.lastRequest);
assert.equal(client.lastRequestHeaders['Content-Type'], 'application/soap+xml; charset=utf-8');
assert.notEqual(client.lastRequest.indexOf('xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\"'), -1);
assert(!client.lastRequestHeaders.SOAPAction);
done();
}, null, { 'test-header': 'test' });
}, baseUrl);
});

it('should add proper headers for soap12 with action in content type', function (done) {
soap.createClient(__dirname + '/wsdl/default_namespace_soap12.wsdl', _.assign({ forceSoap12Headers: true, addHeadersAction: true}, meta.options), function (err, client) {
assert.ok(client);
assert.ifError(err);

client.MyOperation({}, function (err, result) {
assert.ok(result);
assert.ok(client.lastRequestHeaders);
assert.ok(client.lastRequest);
assert.equal(client.lastRequestHeaders['Content-Type'], 'application/soap+xml; charset=utf-8; action=MyOperation');
assert.equal(client.lastRequestHeaders['Content-Type'], 'application/soap+xml; charset=utf-8; action="MyOperation"');
assert.notEqual(client.lastRequest.indexOf('xmlns:soap=\"http://www.w3.org/2003/05/soap-envelope\"'), -1);
assert(!client.lastRequestHeaders.SOAPAction);
done();
Expand Down

0 comments on commit dbbc838

Please # to comment.