diff options
Diffstat (limited to 'sca-java-2.x/trunk')
-rw-r--r-- | sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java | 39 |
1 files changed, 27 insertions, 12 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java index c24d90e2d0..9c379bd4e9 100644 --- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java +++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java @@ -302,10 +302,11 @@ public class JSONRPCServiceServlet extends JSONRPCServlet { requestMessage.getHeaders().put("RequestMessage", request); - if (jsonOperation.getWrapper().getDataBinding().equals(JSONDataBinding.NAME)) + if (jsonOperation.getWrapper().getDataBinding().equals(JSONDataBinding.NAME)) { requestMessage.setBody(new Object[]{jsonReq.toString()}); - else + } else { requestMessage.setBody(args); + } //result = wire.invoke(jsonOperation, args); Message responseMessage = null; @@ -327,16 +328,30 @@ public class JSONRPCServiceServlet extends JSONRPCServlet { result = responseMessage.getBody(); return result.toString().getBytes("UTF-8"); } else { - try { - result = responseMessage.getBody(); - JSONObject jsonResponse = new JSONObject(); - jsonResponse.put("result", result); - jsonResponse.putOpt("id", id); - //get response to send to client - return jsonResponse.toString().getBytes("UTF-8"); - } catch (Exception e) { - throw new ServiceRuntimeException("Unable to create JSON response", e); - } + if (jsonOperation.getOutputType() == null) { + // void operation (json-rpc notification) + try { + JSONObject jsonResponse = new JSONObject(); + jsonResponse.put("result", ""); + //get response to send to client + return jsonResponse.toString().getBytes("UTF-8"); + } catch (Exception e) { + throw new ServiceRuntimeException("Unable to create JSON response", e); + } + + } else { + // regular operation returning some value + try { + result = responseMessage.getBody(); + JSONObject jsonResponse = new JSONObject(); + jsonResponse.put("result", result); + jsonResponse.putOpt("id", id); + //get response to send to client + return jsonResponse.toString().getBytes("UTF-8"); + } catch (Exception e) { + throw new ServiceRuntimeException("Unable to create JSON response", e); + } + } } } else { //exception thrown while executing the invocation |