You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by dk...@apache.org on 2007/12/13 04:18:42 UTC

svn commit: r603807 - in /incubator/cxf/trunk: rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ systests/src/test/java/org/apache/cxf/systest/jaxws/

Author: dkulp
Date: Wed Dec 12 19:18:39 2007
New Revision: 603807

URL: http://svn.apache.org/viewvc?rev=603807&view=rev
Log:
[CXF-1297] Fix for problems with simple frontend clients not working with wsdl first cases

Modified:
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties
    incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java?rev=603807&r1=603806&r2=603807&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java Wed Dec 12 19:18:39 2007
@@ -20,7 +20,11 @@
 package org.apache.cxf.jaxws.support;
 
 import java.lang.annotation.Annotation;
+import java.lang.reflect.Array;
+import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
 import java.util.concurrent.Future;
 
 import javax.jws.Oneway;
@@ -682,5 +686,31 @@
             return "";
         }
     }
-           
+    public Boolean isHolder(Class<?> cls, Type type) {
+        return Holder.class.equals(cls);
+    }
+    
+    public Class<?> getHolderType(Class<?> cls, Type type) {
+        if (cls.equals(Holder.class) && type instanceof ParameterizedType) {
+            ParameterizedType paramType = (ParameterizedType)type;
+            cls = getHolderClass(paramType);
+        }
+
+        return cls;
+    }   
+    
+    private static Class getHolderClass(ParameterizedType paramType) {
+        Object rawType = paramType.getActualTypeArguments()[0];
+        Class rawClass;
+        if (rawType instanceof GenericArrayType) {
+            rawClass = (Class)((GenericArrayType)rawType).getGenericComponentType();
+            rawClass = Array.newInstance(rawClass, 0).getClass();
+        } else {
+            if (rawType instanceof ParameterizedType) {
+                rawType = (Class)((ParameterizedType)rawType).getRawType();
+            }
+            rawClass = (Class)rawType;
+        }
+        return rawClass;
+    }
 }

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?rev=603807&r1=603806&r2=603807&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java Wed Dec 12 19:18:39 2007
@@ -26,7 +26,6 @@
 import java.util.Arrays;
 import java.util.List;
 import java.util.Set;
-import java.util.logging.Logger;
 import javax.wsdl.Operation;
 import javax.xml.namespace.QName;
 import javax.xml.ws.Action;
@@ -39,8 +38,6 @@
 
 import org.apache.cxf.binding.AbstractBindingFactory;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
-import org.apache.cxf.common.i18n.Message;
-import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.databinding.source.SourceDataBinding;
 import org.apache.cxf.endpoint.Endpoint;
@@ -52,7 +49,6 @@
 import org.apache.cxf.jaxws.interceptors.DispatchInDatabindingInterceptor;
 import org.apache.cxf.jaxws.interceptors.DispatchOutDatabindingInterceptor;
 import org.apache.cxf.jaxws.interceptors.WebFaultOutInterceptor;
-import org.apache.cxf.message.Exchange;
 import org.apache.cxf.service.factory.AbstractServiceConfiguration;
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 import org.apache.cxf.service.factory.ServiceConstructionException;
@@ -62,7 +58,6 @@
 import org.apache.cxf.service.model.FaultInfo;
 import org.apache.cxf.service.model.InterfaceInfo;
 import org.apache.cxf.service.model.MessageInfo;
