cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r523211 - in /incubator/cxf/trunk: api/src/main/java/org/apache/cxf/endpoint/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/ rt/frontend/jaxws/src/test/java/org/apach...
Date Wed, 28 Mar 2007 07:28:18 GMT
Author: ffang
Date: Wed Mar 28 00:28:17 2007
New Revision: 523211

URL: http://svn.apache.org/viewvc?view=rev&rev=523211
Log:
[CXF-496] support null holder

Modified:
    incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/HolderOutInterceptor.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java

Modified: incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java?view=diff&rev=523211&r1=523210&r2=523211
==============================================================================
--- incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java (original)
+++ incubator/cxf/trunk/api/src/main/java/org/apache/cxf/endpoint/Client.java Wed Mar 28 00:28:17
2007
@@ -31,7 +31,7 @@
 public interface Client extends InterceptorProvider, MessageObserver {
     String REQUEST_CONTEXT = "RequestContext";
     String RESPONSE_CONTEXT = "ResponseContext";
-    
+    String REQUEST_METHOD = "RequestMethod";
     /**
      * Invokes an operation syncronously
      * @param operationName The name of the operation to be invoked. The service namespace
will be used

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java?view=diff&rev=523211&r1=523210&r2=523211
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/JaxWsClientProxy.java
Wed Mar 28 00:28:17 2007
@@ -111,9 +111,9 @@
 
         context.put(Client.REQUEST_CONTEXT, reqContext);
         context.put(Client.RESPONSE_CONTEXT, respContext);
-
+       
         reqContext.put(Method.class.getName(), method);
-
+        reqContext.put(Client.REQUEST_METHOD, method);
         boolean isAsync = method.getName().endsWith("Async");
 
         Object result = null;

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/HolderOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/HolderOutInterceptor.java?view=diff&rev=523211&r1=523210&r2=523211
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/HolderOutInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/HolderOutInterceptor.java
Wed Mar 28 00:28:17 2007
@@ -19,12 +19,14 @@
 
 package org.apache.cxf.jaxws.interceptors;
 
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.logging.Logger;
 
 import javax.xml.ws.Holder;
 
+import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.message.Exchange;
@@ -78,6 +80,8 @@
             for (int i = 0; i < size; i++) {
                 newObjects.add(null);
             }
+            
+            handleNullHolder(message, outObjects);
             int[] argsOffset = removeOutHolderFromParaList(outObjects, parts, holders, size,
newObjects);
             
             if (holders.size() == 0) {
@@ -117,33 +121,54 @@
             message.setContent(List.class, newObjects);
             message.getExchange().put(HolderInInterceptor.CLIENT_HOLDERS, holders);
         } else {
-            // Add necessary holders so we match the method signature of the service class
-            List<Object> reqObjects =
-                CastUtils.cast(message.getExchange().getInMessage().getContent(List.class));
-    
-            int outIdx = 0;
-            for (MessagePartInfo part : parts) {
-                if (part.getIndex() == -1) {
-                    outIdx++;
-                    break;
-                }
+            handleResponse(message, outObjects, parts);
+        }
+    }
+
+    private void handleResponse(Message message, List<Object> outObjects, List<MessagePartInfo>
parts) {
+        // Add necessary holders so we match the method signature of the service class
+        List<Object> reqObjects =
+            CastUtils.cast(message.getExchange().getInMessage().getContent(List.class));
+   
+        int outIdx = 0;
+        for (MessagePartInfo part : parts) {
+            if (part.getIndex() == -1) {
+                outIdx++;
+                break;
             }
-            
-            for (MessagePartInfo part : parts) {
-                int methodIdx = part.getIndex();
-                if (methodIdx >= 0) {
-                    Holder holder = (Holder) reqObjects.get(methodIdx);
-                    Object o = holder.value;
-                    if (outIdx >= outObjects.size()) {
-                        outObjects.add(o);
-                    } else {
-                        outObjects.add(outIdx, o);
-                    }
-                    outIdx++;
+        }
+        
+        for (MessagePartInfo part : parts) {
+            int methodIdx = part.getIndex();
+            if (methodIdx >= 0) {
+                Holder holder = (Holder) reqObjects.get(methodIdx);
+                Object o = holder.value;
+                if (outIdx >= outObjects.size()) {
+                    outObjects.add(o);
+                } else {
+                    outObjects.add(outIdx, o);
                 }
+                outIdx++;
             }
-            message.setContent(List.class, outObjects);
         }
+        message.setContent(List.class, outObjects);
+    }
+
+    private void handleNullHolder(Message message, List<Object> outObjects) {
+        //process outObjects if Holder itself is null
+        Method method = (Method)message.get(Client.REQUEST_METHOD);
+        if (method == null) {
+            return;
+        }
+        Class<?>[] paramTypes = method.getParameterTypes();
+        int idx = 0;
+        for (Class rawClass : paramTypes) {
+            if (rawClass.equals(Holder.class) && outObjects.get(idx) == null) {
+                outObjects.set(idx, new Holder());
+            }
+            idx++;
+        }
+        
     }
 
     private int[] removeOutHolderFromParaList(List<Object> outObjects, 

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java?view=diff&rev=523211&r1=523210&r2=523211
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/header/HeaderClientServerTest.java
Wed Mar 28 00:28:17 2007
@@ -286,6 +286,20 @@
             throw (Exception)ex.getCause();
         }
     } 
+    
+    @Test
+    public void testHolderNull() {
+        URL wsdl = getClass().getResource("/wsdl/soapheader.wsdl");
+        assertNotNull(wsdl);
+        
+        SOAPHeaderService service = new SOAPHeaderService(wsdl, serviceName);
+        assertNotNull(service);
+        TestHeader proxy = service.getPort(portName, TestHeader.class);
+        proxy.testHeader2(null, null, null);
+        proxy.testHeader3(null, null);
+        proxy.testHeader5(null, null, null);
+        proxy.testHeaderPartBeforeBodyPart(null, null);
+    }
 
   // REVIST: This is not a valid WSDL according to WSI-BP V1.0
   //     @Test



Mime
View raw message