Skip to content
Draft
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
15 changes: 9 additions & 6 deletions lib/addMethod/addMethodSOAP.js
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -186,7 +187,7 @@ module.exports = function (methodName, config, afterHeadersFunction) {

}

};
}


logger.info(methodName + ': creating SOAP client');
Expand All @@ -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);
Expand Down
Loading