-import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.ws.addressing.JAXWSAConstants;
@@ -75,8 +70,6 @@
  * @see org.apache.cxf.jaxws.JaxWsServerFactoryBean
  */
 public class JaxWsServiceFactoryBean extends ReflectionServiceFactoryBean {
-    private static final Logger LOG = LogUtils.getL7dLogger(JaxWsServiceFactoryBean.class);
-
     private AbstractServiceConfiguration jaxWsConfiguration;
 
     private JaxWsImplementorInfo implInfo;
@@ -155,7 +148,6 @@
     @Override
     protected void initializeWSDLOperation(InterfaceInfo intf, OperationInfo o, Method method) {
         method = ((JaxWsServiceConfiguration)jaxWsConfiguration).getDeclaredMethod(method);
-        super.initializeWSDLOperation(intf, o, method);
 
         initializeWrapping(o, method);
 
@@ -278,31 +270,7 @@
     //
     // return intf;
     // }
-    private void setFaultClassInfo(OperationInfo o, Method selected) {
-        Class[] types = selected.getExceptionTypes();
-        for (int i = 0; i < types.length; i++) {
-            Class exClass = types[i];
-            Class beanClass = getBeanClass(exClass);
-
-            QName name = getFaultName(o.getInterface(), o, exClass, beanClass);
-
-            for (FaultInfo fi : o.getFaults()) {
-                for (MessagePartInfo mpi : fi.getMessageParts()) {
-                    String ns = null;
-                    if (mpi.isElement()) {
-                        ns = mpi.getElementQName().getNamespaceURI();
-                    } else {
-                        ns = mpi.getTypeQName().getNamespaceURI();
-                    }
-                    if (mpi.getConcreteName().getLocalPart().equals(name.getLocalPart())
-                        && name.getNamespaceURI().equals(ns)) {
-                        fi.setProperty(Class.class.getName(), exClass);
-                        mpi.setTypeClass(beanClass);
-                    }
-                }
-            }
-        }
-    }
+
 
     @Override
     protected Class<?> getBeanClass(Class<?> exClass) {
@@ -331,117 +299,6 @@
         }
         
         return super.getBeanClass(exClass);
-    }
-
-    /**
-     * set the holder generic type info into message part info
-     *
-     * @param o
-     * @param method
-     */
-    protected void initializeClassInfo(OperationInfo o, Method method, List<String> paramOrder) {
-        if (isWrapped(method)) {
-            if (o.getUnwrappedOperation() == null) {
-                //the "normal" algorithm didn't allow for unwrapping,
-                //but the annotations say unwrap this.   We'll need to
-                //make it.
-                WSDLServiceBuilder.checkForWrapped(o, true);
-            }
-
-            if (o.hasInput()) {
-                MessageInfo input = o.getInput();
-                MessagePartInfo part = input.getMessageParts().get(0);
-                part.setTypeClass(getRequestWrapper(method));
-                part.setProperty("REQUEST.WRAPPER.CLASSNAME", getRequestWrapperClassName(method));
-                part.setIndex(0);
-            }
-
-            if (o.hasOutput()) {
-                MessageInfo input = o.getOutput();
-                MessagePartInfo part = input.getMessageParts().get(0);
-                part.setTypeClass(getResponseWrapper(method));
-                part.setProperty("RESPONSE.WRAPPER.CLASSNAME", getResponseWrapperClassName(method));
-                part.setIndex(0);
-            }
-
-            setFaultClassInfo(o, method);
-            o = o.getUnwrappedOperation();
-        } else if (o.isUnwrappedCapable()) {
-            // remove the unwrapped operation because it will break the
-            // the WrapperClassOutInterceptor, and in general makes
-            // life more confusing
-            o.setUnwrappedOperation(null);
-
-            setFaultClassInfo(o, method);
-        }
-
-        Class<?>[] paramTypes = method.getParameterTypes();
-        Type[] genericTypes = method.getGenericParameterTypes();
-        for (int i = 0; i < paramTypes.length; i++) {
-            if (Exchange.class.equals(paramTypes[i])) {
-                continue;
-            }
-            Class paramType = paramTypes[i];
-            Type genericType = genericTypes[i];
-            initializeParameter(o, method, i, paramType, genericType);
-        }
-
-        // Initialize return type
-        Class paramType = method.getReturnType();
-        Type genericType = method.getGenericReturnType();
-
-        initializeParameter(o, method, -1, paramType, genericType);
-
-        setFaultClassInfo(o, method);
-    }
-
-    private void initializeParameter(OperationInfo o, Method method, int i,
-                                     Class paramType, Type genericType) {
-        boolean isIn = isInParam(method, i);
-        boolean isOut = isOutParam(method, i);
-
-        MessagePartInfo part = null;
-        if (isIn && !isOut) {
-            QName name = getInPartName(o, method, i);
-            part = o.getInput().getMessagePart(name);
-            if (part == null) {
-                throw new ServiceConstructionException(
-                    new Message("COULD_NOT_FIND_PART", LOG,
-                                name,
-                                o.getInput().getMessagePartsMap().keySet().toString()));
-            }
-            initializeParameter(part, paramType, genericType);
-            part.setIndex(i);
-        } else if (!isIn && isOut) {
-            QName name = getOutPartName(o, method, i);
-            part = o.getOutput().getMessagePart(name);
-            if (part == null) {
-                throw new ServiceConstructionException(
-                    new Message("COULD_NOT_FIND_PART", LOG,
-                                name,
-                                o.getOutput().getMessagePartsMap().keySet().toString()));
-            }
-            part.setProperty(ReflectionServiceFactoryBean.MODE_OUT, Boolean.TRUE);
-            initializeParameter(part, paramType, genericType);
-            part.setIndex(i + 1);
-        } else if (isIn && isOut) {
-            QName name = getInPartName(o, method, i);
-            part = o.getInput().getMessagePart(name);
-            if (part == null) {
-                throw new ServiceConstructionException(
-                    new Message("COULD_NOT_FIND_PART", LOG,
-                                name,
-                                o.getInput().getMessagePartsMap().keySet().toString()));
-            }
-            part.setProperty(ReflectionServiceFactoryBean.MODE_INOUT, Boolean.TRUE);
-            initializeParameter(part, paramType, genericType);
-            part.setIndex(i);
-
-            part = o.getOutput().getMessagePart(name);
-            part.setProperty(ReflectionServiceFactoryBean.MODE_INOUT, Boolean.TRUE);
-            initializeParameter(part, paramType, genericType);
-            part.setIndex(i + 1);
-        }
     }
 
     public void setJaxWsConfiguration(JaxWsServiceConfiguration jaxWsConfiguration) {

Modified: incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties?rev=603807&r1=603806&r2=603807&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties (original)
+++ incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties Wed Dec 12 19:18:39 2007
@@ -24,4 +24,3 @@
 ILLEGAL_ATTRIBUTE_IN_SEI_ANNOTATION_EXC = Attributes portName, serviceName and endpointInterface are not allowed in the @WebService annotation of an SEI.
 MALFORMED_URL_IN_WEBSERVICE_ANNOTATION_EXC = Malformed url in @WebService annotation attribute wsdlLocation.
 LOAD_WSDL_EXC = Could not load WSDL from URL {0}.
-COULD_NOT_FIND_PART = Could not find a message part matching name {0}.  Possible values are {1}.

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java?rev=603807&r1=603806&r2=603807&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java Wed Dec 12 19:18:39 2007
@@ -20,6 +20,7 @@
 package org.apache.cxf.service.factory;
 
 import java.lang.reflect.Method;
+import java.lang.reflect.Type;
 
 import javax.xml.namespace.QName;
 
@@ -130,7 +131,7 @@
     }
 
     public QName getOutParameterName(final OperationInfo op, final Method method,
-                                     final int paramNumber) {
+                                      final int paramNumber) {
         return null;
     }
 
@@ -176,6 +177,14 @@
     }
     
     public Boolean isRPC(Method selected) {
+        return null;
+    }
+    
+    public Boolean isHolder(Class<?> cls, Type type) {
+        return null;
+    }
+    
+    public Class<?> getHolderType(Class<?> cls, Type type) {
         return null;
     }
 }

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java?rev=603807&r1=603806&r2=603807&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java Wed Dec 12 19:18:39 2007
@@ -19,8 +19,12 @@
 
 package org.apache.cxf.service.factory;
 
