diff options
author | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2010-10-28 19:53:47 +0000 |
---|---|---|
committer | lresende <lresende@13f79535-47bb-0310-9956-ffa450edef68> | 2010-10-28 19:53:47 +0000 |
commit | 9c31d8adda0fe602d49beb1892c34ebb607266f4 (patch) | |
tree | 970b5341ef91a48bea44c1ecae207565ad363c59 | |
parent | 4440adc16560c9f45db1929c05b6bb12ad4f0eed (diff) |
Handling null return values in JSON-RPC binding
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1028450 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCServiceServlet.java | 8 |
1 files changed, 7 insertions, 1 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 9c379bd4e9..1e4292e66a 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 @@ -344,7 +344,13 @@ public class JSONRPCServiceServlet extends JSONRPCServlet { try { result = responseMessage.getBody(); JSONObject jsonResponse = new JSONObject(); - jsonResponse.put("result", result); + //JSONObject put will remove the entry if it's value is null + //and per javadoc, we should pass JSONObject.NULL + if(result == null) { + jsonResponse.put("result", JSONObject.NULL); + } else { + jsonResponse.put("result", result); + } jsonResponse.putOpt("id", id); //get response to send to client return jsonResponse.toString().getBytes("UTF-8"); |