From 3b13b2066f00bdf9f1a65c5402cb7aa5e2fa5710 Mon Sep 17 00:00:00 2001 From: rfeng Date: Tue, 16 Nov 2010 18:48:27 +0000 Subject: Fix the return type to match the object[] for output git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1035743 13f79535-47bb-0310-9956-ffa450edef68 --- .../binding/jsonrpc/provider/JSONRPCBindingInvoker.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'sca-java-2.x/trunk/modules') diff --git a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java index 9691910893..b58fbb9f53 100644 --- a/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java +++ b/sca-java-2.x/trunk/modules/binding-jsonrpc-runtime/src/main/java/org/apache/tuscany/sca/binding/jsonrpc/provider/JSONRPCBindingInvoker.java @@ -140,8 +140,12 @@ public class JSONRPCBindingInvoker implements Invoker, DataExchangeSemantics { if (!jsonResponse.has("result")) { processException(jsonResponse); } - DataType outputType = operation.getOutputType(); - if (outputType == null) { + DataType> outputType = operation.getOutputType(); + DataType returnType = + (outputType != null && !outputType.getLogical().isEmpty()) ? outputType.getLogical().get(0) + : null; + + if (returnType == null) { msg.setBody(null); return msg; } @@ -156,14 +160,14 @@ public class JSONRPCBindingInvoker implements Invoker, DataExchangeSemantics { processException(jsonResponse); } - Class returnType = outputType.getPhysical(); - Type genericReturnType = outputType.getGenericType(); + Class returnClass = returnType.getPhysical(); + Type genericReturnType = returnType.getGenericType(); - ObjectMapper mapper = createObjectMapper(returnType); + ObjectMapper mapper = createObjectMapper(returnClass); String json = rawResult.toString(); // Jackson requires the quoted String so that readValue can work - if (returnType == String.class) { + if (returnClass == String.class) { json = "\"" + json + "\""; } Object body = mapper.readValue(json, TypeFactory.type(genericReturnType)); -- cgit v1.2.3