responseMessage = endpoint.getInvocationChain(jsonOperation).getHeadInvoker().invoke(requestMessage);
} catch (RuntimeException re) {
if (re.getCause() instanceof javax.security.auth.login.LoginException) {
throw re;
} else {
JsonRpc20Error error = new JsonRpc20Error(request.getId(), re);
return error;
}
}
if (!responseMessage.isFault()) {
if (jsonOperation.getOutputWrapper().getDataBinding().equals(JSONDataBinding.NAME)) {
result = responseMessage.getBody();
return new JsonRpc20Response((ObjectNode)JacksonHelper.MAPPER.readTree(result.toString()));
} else {
if (jsonOperation.getOutputType().getLogical().size() == 0) {
// void operation (json-rpc notification)
try {
JsonRpc20Response response = new JsonRpc20Response(request.getId(), null);
return response;
} catch (Exception e) {
throw new ServiceRuntimeException("Unable to create JSON response", e);
}
} else {
// regular operation returning some value
try {
result = responseMessage.getBody();
JsonRpc20Response response = new JsonRpc20Response(request.getId(), (JsonNode)result);
//get response to send to client
return response;
} catch (Exception e) {
throw new ServiceRuntimeException("Unable to create JSON response", e);
}
}
}
} else {
//exception thrown while executing the invocation
Throwable exception = (Throwable)responseMessage.getBody();
JsonRpc20Error error = new JsonRpc20Error(request.getId(), exception);
return error;
}
}