Skip to content
Open
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
28 changes: 15 additions & 13 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ Server.prototype._process = function (input, req, callback) {
Server.prototype._executeMethod = function (options, req, callback, includeTimestamp) {
options = options || {};
var self = this,
method, body, headers,
method, body,
serviceName = options.serviceName,
portName = options.portName,
methodName = options.methodName,
Expand All @@ -349,20 +349,22 @@ Server.prototype._executeMethod = function (options, req, callback, includeTimes
style = options.style,
handled = false;

if (this.soapHeaders) {
headers = this.soapHeaders.map(function(header) {
if (typeof header === 'function') {
return header(methodName, args, options.headers, req);
} else {
return header;
}
}).join("\n");
function getSoapHeaders() {
if (self.soapHeaders) {
return self.soapHeaders.map(function(header) {
if (typeof header === 'function') {
return header(methodName, args, options.headers, req);
} else {
return header;
}
}).join("\n");
}
}

try {
method = this.services[serviceName][portName][methodName];
} catch (error) {
return callback(this._envelope('', headers, includeTimestamp));
return callback(this._envelope('', getSoapHeaders(), includeTimestamp));
}

function handleResult(error, result) {
Expand All @@ -384,21 +386,21 @@ Server.prototype._executeMethod = function (options, req, callback, includeTimes
var element = self.wsdl.definitions.services[serviceName].ports[portName].binding.methods[methodName].output;
body = self.wsdl.objectToDocumentXML(outputName, result, element.targetNSAlias, element.targetNamespace);
}
callback(self._envelope(body, headers, includeTimestamp));
callback(self._envelope(body, getSoapHeaders(), includeTimestamp));
}

if (!self.wsdl.definitions.services[serviceName].ports[portName].binding.methods[methodName].output) {
// no output defined = one-way operation so return empty response
handled = true;
body = '';
if (this.onewayOptions.emptyBody) {
body = self._envelope('', headers, includeTimestamp);
body = self._envelope('', getSoapHeaders(), includeTimestamp);
}
callback(body, this.onewayOptions.responseCode);
}

var result = method(args, handleResult, options.headers, req);
if (typeof result !== 'undefined') {
if (typeof result !== 'undefined' && typeof result.then !== 'function') {
handleResult(result);
}
};
Expand Down