+import java.lang.reflect.Array;
+import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.Method;
 import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
 import java.util.Arrays;
 
 import javax.xml.namespace.QName;
@@ -39,10 +43,18 @@
     
     @Override
     public QName getOperationName(InterfaceInfo service, Method method) {
+        boolean fromWsdl = this.getServiceFactory().isFromWsdl();
         String ns = service.getName().getNamespaceURI();
         String local = method.getName();
-
+        
         QName name = new QName(ns, local);
+        
+        if (fromWsdl && service.getOperation(name) != null) {
+            //just matching the ops in the class to the ops on the wsdl
+            //probably should check the params and such
+            return name;
+        }
+        
         if (service.getOperation(name) == null) {
             return name;
         }
@@ -214,11 +226,62 @@
 
     @Override
     public Boolean isOutParam(Method method, int j) {
-        return j < 0;
+        if (j < 0) {
+            return Boolean.TRUE;
+        }
+        Class<?> cls = method.getParameterTypes()[j];
+        Type tp = method.getGenericParameterTypes()[j];
+        
+        return isHolder(cls, tp);
     }
 
     @Override
     public Boolean isWrapped(Method m) {
         return getServiceFactory().isWrapped();
     }
+    
+    @Override
+    public Boolean isHolder(Class<?> cls, Type type) {
+        if (cls.getSimpleName().equals("Holder")
+            && cls.getDeclaredFields().length == 1
+            && "value".equals(cls.getDeclaredFields()[0].getName())
+            && Modifier.isPublic(cls.getDeclaredFields()[0].getModifiers())) {
+            return Boolean.TRUE;
+        }
+        return Boolean.FALSE;
+    }
+    
+    @Override
+    public Class<?> getHolderType(Class<?> cls, Type type) {
+        
+        if (isHolder(cls, type)) {
+            if (type instanceof ParameterizedType) {
+                //JAX-WS style using generics       
+                ParameterizedType paramType = (ParameterizedType)type;
+                cls = getHolderClass(paramType);
+            } else {
+                //JAXRPC style of code generated holder
+                return cls.getDeclaredFields()[0].getType();
+            }
+        }
+
+        return null;
+    }   
+    
+    private static Class getHolderClass(ParameterizedType paramType) {
+        Object rawType = paramType.getActualTypeArguments()[0];
+        Class rawClass;
+        if (rawType instanceof GenericArrayType) {
+            rawClass = (Class)((GenericArrayType)rawType).getGenericComponentType();
+            rawClass = Array.newInstance(rawClass, 0).getClass();
+        } else {
+            if (rawType instanceof ParameterizedType) {
+                rawType = (Class)((ParameterizedType)rawType).getRawType();
+            }
+            rawClass = (Class)rawType;
+        }
+        return rawClass;
+    }
+
+    
 }

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=603807&r1=603806&r2=603807&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java Wed Dec 12 19:18:39 2007
@@ -20,11 +20,8 @@
 package org.apache.cxf.service.factory;
 
 import java.lang.annotation.Annotation;
