axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sc...@apache.org
Subject cvs commit: xml-axis/java/test/wsdl/wrapped City_BBBBindingImpl.java City_BBBTestCase.java
Date Sat, 20 Jul 2002 00:30:21 GMT
scheu       2002/07/19 17:30:21

  Modified:    java/src/org/apache/axis/client Call.java
               java/src/org/apache/axis/description ServiceDesc.java
               java/src/org/apache/axis/encoding MethodTarget.java
               java/src/org/apache/axis/message MessageElement.java
                        RPCElement.java RPCHandler.java RPCParam.java
               java/src/org/apache/axis/providers/java RPCProvider.java
               java/src/org/apache/axis/utils JavaUtils.java
               java/src/org/apache/axis/wsdl/fromJava Emitter.java
               java/src/org/apache/axis/wsdl/toJava JavaDeployWriter.java
                        JavaSkelWriter.java JavaStubWriter.java
               java/test/wsdl/wrapped City_BBBBindingImpl.java
                        City_BBBTestCase.java
  Log:
  Changes to the implementation of the <element maxOccurs="unbounded">
  due to:
    a) Problems with ServiceDesc sync'ing up the operation.
    b) Glen did not like the post-combining of the RPCParams
    c) I want to eliminate the generation of Collection QNames.
       (i.e. The Stubs/Skeleton/Deploy generators will never
       generate QNames like the following "xsd:string[unbounded]".)
       Instead the QName of the component type is used...the type
       actually flowed across the wire.)
  
       So if you have a wrapped operation and you want to flow foo Strings like:
           <method>
             <foo>1</foo>
             <foo>2</foo>
           </method>
       then use:
          call.addParameter(<foo QName>, <xsd:string QName>, String[], IN)
       Likewise the skeleton and deploy.wsdd will use <xsd:string> as the
       the typeQName.
  
  The following changes are made:
    1) Removed the parts of the implementation that offended Glen.
  
    2) Changed JavaUtils.convert(arg, destClass).  If the
       destClass is an array, and the argument is a suitable
       component, the convert method will return an array
       containing the arg.
       ** Note this is necessary to automatically have
       a String argument converted into a String[] for
       <element maxOccurs="unbounded"> situations.
  
    3) Similar change to JavaUtils.isConvertable().
  
    4) Changed RPCParam.  The value field is now private
       and the deserializer updates the field via the
       new set method.  This is necessary to support
       an RPCParam with multiple values
       (like the <element maxOccurs="unbounded"> case.
       The RPCParam value is converted into an ArrayList
       (as necessary) to keep track of multiple values.
  
    5) RPCHandler is changed to use the same RPCParam
       object if the new child has the same QName as the
       last child.  This will cause multiple set(Object)
       calls on the RPCParam...see (4).
       Added a startElement method to properly reset
       the currentParam variable to avoid corruption when the
       RPCHandler is re-used.
  
    6) Changed Stub/Skeleton/Deploy generators to use
       the component QName in all places where the
       Collection QName was being generated.
  
    7) No logical change to ServiceDesc.  The ServiceDesc
       may see a ParameterDesc that has "xsd:string"
       as the type QName.  It will successfully match
       this with an actual parameter that has javaType String[]
       (due to (3)).  Thus the collection processing will
       automatically occur without relying on special
       Collection QNames.  Very Cool and useful.
  
       Note that I added some developer notes to ServiceDesc
       to help explain the various sync scenarios.  I also
       moved two setJavaType assignments outside the conditional
       bodies to improve the flow.
  
    8) Added a few more tests to the City_BBB test that
       test the same kind of things as the TCK.
  
    9) Verified this processing with the JAXRPC TCK doc/lit tests.
  
  Revision  Changes    Path
  1.160     +0 -3      xml-axis/java/src/org/apache/axis/client/Call.java
  
  Index: Call.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/Call.java,v
  retrieving revision 1.159
  retrieving revision 1.160
  diff -u -r1.159 -r1.160
  --- Call.java	18 Jul 2002 20:00:37 -0000	1.159
  +++ Call.java	20 Jul 2002 00:30:19 -0000	1.160
  @@ -1852,9 +1852,6 @@
           SOAPBodyElement bodyEl = resEnv.getFirstBody();
           if (bodyEl instanceof RPCElement) {
               try {
  -                // Combine the arguments for the same parameter 
  -                // and get the vector containing the result arguments.
  -                ((RPCElement) bodyEl).combineParams();
                   resArgs = ((RPCElement) bodyEl).getParams();
               } catch (Exception e) {
                   log.error(JavaUtils.getMessage("exception00"), e);
  
  
  
  1.42      +82 -8     xml-axis/java/src/org/apache/axis/description/ServiceDesc.java
  
  Index: ServiceDesc.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/description/ServiceDesc.java,v
  retrieving revision 1.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- ServiceDesc.java	19 Jul 2002 21:15:12 -0000	1.41
  +++ ServiceDesc.java	20 Jul 2002 00:30:19 -0000	1.42
  @@ -468,6 +468,71 @@
        */
       private void syncOperationToClass(OperationDesc oper, Class implClass)
       {
  +        // ------------------------------------------------
  +        // Developer Note:
  +        //
  +        // The goal of the sync code is to associate
  +        // the OperationDesc/ParamterDesc with the 
  +        // target Method.  There are a number of ways to get to this
  +        // point depending on what information
  +        // is available.  Here are the main scenarios:
  +        //
  +        // A) Deployment with wsdd (non-skeleton):
  +        //   * OperationDesc/ParameterDesc loaded from deploy.wsdd
  +        //   * Loaded ParameterDesc does not have javaType,
  +        //     so it is discovered using the TypeMappingRegistry
  +        //     (also loaded via deploy.wsdd) and the 
  +        //     typeQName specified by the ParameterDesc.
  +        //   * Sync occurs using the discovered
  +        //     javaTypes and the javaTypes of the Method
  +        //     parameters
  +        //
  +        // B) Deployment with no wsdd OperationDesc info (non-skeleton):
  +        //   * Implementation Class introspected to build 
  +        //     OperationDesc/ParameterDesc.
  +        //   * ParameterDesc is known via introspection.
  +        //   * ParameterDesc are discovered using javaType 
  +        //     and TypeMappingRegistry.
  +        //   * Sync occurs using the introspected
  +        //     javaTypes and the javaTypes of the Method
  +        //     parameters
  +        //
  +        // C) Deployment with wsdd (skeleton):
  +        //   * OperationDesc/ParameterDesc loaded from the Skeleton
  +        //   * In this scenario the ParameterDescs' already
  +        //     have javaTypes (see E below).
  +        //   * Sync occurs using the ParameterDesc
  +        //     javaTypes and the javaTypes of the Method 
  +        //     parameters.
  +        //
  +        // D) Commandline Java2WSDL loading non-Skeleton Class/Interface
  +        //   * Class/Interface introspected to build 
  +        //     OperationDesc/ParameterDesc.
  +        //   * The javaTypes of the ParameterDesc are set using introspection.  
  +        //   * typeQNames are determined for built-in types using
  +        //     from the default TypeMappingRegistry.  Other
  +        //     typeQNames are guessed from the javaType.  Note
  +        //     that there is no loaded TypeMappingRegistry.
  +        //   * Sync occurs using the ParameterDesc
  +        //     javaTypes and the javaTypes of the Method
  +        //     parameters.
  +        //
  +        // E) Commandline Java2WSDL loading Skeleton Class 
  +        //   * OperationDesc/ParameterDesc loaded from Skeleton
  +        //   * Each ParameterDesc has an appropriate typeQName
  +        //   * Each ParameterDesc also has a javaType, which is
  +        //     essential for sync'ing up with the
  +        //     method since there is no loaded TypeMappingRegistry.
  +        //   * Syncronization occurs using the ParameterDesc
  +        //     javaTypes and the javaTypes of the Method
  +        //     parameters.
  +        //
  +        // So in each scenario, the ultimate sync'ing occurs
  +        // using the javaTypes of the ParameterDescs and the
  +        // javaTypes of the Method parameters.
  +        // 
  +        // ------------------------------------------------
  +        
           // If we're already mapped to a Java method, no need to do anything.
           if (oper.getMethod() != null)
               return;
  @@ -491,17 +556,24 @@
                           heldType = JavaUtils.getHolderValueType(type);
                       }
                       ParameterDesc param = oper.getParameter(j);
  -                    // If no type is specified, just use the Java type
                       QName typeQName = param.getTypeQName();
                       if (typeQName == null) {
  +                        // No typeQName is available.  Set it using
  +                        // information from the held type.
  +                        // (Scenarios B and D)
  +                        // There is no need to try and match with
  +                        // the Method parameter javaType because
  +                        // the ParameterDesc is being constructed
  +                        // by introspecting the Method.
                           typeQName = tm.getTypeQName(heldType);
  -                        param.setJavaType(type);
                           param.setTypeQName(typeQName);
                       } else {
  -                        // A type qname was specified - see if they match
  -
  -                        // Use the specified javaType or get one
  -                        // from the type mapping registry.
  +                        // A type qname is available.
  +                        // Ensure that the ParameterDesc javaType
  +                        // is convertable to the Method parameter type
  +                        //
  +                        // Use the available javaType (Scenarios C and E)
  +                        // or get one from the TMR (Scenario A).
                           Class paramClass = param.getJavaType();
                           if (paramClass != null &&
                               JavaUtils.getHolderValueType(paramClass) != null) {
  @@ -517,9 +589,11 @@
                           if (!JavaUtils.isConvertable(paramClass, heldType)) {
                               break;
                           }
  -
  -                        param.setJavaType(type);
                       }
  +                    // In all scenarios the ParameterDesc javaType is set to
  +                    // match the javaType in the corresponding parameter.
  +                    // This is essential.
  +                    param.setJavaType(type);
                   }
   
                   if (j != paramTypes.length) {
  
  
  
  1.8       +21 -1     xml-axis/java/src/org/apache/axis/encoding/MethodTarget.java
  
  Index: MethodTarget.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/MethodTarget.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- MethodTarget.java	3 Jul 2002 17:50:26 -0000	1.7
  +++ MethodTarget.java	20 Jul 2002 00:30:20 -0000	1.8
  @@ -76,7 +76,23 @@
       private Object targetObject;
       private Method targetMethod;
       private static final Class [] objArg = new Class [] { Object.class };
  -    
  +
  +    /**
  +     * Construct a target whose value is set via a method
  +     * @param targetObject is the object containing the value to be set
  +     * @param targetMethod is the Method used to set the value
  +     */
  +    public MethodTarget(Object targetObject, Method targetMethod)
  +    {
  +        this.targetObject = targetObject;
  +        this.targetMethod = targetMethod;
  +    }
  +
  +    /**
  +     * Construct a target whose value is set via a method
  +     * @param targetObject is the object containing the value to be set
  +     * @param methodName is the name of the Method
  +     */
       public MethodTarget(Object targetObject, String methodName)
           throws NoSuchMethodException
       {
  @@ -85,6 +101,10 @@
           targetMethod = cls.getMethod(methodName, objArg);
       }
       
  +    /**
  +     * Set the target's value by invoking the targetMethod.
  +     * @param value is the new Object value
  +     */
       public void set(Object value) throws SAXException {
           try {
               targetMethod.invoke(targetObject, new Object [] { value });
  
  
  
  1.115     +0 -1      xml-axis/java/src/org/apache/axis/message/MessageElement.java
  
  Index: MessageElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/MessageElement.java,v
  retrieving revision 1.114
  retrieving revision 1.115
  diff -u -r1.114 -r1.115
  --- MessageElement.java	19 Jul 2002 10:30:58 -0000	1.114
  +++ MessageElement.java	20 Jul 2002 00:30:20 -0000	1.115
  @@ -1040,5 +1040,4 @@
       // setEncodingStyle implemented above
   
       // getEncodingStyle() implemented above
  -
   }
  
  
  
  1.66      +0 -74     xml-axis/java/src/org/apache/axis/message/RPCElement.java
  
  Index: RPCElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCElement.java,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- RPCElement.java	18 Jul 2002 20:00:37 -0000	1.65
  +++ RPCElement.java	20 Jul 2002 00:30:20 -0000	1.66
  @@ -285,80 +285,6 @@
           params.addElement(param);
       }
   
  -
  -    /**
  -     * Combines arguments associated with the same parameter
  -     * are combined into a single RPCParam.
  -     * Here is a specific example:
  -     *  <getAttractions xmlns="urn:CityBBB">
  -     *      <attname>Christmas</attname>
  -     *      <attname>Xmas</attname>
  -     *   </getAttractions>
  -     *
  -     *     for getAttractions(String[] attName)
  -     *
  -     * In the example, there will be two String for attName which
  -     * will be combined into one String[] argument
  -     */
  -    public void combineParams() throws Exception {
  -        getParams();  // ensure params are deserialized
  -
  -        for (int i=0; i<params.size(); i++) {
  -            RPCParam param = (RPCParam) params.elementAt(i);
  -            ParameterDesc parmDesc = param.getParamDesc();
  -            // See if the expected Type QName is 
  -            // a special collection QName like
  -            // "xsd:string[unbounded]"
  -            if (parmDesc != null &&
  -                parmDesc.getTypeQName() != null &&
  -                parmDesc.getTypeQName().
  -                getLocalPart().indexOf("[") > 0) {
  -
  -                // Count the number of params for the
  -                // same parameter
  -                int len = 1;
  -                for(int j=i+1; j<params.size(); j++) {
  -                    if (param.getQName().equals(
  -                     ((RPCParam)params.elementAt(j)).getQName())) {
  -                        len++;
  -                    } else {
  -                        break;
  -                    }
  -                }
  -
  -                // Create a container representing the 
  -                // expected parameter type and add the param's value
  -                Object container;
  -                Class containerClass = parmDesc.getJavaType();
  -
  -                if (containerClass.isArray()) {
  -                    container = 
  -                        Array.newInstance(containerClass.getComponentType(),
  -                                          len);
  -                    Array.set(container, 0, param.getValue());
  -                } else {
  -                    container = containerClass.newInstance();
  -                    ((Collection) container).add(param.getValue());
  -                }
  -
  -                // Replace the param value with the container
  -                param.setValue(container);
  -                
  -                // Add successive params to the container, and
  -                // remove the params from the original params vector.
  -                for (int j=1; j<len; j++) {
  -                    RPCParam nextParam = (RPCParam) params.elementAt(i+1);
  -                    if (containerClass.isArray()) {
  -                        Array.set(container, j, nextParam.getValue());
  -                    } else {
  -                        ((Collection) container).add(nextParam.getValue());
  -                    }
  -                    params.removeElementAt(i+1);
  -                }
  -            }
  -        }
  -    }
  -
       protected void outputImpl(SerializationContext context) throws Exception
       {
           MessageContext msgContext = context.getMessageContext();
  
  
  
  1.54      +51 -47    xml-axis/java/src/org/apache/axis/message/RPCHandler.java
  
  Index: RPCHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCHandler.java,v
  retrieving revision 1.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- RPCHandler.java	18 Jul 2002 20:00:37 -0000	1.53
  +++ RPCHandler.java	20 Jul 2002 00:30:20 -0000	1.54
  @@ -67,7 +67,7 @@
   import org.apache.axis.encoding.DeserializationContext;
   import org.apache.axis.encoding.Deserializer;
   import org.apache.axis.encoding.Deserializer;
  -import org.apache.axis.encoding.FieldTarget;
  +import org.apache.axis.encoding.MethodTarget;
   import org.apache.axis.encoding.DeserializerImpl;
   import org.apache.axis.utils.JavaUtils;
   
  @@ -101,7 +101,7 @@
           LogFactory.getLog(RPCHandler.class.getName());
       
       private RPCElement rpcElem;
  -    private RPCParam currentParam;
  +    private RPCParam currentParam = null;
       private boolean isResponse;
       private OperationDesc operation;
   
  @@ -117,6 +117,25 @@
       }
   
       /**
  +     * This method is invoked when an element start tag is encountered.
  +     * The purpose of this method in RPCHandler is to reset variables
  +     * (this allows re-use of RPCHandlers)
  +     * @param namespace is the namespace of the element
  +     * @param localName is the name of the element
  +     * @param qName is the prefixed qName of the element
  +     * @param attributes are the attributes on the element...used to get the type
  +     * @param context is the DeserializationContext
  +     */
  +    public void startElement(String namespace, String localName,
  +                             String qName, Attributes attributes,
  +                             DeserializationContext context)
  +        throws SAXException
  +    {
  +        super.startElement(namespace, localName, qName, attributes, context);
  +        currentParam = null;
  +    }
  +
  +    /**
        * Register the start of a parameter (child element of the method call
        * element).
        *
  @@ -145,16 +164,19 @@
           QName type = null;
           QName qname = new QName(namespace, localName);
           ParameterDesc paramDesc = null;
  -        boolean isCollection = false;
   
           Vector params = rpcElem.getParams();
           
           // SAR: for now, ignore RPC Result elements
           if (qname.equals(Constants.QNAME_RPC_RESULT)) return this;
   
  -        // This is a param.
  -        currentParam = new RPCParam(namespace, localName, null);
  -        rpcElem.addParam(currentParam);
  +        // Create a new param if not the same element
  +        if (currentParam == null ||
  +            !currentParam.getQName().getNamespaceURI().equals(namespace) ||
  +            !currentParam.getQName().getLocalPart().equals(localName)) {
  +            currentParam = new RPCParam(namespace, localName, null);
  +            rpcElem.addParam(currentParam);
  +        }
   
           // Grab xsi:type attribute if present, on either this element or
           // the referent (if it's an href).
  @@ -202,49 +224,14 @@
                   // (see RPCProvider.processMessage())
                   currentParam.setParamDesc(paramDesc);
   
  -                // It is possible that the type qname is "xsd:string"
  -                // and the paramDesc type is a collection of 
  -                // strings using a special axis qname ("xsd:string[unbounded]").
  -                // Here is a specific example:
  -                //  <getAttractions xmlns="urn:CityBBB">
  -                //      <attname>Christmas</attname>
  -                //      <attname>Xmas</attname>
  -                //   </getAttractions>
  -                //
  -                //  for getAttractions(String[] attName)
  -                //
  -                //  In the example, we are processing one of the <attname>
  -                //  children, so the type variable is set to the component
  -                //  type, and isCollection is turned on to 
  -                //  indicate collection processing.
  -                boolean haveXSIType = (type != null);
  -                if (paramDesc.getTypeQName() != null &&
  -                    paramDesc.getTypeQName().getLocalPart().indexOf("[") > 0) {
  -                    if (type==null) {
  -                        type = new QName(paramDesc.getTypeQName().
  -                                           getNamespaceURI(),
  -                                         paramDesc.getTypeQName().
  -                                           getLocalPart().
  -                                           substring(0,
  -                                                     paramDesc.getTypeQName().
  -                                                     getLocalPart().indexOf("[")));
  -                    }
  -                    isCollection = true;
  -                }
  -                
                   if (type == null) {
                       type = paramDesc.getTypeQName();
  -                } 
  -
  -                if (haveXSIType && paramDesc.getJavaType() != null) {
  +                } else if (paramDesc.getJavaType() != null) {
                       // If we have an xsi:type, make sure it makes sense
                       // with the current paramDesc type
                       Class xsiClass = 
                               context.getTypeMapping().getClassForQName(type);
                       Class destClass = paramDesc.getJavaType();
  -                    if (isCollection) {
  -                        destClass = destClass.getComponentType();
  -                    }
                       if (!JavaUtils.isConvertable(xsiClass, destClass)) {
                           throw new SAXException("Bad types (" +
                               xsiClass + " -> " + destClass + ")"); // FIXME!
  @@ -253,9 +240,26 @@
               }
           }
   
  -
  -        if (JavaUtils.isTrueExplicitly(attributes.getValue(Constants.URI_2001_SCHEMA_XSI,
"nil")))
  -          return new DeserializerImpl();
  +        // If the nil attribute is set, just
  +        // return the base DeserializerImpl.
  +        // Register the value target to set the value
  +        // on the RPCParam.  This is necessary for cases like
  +        //  <method>
  +        //    <foo>123</foo>
  +        //    <foo>456</foo>
  +        //    <foo xsi:nil="true" />
  +        //  </method>
  +        // so that a list of 3 items is created.
  +        // Failure to register the target would result in the last
  +        // item not being added to the list
  +        if (JavaUtils.isTrueExplicitly(
  +           attributes.getValue(Constants.URI_2001_SCHEMA_XSI, "nil"))) {
  +          Deserializer nilDSer =  new DeserializerImpl();
  +          nilDSer.registerValueTarget(
  +             new MethodTarget(currentParam,
  +                              RPCParam.getValueSetMethod()));
  +          return (SOAPHandler) nilDSer;
  +        }
           
           Deserializer dser = null;
           if ((type == null) && (namespace != null) && (!namespace.equals("")))
{
  @@ -277,8 +281,8 @@
           dser.setDefaultType(type);
   
           dser.registerValueTarget(
  -             new FieldTarget(currentParam,
  -                 RPCParam.getValueField()));
  +             new MethodTarget(currentParam,
  +                 RPCParam.getValueSetMethod()));
   
           if (log.isDebugEnabled()) {
               log.debug("Exit: RPCHandler.onStartChild()");
  
  
  
  1.43      +37 -8     xml-axis/java/src/org/apache/axis/message/RPCParam.java
  
  Index: RPCParam.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/RPCParam.java,v
  retrieving revision 1.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- RPCParam.java	3 Jul 2002 17:50:28 -0000	1.42
  +++ RPCParam.java	20 Jul 2002 00:30:20 -0000	1.43
  @@ -65,7 +65,8 @@
   import javax.xml.namespace.QName;
   
   import java.io.IOException;
  -import java.lang.reflect.Field;
  +import java.lang.reflect.Method;
  +import java.util.ArrayList;
   
   /** An RPC parameter
    *
  @@ -80,17 +81,18 @@
       RPCElement myCall;
       
       private QName qname;
  -    public Object value;
  +    private Object value = null;
  +    private int countSetCalls = 0; // counts number of calls to set
   
       private ParameterDesc paramDesc;
       private boolean wantXSIType = true;
   
  -    private static Field valueField;
  +    private static Method valueSetMethod;
       static {
           Class cls = RPCParam.class;
           try {
  -            valueField = cls.getField("value");
  -        } catch (NoSuchFieldException e) {
  +            valueSetMethod = cls.getMethod("set", new Class[] {Object.class});
  +        } catch (NoSuchMethodException e) {
               log.error(JavaUtils.getMessage("noValue00", "" + e));
               System.exit(-1);
           }
  @@ -130,7 +132,34 @@
       {
           this.value = value;
       }
  -    
  +
  +    /**
  +     * This set method is registered during deserialization
  +     * to set the deserialized value.
  +     * If the method is called multiple times, the 
  +     * value is automatically changed into a container to 
  +     * hold all of the values.
  +     * @param newValue is the deserialized object
  +     */
  +    public void set(Object newValue) {
  +        countSetCalls++;
  +        // If this is the first call,
  +        // simply set the value.
  +        if (countSetCalls==1) {
  +            this.value = newValue;
  +            return;
  +        }
  +        // If this is the second call, create an
  +        // ArrayList to hold all the values
  +        else if (countSetCalls==2) {
  +            ArrayList list = new ArrayList();
  +            list.add(this.value);
  +            this.value = list;
  +        } 
  +        // Add the new value to the list
  +        ((ArrayList) this.value).add(newValue);
  +    }
  +
       public String getName()
       {
           return this.qname.getLocalPart();
  @@ -141,9 +170,9 @@
           return this.qname;
       }
       
  -    public static Field getValueField()
  +    public static Method getValueSetMethod()
       {
  -        return valueField;
  +        return valueSetMethod;
       }
   
       public ParameterDesc getParamDesc() {
  
  
  
  1.77      +0 -3      xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java
  
  Index: RPCProvider.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/providers/java/RPCProvider.java,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- RPCProvider.java	18 Jul 2002 20:00:38 -0000	1.76
  +++ RPCProvider.java	20 Jul 2002 00:30:20 -0000	1.77
  @@ -188,9 +188,6 @@
           }
   
           String methodName = body.getMethodName();
  -        // Combine the arguments for the same parameter and 
  -        // get the vector containing the arguments
  -        body.combineParams();
           Vector args = body.getParams();
           int numArgs = args.size();
   
  
  
  
  1.60      +21 -3     xml-axis/java/src/org/apache/axis/utils/JavaUtils.java
  
  Index: JavaUtils.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/utils/JavaUtils.java,v
  retrieving revision 1.59
  retrieving revision 1.60
  diff -u -r1.59 -r1.60
  --- JavaUtils.java	3 Jul 2002 17:50:36 -0000	1.59
  +++ JavaUtils.java	20 Jul 2002 00:30:20 -0000	1.60
  @@ -235,6 +235,18 @@
               return new Hashtable((HashMap)arg);
           }
   
  +        // If the destination is an array and the source
  +        // is a suitable component, return an array with 
  +        // the single item.
  +        if (arg != null &&
  +            destClass.isArray() &&
  +            !destClass.getComponentType().equals(Object.class) &&
  +            destClass.getComponentType().isAssignableFrom(arg.getClass())) {
  +            Object array = 
  +                Array.newInstance(destClass.getComponentType(), 1);
  +            Array.set(array, 0, arg);
  +            return array;
  +        }
   
           // Return if no conversion is available
           if (!(arg instanceof Collection ||
  @@ -282,12 +294,12 @@
                       return destValue;
               }
           }
  -
  +        
           if (arg == null) {
               return arg;
           }
   
  -        // The arg may be an array or List
  +        // The arg may be an array or List 
           int length = 0;
           if (arg.getClass().isArray()) {
               length = Array.getLength(arg);
  @@ -410,11 +422,17 @@
                   (Collection.class.isAssignableFrom(dest) || dest.isArray()))
                   return true;
               
  +            // If destination is an array, and src is a component, we're good.
  +            if (dest.isArray() &&
  +                !dest.getComponentType().equals(Object.class) &&
  +                dest.getComponentType().isAssignableFrom(src)) 
  +                return true;
  +
               if ((src == Hex.class && dest == byte[].class) ||
                   (src == byte[].class && dest == Hex.class))
                   return true;
               
  -            // Allow mapping of HashMaps to Hasttables
  +            // Allow mapping of HashMaps to Hashtables
               if (src == HashMap.class && dest == Hashtable.class)
                   return true;
           }
  
  
  
  1.52      +1 -1      xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java
  
  Index: Emitter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/fromJava/Emitter.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- Emitter.java	19 Jul 2002 21:30:13 -0000	1.51
  +++ Emitter.java	20 Jul 2002 00:30:20 -0000	1.52
  @@ -686,7 +686,7 @@
   
               OperationDesc messageOper = thisOper;
               if (serviceDesc2 != null) {
  -                // If a serviceDesc contain an impl class is provided,
  +                // If a serviceDesc containing an impl class is provided,
                   // try and locate the corresponding operation
                   // (same name, same parm types and modes).  If a
                   // corresponding operation is found, it is sent
  
  
  
  1.51      +11 -9     xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java
  
  Index: JavaDeployWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaDeployWriter.java,v
  retrieving revision 1.50
  retrieving revision 1.51
  diff -u -r1.50 -r1.51
  --- JavaDeployWriter.java	21 Jun 2002 14:37:40 -0000	1.50
  +++ JavaDeployWriter.java	20 Jul 2002 00:30:20 -0000	1.51
  @@ -392,21 +392,23 @@
           Vector paramList = params.list;
           for (int i = 0; i < paramList.size(); i++) {
               Parameter param = (Parameter) paramList.elementAt(i);
  -            TypeEntry typeEntry = param.getType();
  -
  -            QName paramQName = null;
  -            QName paramType = null;
   
  -            // Get the parameter type QName
  +            // Get the typeEntry for the parameter.
  +            // Use the referenced type if an Element
  +            // Use the referenced type (the component type) if a Collection
  +            TypeEntry typeEntry = param.getType();
               if (typeEntry instanceof DefinedElement &&
                   typeEntry.getRefType() != null) {
  -                paramType = typeEntry.getRefType().getQName();
  -            } else {
  -                paramType = typeEntry.getQName();
  +                typeEntry = typeEntry.getRefType();
  +            } 
  +            if (typeEntry instanceof CollectionType &&
  +                typeEntry.getRefType() != null) {
  +                typeEntry = typeEntry.getRefType();
               }
   
               // Get the parameter name QName
  -            paramQName = param.getQName();
  +            QName paramQName = param.getQName();
  +            QName paramType = typeEntry.getQName();
   
               pw.print("        <parameter");
               if (paramQName == null || "".equals(paramQName.getNamespaceURI())) {
  
  
  
  1.35      +17 -2     xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaSkelWriter.java
  
  Index: JavaSkelWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaSkelWriter.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- JavaSkelWriter.java	18 Jul 2002 21:06:30 -0000	1.34
  +++ JavaSkelWriter.java	20 Jul 2002 00:30:20 -0000	1.35
  @@ -76,6 +76,7 @@
   
   import org.apache.axis.wsdl.symbolTable.BindingEntry;
   import org.apache.axis.wsdl.symbolTable.Element;
  +import org.apache.axis.wsdl.symbolTable.CollectionType;
   import org.apache.axis.wsdl.symbolTable.Parameter;
   import org.apache.axis.wsdl.symbolTable.Parameters;
   import org.apache.axis.wsdl.symbolTable.SymbolTable;
  @@ -177,10 +178,24 @@
                                   JavaUtils.getMessage("badParmMode00", 
                                           (new Byte(p.getMode())).toString()));
                       }
  -                    // Construct a parameter with the parameter name, mode, type qname
  -                    // a type javaType.
  +                    // Construct a parameter with the parameter name, 
  +                    // mode, type qname and type javaType.
                       TypeEntry paramType = p.getType();
                       if (paramType instanceof Element && 
  +                        paramType.getRefType() != null) {
  +                        paramType = paramType.getRefType();
  +                    }
  +                    // For collections, set the paramType to the 
  +                    // component type QName.
  +                    // The javaType is the type expected by the method.
  +                    // So for example a parameter that takes a 
  +                    // collection type for
  +                    // <element name="A" type="xsd:string" maxOccurs="unbounded"/>
  +                    // will be 
  +                    // new ParameterDesc(<QName of A>, IN,
  +                    //                   <QName of xsd:string>,
  +                    //                   String[])
  +                    if (paramType instanceof CollectionType &&
                           paramType.getRefType() != null) {
                           paramType = paramType.getRefType();
                       }
  
  
  
  1.76      +36 -14    xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java
  
  Index: JavaStubWriter.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/wsdl/toJava/JavaStubWriter.java,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- JavaStubWriter.java	18 Jul 2002 20:00:38 -0000	1.75
  +++ JavaStubWriter.java	20 Jul 2002 00:30:20 -0000	1.76
  @@ -476,15 +476,26 @@
           for (int i = 0; i < parms.list.size(); ++i) {
               Parameter p = (Parameter) parms.list.get(i);
   
  -            // We need to use the Qname of the actual type, not the QName of the element
  +            // Get the TypeEntry of the actual type not the Element.
               TypeEntry type = p.getType();
  -            if (type instanceof DefinedElement
  -                    && type.getRefType() != null) {
  +            if (type instanceof DefinedElement &&
  +                type.getRefType() != null) {
                   type = type.getRefType();
               }
  -            QName qn = type.getQName();
  +            // Set the javaType to the name of the type
               String javaType = type.getName();
   
  +            // If the TypeEntry is a collectionType then
  +            // set use the QName of the componentType.
  +            // So for example if the following is the expected parameter:
  +            // <element name="A" type="xsd:string" maxOccurs="unbounded"/>
  +            // then the QName type is "xsd:string" and the javaType=String[]
  +            if (type instanceof CollectionType &&
  +                type.getRefType() != null) {
  +                type = type.getRefType();
  +            }
  +            QName qn = type.getQName();
  +
               if (javaType != null) {
                   javaType += ".class, ";
               } else {
  @@ -517,18 +528,29 @@
           }
           // set output type
           if (parms.returnType != null) {
  -            // We need to use the Qname of the actual type, not the QName of the element
  -            // Also get the corresponding javaType
  -            QName qn = parms.returnType.getQName();
  -            String javaType = parms.returnType.getName();
   
  -            if (parms.returnType instanceof DefinedElement) {
  -                TypeEntry type = ((DefinedElement) parms.returnType).getRefType();
  -                if (type != null && type.getQName() != null) {
  -                    qn = type.getQName();
  -                    javaType = type.getName();
  -                }
  +            // Get the TypeEntry of the actual type not the Element.
  +            TypeEntry returnTE = parms.returnType;
  +            if (returnTE instanceof DefinedElement &&
  +                returnTE.getRefType() != null) {
  +                returnTE = returnTE.getRefType();
               }
  +            // Set the javaType to the name of the type
  +            String javaType = returnTE.getName();
  +
  +            // If the return TypeEntry is a collectionType then
  +            // set the use the QName of the componentType.
  +            // So for example if the following is the expected return:
  +            // <element name="A" type="xsd:string" maxOccurs="unbounded"/>
  +            // this is generated:
  +            // setReturnType(<QName of xsd:string>, String[]);
  +            if (returnTE instanceof CollectionType &&
  +                returnTE.getRefType() != null) {
  +                returnTE = returnTE.getRefType();
  +            }
  +            
  +            // Get the QName and Java Class name
  +            QName qn = returnTE.getQName();
    
               String outputType = "new javax.xml.namespace.QName(\"" +
                   qn.getNamespaceURI() + "\", \"" +
  
  
  
  1.4       +7 -0      xml-axis/java/test/wsdl/wrapped/City_BBBBindingImpl.java
  
  Index: City_BBBBindingImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/wrapped/City_BBBBindingImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- City_BBBBindingImpl.java	18 Jul 2002 20:55:11 -0000	1.3
  +++ City_BBBBindingImpl.java	20 Jul 2002 00:30:20 -0000	1.4
  @@ -14,6 +14,13 @@
       public static final String OID_STRING = "Attraction@cityCF::1028:1028";
   
       public Attraction getAttraction(String attname) throws java.rmi.RemoteException {
  +        // The only acceptable attNames are Christmas and Xmas
  +        // Apparently no one ones to go to New Orleans for Mardi Gras. :-)
  +        if (attname == null ||
  +            !(attname.equals("Christmas") ||
  +              attname.equals("Xmas"))) {
  +            return null;
  +        }
           Attraction attraction = new Attraction();
           attraction.set_OID(OID_STRING);
           attraction.setFacts("New Orleans at Christmastime is a city with the best food
in the world, the best music" +
  
  
  
  1.4       +47 -0     xml-axis/java/test/wsdl/wrapped/City_BBBTestCase.java
  
  Index: City_BBBTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/wrapped/City_BBBTestCase.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- City_BBBTestCase.java	18 Jul 2002 20:55:11 -0000	1.3
  +++ City_BBBTestCase.java	20 Jul 2002 00:30:20 -0000	1.4
  @@ -76,5 +76,52 @@
               throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re);
           }
       }
  +
  +    public void test4CityBBBPortGetAttractions() {
  +        City_BBBPortType binding;
  +        try {
  +            binding = new City_BBBLocator().getCity_BBBPort();
  +        }
  +        catch (javax.xml.rpc.ServiceException jre) {
  +            throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught:
" + jre);
  +        }
  +        assertTrue("binding is null", binding != null);
  +
  +        try {
  +            // Invoke getAttractions with one input
  +            String[] attName = new String[] {"Christmas", null};
  +            Attraction[] value = binding.getAttractions(attName);
  +            assertEquals("Expected returned Attraction length of 2", value.length, 2);
  +            assertEquals("OID value was wrong for first attraction", value[0].get_OID(),
  +                         City_BBBBindingImpl.OID_STRING);
  +            assertEquals("Attracton[1] should be null", value[1], null);
  +        }
  +        catch (java.rmi.RemoteException re) {
  +            throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re);
  +        }
  +    }
  +    public void test5CityBBBPortGetAttractions() {
  +        City_BBBPortType binding;
  +        try {
  +            binding = new City_BBBLocator().getCity_BBBPort();
  +        }
  +        catch (javax.xml.rpc.ServiceException jre) {
  +            throw new junit.framework.AssertionFailedError("JAX-RPC ServiceException caught:
" + jre);
  +        }
  +        assertTrue("binding is null", binding != null);
  +
  +        try {
  +            // Invoke getAttractions with one input
  +            String[] attName = new String[] {"Christmas", ""};
  +            Attraction[] value = binding.getAttractions(attName);
  +            assertEquals("Expected returned Attraction length of 2", value.length, 2);
  +            assertEquals("OID value was wrong for first attraction", value[0].get_OID(),
  +                         City_BBBBindingImpl.OID_STRING);
  +            assertEquals("Attracton[1] should be null", value[1], null);
  +        }
  +        catch (java.rmi.RemoteException re) {
  +            throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re);
  +        }
  +    }
   }
   
  
  
  

Mime
View raw message