summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/binding-http-runtime/src
diff options
context:
space:
mode:
Diffstat (limited to 'sca-java-2.x/trunk/modules/binding-http-runtime/src')
-rw-r--r--sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPDefaultWireFormatServiceInterceptor.java27
1 files changed, 25 insertions, 2 deletions
diff --git a/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPDefaultWireFormatServiceInterceptor.java b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPDefaultWireFormatServiceInterceptor.java
index 9a0c73e9b0..ccd4e03ca6 100644
--- a/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPDefaultWireFormatServiceInterceptor.java
+++ b/sca-java-2.x/trunk/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/format/HTTPDefaultWireFormatServiceInterceptor.java
@@ -28,6 +28,7 @@ import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.SortedSet;
+import java.util.StringTokenizer;
import java.util.TreeSet;
import javax.servlet.ServletRequest;
@@ -90,10 +91,32 @@ public class HTTPDefaultWireFormatServiceInterceptor implements Interceptor {
if ("GET".equals(servletRequest.getMethod())) {
msg.setBody(getRequestFromQueryString(msg.getOperation(), servletRequest));
} else {
- msg.setBody(read(servletRequest));
+ msg.setBody(getRequestFromPost(msg.getOperation(), servletRequest));
}
return msg;
}
+
+ /**
+ * The data binding seems to be expecting an Object array of json strings so if the
+ * post data is a json array convert that to an array of strings
+ * TODO: should this be being done by the data binding framework?
+ */
+ private Object[] getRequestFromPost(Operation operation, HttpServletRequest servletRequest) throws IOException {
+ List<Object> os = new ArrayList<Object>();
+ String data = read(servletRequest);
+ if (data.length() > 0) {
+ if (data.startsWith("[") && data.endsWith("]")) {
+ data = data.substring(1, data.length()-1);
+ StringTokenizer st = new StringTokenizer(data, ",");
+ while (st.hasMoreElements()) {
+ os.add(st.nextElement());
+ }
+ } else {
+ os.add(data);
+ }
+ }
+ return os.toArray();
+ }
private Message invokeResponse(Message msg) throws IOException {
HTTPContext context = msg.getBindingContext();
@@ -219,7 +242,7 @@ public class HTTPDefaultWireFormatServiceInterceptor implements Interceptor {
while ((str = reader.readLine()) != null) {
sb.append(str);
}
- return sb.toString();
+ return sb.toString().trim();
} finally {
if (reader != null) {
reader.close();