-import java.lang.reflect.Array;
 import java.lang.reflect.Field;
-import java.lang.reflect.GenericArrayType;
 import java.lang.reflect.Method;
-import java.lang.reflect.ParameterizedType;
 import java.lang.reflect.Proxy;
 import java.lang.reflect.Type;
 import java.net.MalformedURLException;
@@ -44,12 +41,12 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+import javax.wsdl.Operation;
 import javax.xml.bind.annotation.XmlAttachmentRef;
 import javax.xml.bind.annotation.XmlList;
 import javax.xml.bind.annotation.XmlMimeType;
 import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
 import javax.xml.namespace.QName;
-import javax.xml.ws.Holder;
 
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.BindingFactoryManager;
@@ -67,6 +64,7 @@
 import org.apache.cxf.frontend.FaultInfoException;
 import org.apache.cxf.frontend.MethodDispatcher;
 import org.apache.cxf.frontend.SimpleMethodDispatcher;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.helpers.MethodComparator;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.interceptor.FaultOutInterceptor;
@@ -92,6 +90,7 @@
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.service.model.UnwrappedOperationInfo;
 import org.apache.cxf.wsdl.WSDLConstants;
+import org.apache.cxf.wsdl11.WSDLServiceBuilder;
 import org.apache.cxf.wsdl11.WSDLServiceFactory;
 import org.apache.ws.commons.schema.XmlSchema;
 import org.apache.ws.commons.schema.XmlSchemaComplexType;
