Skip to content

Commit

Permalink
add fault body for exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
atwong committed Dec 7, 2012
1 parent e44fb8d commit 7999eba
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions lib/server.js
Expand Up @@ -200,22 +200,27 @@ Server.prototype._executeMethod = function(options, callback) {
}
args['_context'] = this.context;

function handleResult(result) {
function handleResult(err, result) {
if (handled) return;
handled = true;

var actualOutputName = err ? 'Fault' : outputName;
if (err) {
result = err;
}

if(style==='rpc') {
body = self.wsdl.objectToRpcXML(outputName, result, '', self.wsdl.definitions.$targetNamespace);
body = self.wsdl.objectToRpcXML(actualOutputName, result, '', self.wsdl.definitions.$targetNamespace);
} else {
var element = self.wsdl.definitions.services[serviceName].ports[portName].binding.methods[methodName].output;
body = self.wsdl.objectToDocumentXML(outputName, result, element.targetNSAlias, element.targetNamespace);
body = self.wsdl.objectToDocumentXML(actualOutputName, result, element.targetNSAlias, element.targetNamespace);
}
callback(self._envelope(body));
}

var result = method(args, handleResult);
if (typeof result !== 'undefined') {
handleResult(result);
handleResult(err, result);
}
}

Expand Down

0 comments on commit 7999eba

Please sign in to comment.