Skip to content

Commit

Permalink
fix error when soapaction header is not set (#1171)
Browse files Browse the repository at this point in the history
* fix error when soapaction is not set

* fix error when soapaction is not set

* + add test for calling the server method without the SOAPAction header set
  • Loading branch information
paulish committed Nov 10, 2021
1 parent f6a0979 commit d284fea
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,9 @@ export class Server extends EventEmitter {
}

private _getSoapAction(req: Request) {
if (typeof req.headers.soapaction === 'undefined') {
return;
}
const soapAction: string = req.headers.soapaction as string;
return (soapAction.indexOf('"') === 0)
? soapAction.slice(1, -1)
Expand Down
14 changes: 13 additions & 1 deletion test/server-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ describe('SOAP Server', function () {
});
});


it('should return correct async results (double argument callback style)', function (done) {
soap.createClient(test.baseUrl + '/stockquote?wsdl', function (err, client) {
assert.ifError(err);
Expand All @@ -300,6 +299,19 @@ describe('SOAP Server', function () {
});
});

it('should return correct result when called without SOAPAction header', function(done) {
soap.createClient(test.baseUrl + '/stockquote?wsdl', function (err, client) {
assert.ifError(err);
// this clears the SOAPAction header
client.addHttpHeader('SOAPAction', '');
client.IsValidPrice({ price: 50000 }, function (err, result) {
assert.ifError(err);
assert.equal(true, !!(result.valid));
done();
});
});
});

it('should support Promise return result', function (done) {
soap.createClient(test.baseUrl + '/stockquote?wsdl', function (err, client) {
assert.ifError(err);
Expand Down

0 comments on commit d284fea

Please sign in to comment.