You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by tl...@apache.org on 2006/10/09 13:51:02 UTC

svn commit: r454345 - in /incubator/cxf/trunk: rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/ rt/core/src/main/java/org/apache/cxf/wsdl11/ rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/ testutils/

Author: tli
Date: Mon Oct  9 04:51:01 2006
New Revision: 454345

URL: http://svn.apache.org/viewvc?view=rev&rev=454345
Log:
fix parametorOrder bug in service model, fix rpc bug, add rpc-type-test code gen

Modified:
    incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java
    incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
    incubator/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/support/JaxWsServiceFactoryBean.java
    incubator/cxf/trunk/testutils/pom.xml

Modified: incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java?view=diff&rev=454345&r1=454344&r2=454345
==============================================================================
--- incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java (original)
+++ incubator/cxf/trunk/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/interceptor/RPCOutInterceptor.java Mon Oct  9 04:51:01 2006
@@ -74,18 +74,15 @@
             countParts = parts.size();
 
             if (countParts > 0) {
-                List<?> objs = (List<?>) message.getContent(List.class);
-                Object[] args = objs.toArray();
-                Object[] els = parts.toArray();
-
-                if (args.length != els.length) {
+                List<?> objs = (List<?>) message.getContent(List.class);                
+                if (objs.size() < parts.size()) {
                     message.setContent(Exception.class, new RuntimeException(
                                     "The number of arguments is not equal!"));
                 }
 
                 for (int idx = 0; idx < countParts; idx++) {
-                    Object arg = args[idx];
-                    MessagePartInfo part = (MessagePartInfo) els[idx];
+                    Object arg = objs.get(idx);
+                    MessagePartInfo part = (MessagePartInfo) parts.get(idx);
                     QName elName = getPartName(part);
                     dataWriter.write(arg, elName, message);
                 }

Modified: incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java?view=diff&rev=454345&r1=454344&r2=454345
==============================================================================
--- incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java (original)
+++ incubator/cxf/trunk/rt/core/src/main/java/org/apache/cxf/wsdl11/WSDLServiceBuilder.java Mon Oct  9 04:51:01 2006
@@ -480,7 +480,8 @@
     }
 
     private void buildMessage(AbstractMessageContainer minfo, Message msg, List paramOrder) {
-        for (Part part : cast(msg.getOrderedParts(paramOrder), Part.class)) {
+        List orderedParam = msg.getOrderedParts(paramOrder);
+        for (Part part : cast(orderedParam, Part.class)) {
             MessagePartInfo pi = minfo.addMessagePart(part.getName());
             if (part.getTypeName() != null) {
                 pi.setTypeQName(part.getTypeName());
@@ -490,6 +491,18 @@
                 pi.setIsElement(true);
             }
         }
-    }
+        for (Part part : cast(msg.getParts().values(), Part.class)) {
+            if (!orderedParam.contains(part)) {
+                MessagePartInfo pi = minfo.addMessagePart(part.getName());
+                if (part.getTypeName() != null) {
+                    pi.setTypeQName(part.getTypeName());
+                    pi.setIsElement(false);
+                } else {
+                    pi.setElementQName(part.getElementName());
+                    pi.setIsElement(true);
+                }                
+            }
+        }
+    }    
 
 }

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?view=diff&rev=454345&r1=454344&r2=454345
==============================================================================
--- 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 Mon Oct  9 04:51:01 2006
@@ -27,6 +27,7 @@
 import java.util.Arrays;
 import java.util.List;
 
+import javax.wsdl.Operation;
 import javax.xml.bind.JAXBException;
 import javax.xml.ws.AsyncHandler;
 import javax.xml.ws.Holder;
@@ -45,12 +46,14 @@
 import org.apache.cxf.service.model.InterfaceInfo;
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.service.model.OperationInfo;
+import org.apache.cxf.wsdl11.WSDLServiceBuilder;
 
 public class JaxWsServiceFactoryBean extends ReflectionServiceFactoryBean {
 
     public static final String MODE_OUT = "messagepart.mode.out";
+
     public static final String MODE_INOUT = "messagepart.mode.inout";
-    
+
     public static final String HOLDER = "messagepart.isholder";
 
     private JAXBDataBinding dataBinding;
@@ -63,31 +66,31 @@
         jaxWsConfiguration = new JaxWsServiceConfiguration();
         getServiceConfigurations().add(0, jaxWsConfiguration);
     }
