From b28011be9614454b3e60868d6af1eba3860edb59 Mon Sep 17 00:00:00 2001 From: Andrei Ortan Date: Thu, 4 Dec 2025 13:52:51 +0200 Subject: [PATCH] wip proposal --- lib/addMethod/addMethodSOAP.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/addMethod/addMethodSOAP.js b/lib/addMethod/addMethodSOAP.js index da71d60..a5dc8f6 100644 --- a/lib/addMethod/addMethodSOAP.js +++ b/lib/addMethod/addMethodSOAP.js @@ -126,7 +126,7 @@ module.exports = function (methodName, config, afterHeadersFunction) { .then(function (soapRequest) { return when.promise(function (resolve, reject) { - var handleResponse = function (err, result, raw, soapHeaders) { + function handleResponseWithClient (err, result, raw, soapHeaders, client) { function handleReject (payload) { return reject({ @@ -156,8 +156,9 @@ module.exports = function (methodName, config, afterHeadersFunction) { logger.info(methodName + ': got response', JSON.stringify(raw)); + const finalResult = { ...result, ...(client.lastResponseAttachments ? { attachments: client.lastResponseAttachments } : {}) }; var res = { - body: result, + body: finalResult, response: { raw: raw, headers: soapHeaders @@ -186,7 +187,7 @@ module.exports = function (methodName, config, afterHeadersFunction) { } - }; + } logger.info(methodName + ': creating SOAP client'); @@ -203,14 +204,16 @@ module.exports = function (methodName, config, afterHeadersFunction) { throw new Error(soapRequest.method + ' method does not exist.'); } - return methodExe; + return { client, methodExe }; }) //Execute the request accordingly .done( - function (methodExe) { + function ({ client, methodExe }) { logger.info(methodName + ': running SOAP soapRequest', soapRequest); - methodExe(soapRequest.data, handleResponse); + methodExe(soapRequest.data, function (err, result, raw, soapHeaders) { + handleResponseWithClient(err, result, raw, soapHeaders, client); + }); }, function (err) { reject(err);