Package org.apache.tuscany.sca.binding.jsonrpc.protocol

Examples of org.apache.tuscany.sca.binding.jsonrpc.protocol.JsonRpc20Error


            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;
        }

    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.binding.jsonrpc.protocol.JsonRpc20Error

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.