-    
+
     public JaxWsServiceFactoryBean(JaxWsImplementorInfo implInfo) {
         this();
         this.jaxWsImplementorInfo = implInfo;
         this.serviceClass = implInfo.getImplementorClass();
     }
-    
+
     @Override
     public void setServiceClass(Class<?> serviceClass) {
         if (jaxWsImplementorInfo == null) {
             jaxWsImplementorInfo = new JaxWsImplementorInfo(serviceClass);
         }
-        
+
         super.setServiceClass(serviceClass);
     }
 
     @Override
     protected void initializeDefaultInterceptors() {
         super.initializeDefaultInterceptors();
-        
+
         getService().getOutFaultInterceptors().add(new WebFaultOutInterceptor());
     }
 
     @Override
-    protected Endpoint createEndpoint(EndpointInfo ei) throws EndpointException  {
+    protected Endpoint createEndpoint(EndpointInfo ei) throws EndpointException {
         return new JaxWsEndpointImpl(getBus(), getService(), ei);
     }
 
@@ -95,22 +98,21 @@
     @Override
     protected void initializeWSDLOperation(InterfaceInfo intf, OperationInfo o, Method method) {
         method = jaxWsConfiguration.getDeclaredMethod(method);
-        
+
         super.initializeWSDLOperation(intf, o, method);
 
         initializeWrapping(o, method);
-        
+
         try {
             // Find the Async method which returns a Response
-            Method responseMethod = method.getDeclaringClass().getDeclaredMethod(method.getName() + "Async", 
-                                                                              method.getParameterTypes());
+            Method responseMethod = method.getDeclaringClass().getDeclaredMethod(method.getName() + "Async",
+                    method.getParameterTypes());
 
-            
             // Find the Async method whic has a Future & AsyncResultHandler
             List<Class<?>> asyncHandlerParams = new ArrayList(Arrays.asList(method.getParameterTypes()));
             asyncHandlerParams.add(AsyncHandler.class);
-            Method futureMethod = method.getDeclaringClass().getDeclaredMethod(method.getName() + "Async", 
-                asyncHandlerParams.toArray(new Class<?>[asyncHandlerParams.size()]));
+            Method futureMethod = method.getDeclaringClass().getDeclaredMethod(method.getName() + "Async",
+                    asyncHandlerParams.toArray(new Class<?>[asyncHandlerParams.size()]));
 
             getMethodDispatcher().bind(o, method, responseMethod, futureMethod);
 
@@ -119,70 +121,94 @@
         } catch (NoSuchMethodException e) {
             getMethodDispatcher().bind(o, method);
         }
-        
+
         // rpc out-message-part-info class mapping
-        initalizeClassInfo(o, method);
+        Operation op = (Operation)o.getProperty(WSDLServiceBuilder.WSDL_OPERATION);
+        initalizeClassInfo(o, method, op == null ? null : op.getParameterOrdering());
+
     }
 
+
     void initializeWrapping(OperationInfo o, Method selected) {
         Class responseWrapper = getResponseWrapper(selected);
         if (responseWrapper != null) {
             o.getUnwrappedOperation().getOutput().setProperty(WrapperClassOutInterceptor.WRAPPER_CLASS,
-                                                              responseWrapper);
+                    responseWrapper);
         }
         Class<?> requestWrapper = getRequestWrapper(selected);
         if (requestWrapper != null) {
             o.getUnwrappedOperation().getInput().setProperty(WrappedInInterceptor.WRAPPER_CLASS,
-                                                             requestWrapper);
+                    requestWrapper);
         }
     }
 
     @Override