@@ -326,7 +325,7 @@
         for (ServiceInfo si : getService().getServiceInfos()) {
             Set<?> wrapperClasses = this.getExtraClass();
             if (wrapperClasses != null) {
-                serviceInfo.setProperty(EXTRA_CLASS, wrapperClasses);
+                si.setProperty(EXTRA_CLASS, wrapperClasses);
             }
         }
         
@@ -519,11 +518,161 @@
         }
     }
 
-    protected void initializeWSDLOperation(InterfaceInfo intf, OperationInfo o, Method selected) {
-        // TODO Auto-generated method stub
-
+    protected void initializeWSDLOperation(InterfaceInfo intf, OperationInfo o, Method method) {
+        // rpc out-message-part-info class mapping
+        Operation op = (Operation)o.getProperty(WSDLServiceBuilder.WSDL_OPERATION);
+
+        if (initializeClassInfo(o, method, op == null ? null
+            : CastUtils.cast(op.getParameterOrdering(), String.class))) {
+            getMethodDispatcher().bind(o, method);
+        } else {
+            LOG.log(Level.WARNING, "NO_METHOD_FOR_OP", o.getName());
+        }
     }
+    
+    /**
+     * set the holder generic type info into message part info
+     *
+     * @param o
+     * @param method
+     */
+    protected boolean initializeClassInfo(OperationInfo o, Method method, List<String> paramOrder) {
+        if (isWrapped(method)) {
+            if (o.getUnwrappedOperation() == null) {
+                //the "normal" algorithm didn't allow for unwrapping,
+                //but the annotations say unwrap this.   We'll need to
+                //make it.
+                WSDLServiceBuilder.checkForWrapped(o, true);
+            }
+
+            if (o.hasInput()) {
+                MessageInfo input = o.getInput();
+                MessagePartInfo part = input.getMessageParts().get(0);
+                part.setTypeClass(getRequestWrapper(method));
+                part.setProperty("REQUEST.WRAPPER.CLASSNAME", getRequestWrapperClassName(method));
+                part.setIndex(0);
+            }
+
+            if (o.hasOutput()) {
+                MessageInfo input = o.getOutput();
+                MessagePartInfo part = input.getMessageParts().get(0);
+                part.setTypeClass(getResponseWrapper(method));
+                part.setProperty("RESPONSE.WRAPPER.CLASSNAME", getResponseWrapperClassName(method));
+                part.setIndex(0);
+            }
+
+            setFaultClassInfo(o, method);
+            o = o.getUnwrappedOperation();
+        } else if (o.isUnwrappedCapable()) {
+            // remove the unwrapped operation because it will break the
+            // the WrapperClassOutInterceptor, and in general makes
+            // life more confusing
+            o.setUnwrappedOperation(null);
+
+            setFaultClassInfo(o, method);
+        }
 
+        Class<?>[] paramTypes = method.getParameterTypes();
+        Type[] genericTypes = method.getGenericParameterTypes();
+        for (int i = 0; i < paramTypes.length; i++) {
+            if (Exchange.class.equals(paramTypes[i])) {
+                continue;
+            }
+            Class paramType = paramTypes[i];
+            Type genericType = genericTypes[i];
+            if (!initializeParameter(o, method, i, paramType, genericType)) {
+                return false;
+            }
+        }
+
+        // Initialize return type
+        Class paramType = method.getReturnType();
+        Type genericType = method.getGenericReturnType();
+
+        if (!initializeParameter(o, method, -1, paramType, genericType)) {
+            return false;
+        }
+
+        setFaultClassInfo(o, method);
+        return true;
+    }    
+    private boolean initializeParameter(OperationInfo o, Method method, int i,
+                                     Class paramType, Type genericType) {
+        boolean isIn = isInParam(method, i);
+        boolean isOut = isOutParam(method, i);
+
+        MessagePartInfo part = null;
+        if (isIn && !isOut) {
+            QName name = getInPartName(o, method, i);
+            part = o.getInput().getMessagePart(name);
+            if (part == null && isFromWsdl()) {
+                part = o.getInput().getMessagePartByIndex(i);
+            }
+            if (part == null) {
+                return false;
+            }
+            initializeParameter(part, paramType, genericType);
+            part.setIndex(i);
+        } else if (!isIn && isOut) {
+            QName name = getOutPartName(o, method, i);
+            part = o.getOutput().getMessagePart(name);
+            if (part == null && isFromWsdl()) {
+                part = o.getOutput().getMessagePartByIndex(i + 1);
+            }
+            if (part == null) {
+                return false;
+            }
+            part.setProperty(ReflectionServiceFactoryBean.MODE_OUT, Boolean.TRUE);
+            initializeParameter(part, paramType, genericType);
+            part.setIndex(i + 1);
+        } else if (isIn && isOut) {
+            QName name = getInPartName(o, method, i);
+            part = o.getInput().getMessagePart(name);
+            if (part == null && this.isFromWsdl()) {
+                part = o.getInput().getMessagePartByIndex(i);
+            }
+            if (part == null) {
+                return false;
+            }
+            part.setProperty(ReflectionServiceFactoryBean.MODE_INOUT, Boolean.TRUE);
+            initializeParameter(part, paramType, genericType);
+            part.setIndex(i);
+
+            part = o.getOutput().getMessagePart(name);
+            if (part == null) {
+                return false;
+            }
+            part.setProperty(ReflectionServiceFactoryBean.MODE_INOUT, Boolean.TRUE);
+            initializeParameter(part, paramType, genericType);
+            part.setIndex(i + 1);
+        }
+        return true;
+    }    
+    private void setFaultClassInfo(OperationInfo o, Method selected) {
+        Class[] types = selected.getExceptionTypes();
+        for (int i = 0; i < types.length; i++) {
+            Class exClass = types[i];
+            Class beanClass = getBeanClass(exClass);
+
+            QName name = getFaultName(o.getInterface(), o, exClass, beanClass);
+
+            for (FaultInfo fi : o.getFaults()) {
+                for (MessagePartInfo mpi : fi.getMessageParts()) {
+                    String ns = null;
+                    if (mpi.isElement()) {
+                        ns = mpi.getElementQName().getNamespaceURI();
+                    } else {
+                        ns = mpi.getTypeQName().getNamespaceURI();
+                    }
+                    if (mpi.getConcreteName().getLocalPart().equals(name.getLocalPart())
+                        && name.getNamespaceURI().equals(ns)) {
+                        fi.setProperty(Class.class.getName(), exClass);
+                        mpi.setTypeClass(beanClass);
+                    }
+                }
+            }
+        }
+    }
     protected Invoker createInvoker() {
         return new FactoryInvoker(new LocalFactory(getServiceClass()), new ApplicationScopePolicy());
     }
@@ -1233,16 +1382,12 @@
         }
     }
 
