cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r542945 - /incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java
Date Wed, 30 May 2007 21:55:52 GMT
Author: dkulp
Date: Wed May 30 14:55:51 2007
New Revision: 542945

URL: http://svn.apache.org/viewvc?view=rev&rev=542945
Log:
Fix issue of if a header appears before the wrapper parts, it tried to unwrap the header instead
of the part.


Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java?view=diff&rev=542945&r1=542944&r2=542945
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java
(original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/interceptors/WrapperClassInInterceptor.java
Wed May 30 14:55:51 2007
@@ -20,10 +20,10 @@
 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 org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxb.WrapperHelper;
 import org.apache.cxf.message.Message;
@@ -63,26 +63,43 @@
         
         if (boi != null && boi.isUnwrappedCapable()) {
             BindingOperationInfo boi2 = boi.getUnwrappedOperation();
-            
-            // Sometimes, an operation can be unwrapped according to WSDLServiceFactory,
-            // but not according to JAX-WS. We should unify these at some point, but
-            // for now check for the wrapper class.
-            MessageInfo messageInfo = message.get(MessageInfo.class);
-            if (messageInfo != null && messageInfo.getMessageParts().get(0).getTypeClass()
== null) {
-                return;
-            }
-            
             OperationInfo op = boi2.getOperationInfo();
             BindingMessageInfo bmi;
-            if (messageInfo == boi.getOperationInfo().getInput()) {
+            
+            MessageInfo wrappedMessageInfo = message.get(MessageInfo.class);
+            MessageInfo messageInfo;
+            if (wrappedMessageInfo == boi.getOperationInfo().getInput()) {
                 messageInfo = op.getInput();
                 bmi = boi2.getInput();
             } else {
                 messageInfo = op.getOutput();
                 bmi = boi2.getOutput();
             }
-                        
+            
+            // Sometimes, an operation can be unwrapped according to WSDLServiceFactory,
+            // but not according to JAX-WS. We should unify these at some point, but
+            // for now check for the wrapper class.
             List<?> lst = message.getContent(List.class);
+            if (lst == null) {
+                return;
+            }
+            Class<?> wrapperClass = null;
+            Object wrappedObject = null;
+            if (wrappedMessageInfo != null) {
+                for (MessagePartInfo part : wrappedMessageInfo.getMessageParts()) {
+                    //headers should appear in both, find the part that doesn't
+                    if (messageInfo.getMessagePart(part.getName()) == null) {
+                        wrapperClass = part.getTypeClass();
+                        for (Object o : lst) {
+                            if (wrapperClass.isInstance(o)) {
+                                wrappedObject = o;
+                                break;
+                            }
+                        }
+                        break;
+                    }
+                }
+            }
             
             if (lst != null) {
                 message.put(MessageInfo.class, messageInfo);
@@ -94,38 +111,39 @@
                 LOG.info("WrapperClassInInterceptor skipped in HTTP GET method");
                 return;
             }
-            if (lst != null && lst.size() == 1) {
-                if (messageInfo.getMessageParts().size() > 0) {
-                    Object wrappedObject = lst.get(0);
-                    lst.clear();
-                    
-                    for (MessagePartInfo part : messageInfo.getMessageParts()) {
-                        try {
-                            String elementType = null;
-                            if (part.isElement()) {
-                                elementType = part.getElementQName().getLocalPart();
+            if (wrapperClass == null || wrappedObject == null) {
+                return;
+            }
+            
+            List<Object> newParams = new ArrayList<Object>();
+            for (MessagePartInfo part : messageInfo.getMessageParts()) {
+                if (wrappedMessageInfo.getMessagePart(part.getName()) != null) {
+                    newParams.add(lst.get(part.getIndex()));
+                } else {
+                    try {
+                        String elementType = null;
+                        if (part.isElement()) {
+                            elementType = part.getElementQName().getLocalPart();
+                        } else {
+                            if (part.getTypeQName() == null) {
+                                // handling anonymous complex type
+                                elementType = null;
                             } else {
-                                if (part.getTypeQName() == null) {
-                                    // handling anonymous complex type
-                                    elementType = null;
-                                } else {
-                                    elementType = part.getTypeQName().getLocalPart();
-                                }
+                                elementType = part.getTypeQName().getLocalPart();
                             }
-                            Object obj = WrapperHelper.getWrappedPart(part.getName().getLocalPart(),

-                                                                      wrappedObject,
-                                                                      elementType);
-                        
-                            CastUtils.cast(lst, Object.class).add(obj);
-                        } catch (Exception e) {
-                            // TODO - fault
-                            throw new Fault(e);
                         }
+                        Object obj = WrapperHelper.getWrappedPart(part.getName().getLocalPart(),

+                                                                  wrappedObject,
+                                                                  elementType);
+                    
+                        newParams.add(obj);
+                    } catch (Exception e) {
+                        // TODO - fault
+                        throw new Fault(e);
                     }
-                } else {
-                    lst.clear();
                 }
             }
+            message.setContent(List.class, newParams);
         }
     }
 



Mime
View raw message