log.error("Endpoint " + msg.destination + " doesn't exist (" + msg + ")");
return returnError(msg, "Server.Invoke.Error", "Endpoint " + msg.destination + " doesn't exist.", "Endpoint " + msg.destination + " doesn't exist.");
}
Object[] args = (Object[]) ConversionUtils.convert(msg.body, Object[].class);
IPendingServiceCall call = new PendingCall(msg.operation, args);
try {
if (!serviceInvoker.invoke(call, endpoint)) {
if (call.getException() != null) {
// Use regular exception handling
Throwable err = call.getException();
return returnError(msg, "Server.Invoke.Error", err.getMessage(), err);
}
return returnError(msg, "Server.Invoke.Error", "Can't invoke method.", "");
}
} catch (Throwable err) {
log.error("Error while invoking method.", err);
return returnError(msg, "Server.Invoke.Error", err.getMessage(), err);
}
// We got a valid result from the method call.
AcknowledgeMessage result = new AcknowledgeMessage();
result.body = call.getResult();
result.headers = msg.headers;
result.clientId = msg.clientId;
result.correlationId = msg.messageId;
return result;
}