-    // TODO: Remove reference to JAX-WS holder if possible
-    // We do need holder support in the simple frontend though as Aegis has its
-    // own
-    // holder class. I'll tackle refactoring this into a more generic way of
-    // handling
-    // holders in phase 2.
     protected void initializeParameter(MessagePartInfo part, Class rawClass, Type type) {
-        if (rawClass.equals(Holder.class) && type instanceof ParameterizedType) {
-            ParameterizedType paramType = (ParameterizedType)type;
-            rawClass = getHolderClass(paramType);
+        if (isHolder(rawClass, type)) {
+            Class<?> c = getHolderType(rawClass, type);
+            if (c != null) {
+                rawClass = c;
+            }
         }
         part.setProperty(GENERIC_TYPE, type);
         // if rawClass is List<String>, it will be converted to array
@@ -1253,20 +1398,6 @@
         part.setTypeClass(rawClass);
     }
 
-    protected Class getHolderClass(ParameterizedType paramType) {
-        Object rawType = paramType.getActualTypeArguments()[0];
-        Class rawClass;
-        if (rawType instanceof GenericArrayType) {
-            rawClass = (Class)((GenericArrayType)rawType).getGenericComponentType();
-            rawClass = Array.newInstance(rawClass, 0).getClass();
-        } else {
-            if (rawType instanceof ParameterizedType) {
-                rawType = (Class)((ParameterizedType)rawType).getRawType();
-            }
-            rawClass = (Class)rawType;
-        }
-        return rawClass;
-    }
 
     public QName getServiceQName() {
         if (serviceName == null) {
@@ -1308,7 +1439,7 @@
         }
         throw new IllegalStateException("ServiceConfiguration must provide a value!");
     }
-
+    
     protected String getServiceNamespace() {
         if (serviceName != null) {
             return serviceName.getNamespaceURI();
@@ -1342,7 +1473,27 @@
         }
         return true;
     }
-
+    
+    public boolean isHolder(Class<?> cls, Type type) {
+        for (AbstractServiceConfiguration c : serviceConfigurations) {
+            Boolean b = c.isHolder(cls, type);
+            if (b != null) {
+                return b.booleanValue();
+            }
+        }
+        return false;
+    }
+    
+    public Class<?> getHolderType(Class<?> cls, Type type) {
+        for (AbstractServiceConfiguration c : serviceConfigurations) {
+            Class<?> b = c.getHolderType(cls, type);
+            if (b != null) {
+                return b;
+            }
+        }
+        return null;
+    }
+    
     protected boolean isWrapped(final Method method) {
         for (AbstractServiceConfiguration c : serviceConfigurations) {
             Boolean b = c.isWrapped(method);

Modified: incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties?rev=603807&r1=603806&r2=603807&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties (original)
+++ incubator/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties Wed Dec 12 19:18:39 2007
@@ -25,3 +25,4 @@
   annotations on the real instance are not available.  We suggest overriding the ServiceClass via spring config or \
   other configuration. (serviceClass/implementorClass attributes on the endpoint/server spring config entry)
 REFERENCE_TO_UNDEFINED_TYPE = Schema element {0} references undefined type {1} for service {2}.
+COULD_NOT_FIND_PART = Could not find a message part matching name {0}.  Possible values are {1}.

Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java?rev=603807&r1=603806&r2=603807&view=diff
==============================================================================
--- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java (original)
+++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java Wed Dec 12 19:18:39 2007
@@ -38,6 +38,7 @@
 import org.apache.cxf.anonymous_complex_type.RefSplitNameResponse;
 import org.apache.cxf.anonymous_complex_type.SplitName;
 import org.apache.cxf.anonymous_complex_type.SplitNameResponse.Names;
+import org.apache.cxf.frontend.ClientProxyFactoryBean;
 import org.apache.cxf.jaxb_element_test.JaxbElementTest;
 import org.apache.cxf.jaxb_element_test.JaxbElementTest_Service;
 import org.apache.cxf.ordered_param_holder.ComplexStruct;
@@ -242,6 +243,25 @@
         runDocLitTest(port);
     }
     
+    @Test
+    public void testSimpleClientWithWsdl() throws Exception {
+        QName portName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService", 
+            "DocLitWrappedCodeFirstServicePort");
+        QName servName = new QName("http://cxf.apache.org/systest/jaxws/DocLitWrappedCodeFirstService", 
+            "DocLitWrappedCodeFirstService");
+        
+        ClientProxyFactoryBean factory = new ClientProxyFactoryBean();
+        factory.setWsdlURL(ServerMisc.DOCLIT_CODEFIRST_URL + "?wsdl");
+        factory.setServiceName(servName);
+        factory.setServiceClass(DocLitWrappedCodeFirstService.class);
+        factory.setEndpointName(portName);
+        
+        DocLitWrappedCodeFirstService port = (DocLitWrappedCodeFirstService) factory.create();        
+        assertNotNull(port);
+
+        String echoMsg = port.echo("Hello");
+        assertEquals("Hello", echoMsg);
+    }
     private void runDocLitTest(DocLitWrappedCodeFirstService port) throws Exception {
         assertEquals(24, port.echoIntDifferentWrapperName(24));