cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r604005 - in /incubator/cxf/branches/2.0.x-fixes: ./ 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/
Date Thu, 13 Dec 2007 19:46:06 GMT
Author: dkulp
Date: Thu Dec 13 11:46:05 2007
New Revision: 604005

URL: http://svn.apache.org/viewvc?rev=604005&view=rev
Log:
Merged revisions 603807 via svnmerge from 
https://svn.apache.org/repos/asf/incubator/cxf/trunk

........
  r603807 | dkulp | 2007-12-12 22:18:39 -0500 (Wed, 12 Dec 2007) | 2 lines
  
  [CXF-1297] Fix for problems with simple frontend clients not working with wsdl first cases
........

Modified:
    incubator/cxf/branches/2.0.x-fixes/   (props changed)
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties
    incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java

Propchange: incubator/cxf/branches/2.0.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java?rev=604005&r1=604004&r2=604005&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceConfiguration.java
Thu Dec 13 11:46:05 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;
@@ -683,5 +687,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/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java?rev=604005&r1=604004&r2=604005&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
Thu Dec 13 11:46:05 2007
@@ -25,7 +25,6 @@
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
-import java.util.logging.Logger;
 
 import javax.wsdl.Operation;
 import javax.xml.namespace.QName;
@@ -36,8 +35,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;
@@ -48,7 +45,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;
@@ -58,7 +54,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.wsdl11.WSDLServiceBuilder;
 
@@ -69,8 +64,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;
@@ -142,7 +135,6 @@
     @Override
     protected void initializeWSDLOperation(InterfaceInfo intf, OperationInfo o, Method method)
{
         method = ((JaxWsServiceConfiguration)jaxWsConfiguration).getDeclaredMethod(method);
-        super.initializeWSDLOperation(intf, o, method);
 
         initializeWrapping(o, method);
 
@@ -265,31 +257,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) {
@@ -318,117 +286,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/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties?rev=604005&r1=604004&r2=604005&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/Messages.properties
Thu Dec 13 11:46:05 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/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java?rev=604005&r1=604004&r2=604005&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/AbstractServiceConfiguration.java
Thu Dec 13 11:46:05 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/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java?rev=604005&r1=604004&r2=604005&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/DefaultServiceConfiguration.java
Thu Dec 13 11:46:05 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/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=604005&r1=604004&r2=604005&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Thu Dec 13 11:46:05 2007
@@ -19,11 +19,8 @@
 
 package org.apache.cxf.service.factory;
 
-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;
@@ -41,8 +38,15 @@
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
+<<<<<<< .working
+=======
+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;
+>>>>>>> .merge-right.r603807
 import javax.xml.namespace.QName;
-import javax.xml.ws.Holder;
 
 import org.apache.cxf.BusException;
 import org.apache.cxf.binding.BindingFactoryManager;
@@ -57,6 +61,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;
@@ -82,6 +87,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;
@@ -494,11 +500,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());
     }
@@ -1166,36 +1322,18 @@
         }
     }
 
-    // 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);
         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) {
@@ -1237,7 +1375,7 @@
         }
         throw new IllegalStateException("ServiceConfiguration must provide a value!");
     }
-
+    
     protected String getServiceNamespace() {
         if (serviceName != null) {
             return serviceName.getNamespaceURI();
@@ -1271,7 +1409,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/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties?rev=604005&r1=604004&r2=604005&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties
(original)
+++ incubator/cxf/branches/2.0.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/SimpleMessages.properties
Thu Dec 13 11:46:05 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/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java?rev=604005&r1=604004&r2=604005&view=diff
==============================================================================
--- incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
(original)
+++ incubator/cxf/branches/2.0.x-fixes/systests/src/test/java/org/apache/cxf/systest/jaxws/ClientServerMiscTest.java
Thu Dec 13 11:46:05 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));
         



Mime
View raw message