-    protected void initializeDataBindings() {   
+    protected void initializeDataBindings() {
         try {
             dataBinding = new JAXBDataBinding(jaxWsConfiguration.getEndpointClass());
         } catch (JAXBException e) {
             throw new ServiceConstructionException(e);
         }
-        
+
         setDataBinding(dataBinding);
 
         super.initializeDataBindings();
     }
 
+    
+    private void setInputClassInfo(OperationInfo o, Method selected) {
+        Object[] para = selected.getParameterTypes();
+        int inIdx = 0;
+        for (MessagePartInfo mpiIn : o.getInput().getMessageParts()) {
+            // check for sayHi() type no input param method
+            if (para.length > 0 && !para[inIdx].equals(Holder.class)) {
+                mpiIn.setProperty(Class.class.getName(), para[inIdx]);
+            }
+            inIdx++;
+        }        
+    }
+    
+    private void setFaultClassInfo(OperationInfo o, Method selected) {
+        for (FaultInfo fi : o.getFaults()) {
+            int i = 0;
+            Class<?> cls = selected.getExceptionTypes()[i];
+            fi.getMessagePartByIndex(0).setProperty(Class.class.getName(), cls);
+            if (cls.isAnnotationPresent(WebFault.class)) {
+                fi.getMessagePartByIndex(i).setProperty(WebFault.class.getName(), Boolean.TRUE);
+            }
+            i++;
+        }
+    }
     /**
      * set the holder generic type info into message part info
      * 
      * @param o
      * @param method
      */
-    protected void initalizeClassInfo(OperationInfo o, Method selected) {
+    protected void initalizeClassInfo(OperationInfo o, Method selected, List<String> paramOrder) {
         if (o.getOutput() == null) {
             return;
         }
         int outPartCount = o.getOutput().getMessageParts().size();
-        int inPartCount = o.getInput().getMessageParts().size();
-        Object[] para = selected.getParameterTypes();
+        int inPartCount = o.getInput().getMessageParts().size();        
         int outIdx = 0;
+        int offset = 0;
+        setInputClassInfo(o, selected);
         for (MessagePartInfo mpiOut : o.getOutput().getMessageParts()) {
             int inIdx = 0;
             boolean isInOut = false;
             MessagePartInfo mpiInHolder = null;
             Object[] paraType = selected.getGenericParameterTypes();
             for (MessagePartInfo mpiIn : o.getInput().getMessageParts()) {
-                // check for sayHi() type no input param method
-                if (para.length > 0 && !para[inIdx].equals(Holder.class)) {
-                    mpiIn.setProperty(Class.class.getName(), para[inIdx]);
-                }
                 if (mpiOut.getName().equals(mpiIn.getName())) {
                     if (mpiOut.isElement() && mpiIn.isElement()
                             && mpiOut.getElementQName().equals(mpiIn.getElementQName())) {
                         isInOut = true;
-                        mpiInHolder = mpiIn;                        
+                        mpiInHolder = mpiIn;
                     } else if (!mpiOut.isElement() && !mpiIn.isElement()
                             && mpiOut.getTypeQName().equals(mpiIn.getTypeQName())) {
                         isInOut = true;
-                        mpiInHolder = mpiIn;                        
+                        mpiInHolder = mpiIn;
                     }
                 }
                 if (isInOut) {
@@ -192,13 +218,15 @@
                     mpiInHolder.setProperty(Class.class.getName(), rawClass);
                     mpiOut.setProperty(JaxWsServiceFactoryBean.MODE_INOUT, Boolean.TRUE);
                     mpiInHolder.setProperty(JaxWsServiceFactoryBean.MODE_INOUT, Boolean.TRUE);
+                    offset++;
                     break;
                 }
                 inIdx++;
             }
             if (!isInOut) {
-                if (((Class) selected.getReturnType()).getName().equals("void")) {                    
-                    // to avoid <element name="..."><complexType/></element> in output message part
+                if (((Class) selected.getReturnType()).getName().equals("void")) {
+                    // to avoid <element name="..."><complexType/></element> in
+                    // output message part
                     if (paraType.length > inPartCount + outIdx) {
                         ParameterizedType paramType = (ParameterizedType) paraType[inPartCount + outIdx];
                         Class rawClass = getHolderClass(paramType, inPartCount + outIdx);
@@ -208,31 +236,30 @@
                 } else {
                     String local = mpiOut.isElement() ? mpiOut.getElementQName().getLocalPart() : mpiOut
                             .getTypeQName().getLocalPart();
-                    if ("return".equalsIgnoreCase(local) || outPartCount == 1) {
+                    if ("return".equalsIgnoreCase(mpiOut.getName().getLocalPart()) || outPartCount == 1) {
                         mpiOut.setProperty(Class.class.getName(), selected.getReturnType());
+                        offset++;
+                    } else {
+                        if (paramOrder != null && !paramOrder.contains(local)) {
+                            int idx = inPartCount + outIdx - offset;
+                            ParameterizedType paramType = (ParameterizedType) paraType[idx];
+                            Class rawClass = getHolderClass(paramType, idx);
+                            mpiOut.setProperty(Class.class.getName(), rawClass);
+                            mpiOut.setProperty(JaxWsServiceFactoryBean.MODE_OUT, Boolean.TRUE);
+                        }
                     }
-                    // revisit, is there any case that multi-out-parts and one part map to return type, 
-                    // some map to in-out-holder, some map to out-holder?
                 }
             }
             outIdx++;
         }
-        for (FaultInfo fi : o.getFaults()) {
-            int i = 0;
-            Class<?> cls = selected.getExceptionTypes()[i];
-            fi.getMessagePartByIndex(0).setProperty(Class.class.getName(), cls);
-            if (cls.isAnnotationPresent(WebFault.class)) {
-                fi.getMessagePartByIndex(i).setProperty(WebFault.class.getName(), Boolean.TRUE);
-            }
-            i++;
-        }
+        setFaultClassInfo(o, selected);
     }
-    
+
     private static Class getHolderClass(ParameterizedType paramType, int idx) {
         if (((Class) paramType.getRawType()).getName().equals("javax.xml.ws.Holder")) {
             Object rawType = paramType.getActualTypeArguments()[0];
             Class rawClass;
-            if (rawType instanceof GenericArrayType) {                
+            if (rawType instanceof GenericArrayType) {
                 rawClass = (Class) ((GenericArrayType) rawType).getGenericComponentType();
                 rawClass = Array.newInstance(rawClass, 0).getClass();
             } else {

Modified: incubator/cxf/trunk/testutils/pom.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/pom.xml?view=diff&rev=454345&r1=454344&r2=454345
==============================================================================
--- incubator/cxf/trunk/testutils/pom.xml (original)
+++ incubator/cxf/trunk/testutils/pom.xml Mon Oct  9 04:51:01 2006
@@ -103,6 +103,12 @@
                                     <param name="inc_xsd_path" expression="."/>
                                     <param name="use_style" expression="document"/>
                                 </xslt>
+                                <xslt style="${test.resources.dir}/wsdl/type_test/type_test_wsdl.xsl"
+                                      in="${test.resources.dir}/wsdl/type_test/type_test.xsd"
+                                      out="${generated.resources.test}/wsdl/type_test/type_test_rpclit.wsdl">
+                                    <param name="inc_xsd_path" expression="."/>
+                                    <param name="use_style" expression="rpc"/>
+                                </xslt>
                                 <xslt style="${test.resources.dir}/wsdl/type_test/type_test_xml_wsdl.xsl"
                                       in="${test.resources.dir}/wsdl/type_test/type_test.xsd"
                                       out="${generated.resources.test}/wsdl/type_test/type_test_xml.wsdl">
@@ -115,12 +121,6 @@
                                     <param name="inc_wsdl_path" expression="."/>
                                     <param name="use_style" expression="document"/>
                                     <param name="port" expression="9007"/>
-                                </xslt>
-                                <xslt style="${test.resources.dir}/wsdl/type_test/type_test_wsdl.xsl"
-                                      in="${test.resources.dir}/wsdl/type_test/type_test.xsd"
-                                      out="${generated.resources.test}/wsdl/type_test/type_test_rpclit.wsdl">
-                                    <param name="inc_xsd_path" expression="${generated.resources.test}/wsdl/type_test"/>
-                                    <param name="use_style" expression="rpc"/>
                                 </xslt>
                                 <xslt style="${test.resources.dir}/wsdl/type_test/type_test_soap_wsdl.xsl"
                                       in="${test.resources.dir}/wsdl/type_test/type_test.xsd"