From d284fea9fe0ef5e24c91312e7d95eb9b681b70e4 Mon Sep 17 00:00:00 2001 From: Paul Ishenin Date: Thu, 11 Nov 2021 05:44:22 +0700 Subject: [PATCH] fix error when soapaction header is not set (#1171) * 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 --- src/server.ts | 3 +++ test/server-test.js | 14 +++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/server.ts b/src/server.ts index d50956685..247cdcede 100644 --- a/src/server.ts +++ b/src/server.ts @@ -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) diff --git a/test/server-test.js b/test/server-test.js index e1ff2cab3..180c1ac30 100644 --- a/test/server-test.js +++ b/test/server-test.js @@ -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); @@ -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);