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/types ComprehensiveTypes.wsdl
Date Fri, 14 Dec 2001 18:48:31 GMT
scheu       01/12/14 10:48:31

  Modified:    java/src/org/apache/axis/encoding ArraySerializer.java
               java/src/org/apache/axis/utils JavaUtils.java
               java/test/arrays ArrayTest.wsdl ArrayTestCase.java
                        PersonalInfoBookSOAPBindingImpl.java
               java/test/wsdl/types ComprehensiveTypes.wsdl
  Log:
  Added the support in ArraySerializer for arrays of arrays.
  This required the following changes:
     a) When serializing an array, need to set the arrayType to the full array name
        (i.e. int[][] not Array[]).
     b) During deserialization, need to recognize an array of arrays and
        use an ArrayList (disabled the "not supported" message).
     c) JavaUtils.convert does the proper assignment conversion between
        List objects and arrays.  This was improved to properly consider
        component types which may be arrays/lists.  In such cases the convert
        method is invoked recursively to deal with the component arrays.
  
  Updated the arrays test and the comprehensive test to verify.
  Also verified by viewing the wire format using tcpmon.
  
  Revision  Changes    Path
  1.27      +32 -8     xml-axis/java/src/org/apache/axis/encoding/ArraySerializer.java
  
  Index: ArraySerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ArraySerializer.java,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- ArraySerializer.java	2001/11/29 11:11:31	1.26
  +++ ArraySerializer.java	2001/12/14 18:48:31	1.27
  @@ -134,17 +134,22 @@
                       JavaUtils.getMessage("badArrayType00", "" + arrayTypeValue));
           }
   
  +        Class componentType = null;
           String componentTypeName =
                           arrayTypeValueLocalPart.substring(0, leftBracketIndex);
  -
  +        
           if (componentTypeName.endsWith("]"))
           {
  -            throw new IllegalArgumentException(
  -                    JavaUtils.getMessage("noArrayArray00", "" + arrayTypeValue));
  +            // If the componentTypeName is an array, use soap_enc:Array
  +            // with a componentType of ArrayList.class
  +            arrayItemType = new QName(Constants.URI_SOAP_ENC, "Array");
  +            componentType = ArrayList.class;
  +            //throw new IllegalArgumentException(
  +            //        JavaUtils.getMessage("noArrayArray00", "" + arrayTypeValue));
           }
  -        
  -        arrayItemType = new QName(arrayTypeValueNamespaceURI,
  -                                  componentTypeName);
  +        else
  +            arrayItemType = new QName(arrayTypeValueNamespaceURI,
  +                                      componentTypeName);
   
           String lengthStr =
                          arrayTypeValueLocalPart.substring(leftBracketIndex + 1,
  @@ -161,13 +166,18 @@
               try
               {
                   length = Integer.parseInt(lengthStr);
  -                Class componentType = context.getTypeMappingRegistry().
  +
  +                // If the componentType was not already determined to be an 
  +                // array, go and get it.
  +                if (componentType == null)
  +                    componentType = context.getTypeMappingRegistry().
                                                 getClassForQName(arrayItemType);
                   
                   if (componentType == null)
                       throw new SAXException(
                               JavaUtils.getMessage("noComponent00",  "" + arrayItemType));
                   
  +                
                   ArrayList list = new ArrayList(length);
                   // ArrayList lacks a setSize(), so...
                   for (int i = 0; i < length; i++) {
  @@ -315,6 +325,20 @@
                   componentType = list.get(0).getClass();
               }
           }
  +
  +        // Check to see if componentType is also an array.
  +        // If so, set the componentType to the most nested non-array 
  +        // componentType.  Increase the dims string by "[]"
  +        // each time through the loop.  
  +        // Note from Rich Scheuerle:
  +        //    This won't handle Lists of Lists or
  +        //    arrays of Lists....only arrays of arrays.
  +        String dims = "";
  +        while (componentType.isArray()) {
  +            componentType = componentType.getComponentType();
  +            dims += "[]";
  +        }
  +
           
           QName componentQName = context.getQNameForClass(componentType);
           if (componentQName == null)
  @@ -324,7 +348,7 @@
           String arrayType = prefix + ":" + componentQName.getLocalPart();
           int len = (list == null) ? Array.getLength(value) : list.size();
           
  -        arrayType += "[" + len + "]";
  +        arrayType += dims + "[" + len + "]";
           
           Attributes attrs = attributes;
           
  
  
  
  1.15      +6 -2      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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- JavaUtils.java	2001/12/13 20:54:00	1.14
  +++ JavaUtils.java	2001/12/14 18:48:31	1.15
  @@ -117,8 +117,12 @@
                   } catch (Exception e) {
                       return arg;
                   }
  -                
  -                return list.toArray(array);
  +
  +                // Use convert to assign array elements.                        
  +                for (int i=0; i < length; i++) {
  +                    array[i] = convert(list.get(i), destClass.getComponentType()); 
  +                }
  +                return array;
               }
           }
           
  
  
  
  1.8       +93 -0     xml-axis/java/test/arrays/ArrayTest.wsdl
  
  Index: ArrayTest.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/arrays/ArrayTest.wsdl,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- ArrayTest.wsdl	2001/12/04 23:53:03	1.7
  +++ ArrayTest.wsdl	2001/12/14 18:48:31	1.8
  @@ -73,7 +73,50 @@
   
           </xsd:sequence>
         </xsd:complexType>
  +
  +    <!-- Arrays of arrays -->
  +      <xsd:complexType name="Array2">
  +        <xsd:complexContent>
  +          <xsd:restriction base="soapenc:Array">
  +            <xsd:sequence>
  +              <xsd:element name="alias" type="typens:intArray" maxOccurs="unbounded"/>
  +            </xsd:sequence>
  +          </xsd:restriction>
  +        </xsd:complexContent>
  +      </xsd:complexType>
  +
  +      <xsd:complexType name="Array3">
  +        <xsd:complexContent>
  +          <xsd:restriction base="soapenc:Array">
  +            <xsd:sequence>
  +              <xsd:element name="alias" type="typens:Array2" maxOccurs="unbounded"/>
  +            </xsd:sequence>
  +          </xsd:restriction>
  +        </xsd:complexContent>
  +      </xsd:complexType>
  +
  +    <!-- Arrays of arrays -->
  +      <xsd:complexType name="Array2S">
  +        <xsd:complexContent>
  +          <xsd:restriction base="soapenc:Array">
  +            <xsd:sequence>
  +              <xsd:element name="alias" type="typens:petArray" maxOccurs="unbounded"/>
  +            </xsd:sequence>
  +          </xsd:restriction>
  +        </xsd:complexContent>
  +      </xsd:complexType>
  +
  +      <xsd:complexType name="Array3S">
  +        <xsd:complexContent>
  +          <xsd:restriction base="soapenc:Array">
  +            <xsd:sequence>
  +              <xsd:element name="alias" type="typens:Array2S" maxOccurs="unbounded"/>
  +            </xsd:sequence>
  +          </xsd:restriction>
  +        </xsd:complexContent>
  +      </xsd:complexType>
       </xsd:schema>
  +
     </types>
   
     <!-- message declns -->
  @@ -114,6 +157,22 @@
       <part name="id" type="xsd:int"/>
     </message>
   
  +  <message name="Array3Request">
  +    <part name="in" type="typens:Array3"/>
  +  </message>
  +
  +  <message name="Array3Response">
  +    <part name="out" type="typens:Array3"/>
  +  </message>
  +
  +  <message name="Array3SRequest">
  +    <part name="in" type="typens:Array3S"/>
  +  </message>
  +
  +  <message name="Array3SResponse">
  +    <part name="out" type="typens:Array3S"/>
  +  </message>
  +
     <!-- port type declns -->
     <portType name="PersonalInfoBook">
       <operation name="addEntry">
  @@ -135,6 +194,14 @@
         <input message="tns:GetID2FromNameRequest"/>
         <output message="tns:GetID2FromNameResponse"/>
       </operation>
  +    <operation name="testArray3">
  +      <input message="tns:Array3Request"/>
  +      <output message="tns:Array3Response"/>
  +    </operation>
  +    <operation name="testArray3S">
  +      <input message="tns:Array3SRequest"/>
  +      <output message="tns:Array3SResponse"/>
  +    </operation>
     </portType>
   
     <!-- binding declns -->
  @@ -194,6 +261,32 @@
         </output>
       </operation>
       <operation name="getID2FromName">
  +      <soap:operation soapAction=""/>
  +      <input>
  +        <soap:body use="encoded"
  +                   namespace="urn:ArrayTest"
  +                   encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  +      </input>
  +      <output>
  +        <soap:body use="encoded"
  +                   namespace="urn:ArrayTest"
  +                   encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  +      </output>
  +    </operation>
  +    <operation name="testArray3">
  +      <soap:operation soapAction=""/>
  +      <input>
  +        <soap:body use="encoded"
  +                   namespace="urn:ArrayTest"
  +                   encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  +      </input>
  +      <output>
  +        <soap:body use="encoded"
  +                   namespace="urn:ArrayTest"
  +                   encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
  +      </output>
  +    </operation>
  +    <operation name="testArray3S">
         <soap:operation soapAction=""/>
         <input>
           <soap:body use="encoded"
  
  
  
  1.2       +87 -0     xml-axis/java/test/arrays/ArrayTestCase.java
  
  Index: ArrayTestCase.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/arrays/ArrayTestCase.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ArrayTestCase.java	2001/11/09 22:51:15	1.1
  +++ ArrayTestCase.java	2001/12/14 18:48:31	1.2
  @@ -85,6 +85,93 @@
               e.printStackTrace();
               throw new Exception("Fault returned from test: "+e);
           }
  +        
  +        // Multi-dimensional array tests
  +        test.arrays.PersonalInfoBook binding =
  +            new PersonalInfoBookService().getPersonalInfoBook();
  +        assertTrue("binding is null", binding != null);
  +        try {
  +            int[][][] one = new int[2][2][2];
  +            int[][][] two = new int[2][2][];
  +            two[0][0] = new int[1];
  +            two[1][0] = new int[2];
  +            two[0][1] = new int[3];
  +            two[1][1] = new int[4];
  +
  +            String[][][] oneS = new String[2][2][2];
  +            String[][][] twoS = new String[2][2][];
  +            twoS[0][0] = new String[1];
  +            twoS[1][0] = new String[2];
  +            twoS[0][1] = new String[3];
  +            twoS[1][1] = new String[4];
  +
  +            fill(one, oneS);
  +            fill(two, twoS);
  +
  +            int[][][] one_rc;
  +            int[][][] two_rc;
  +            String[][][] oneS_rc;
  +            String[][][] twoS_rc;
  +
  +            one_rc = binding.testArray3(one);
  +            assertTrue("testArray3 One Failed", verify(one, one_rc));
  +
  +            two_rc = binding.testArray3(two);
  +            assertTrue("testArray3 Two Failed", verify(two, two_rc));
  +
  +            oneS_rc = binding.testArray3S(oneS);
  +            assertTrue("testArray3S One Failed", verifyS(one, oneS_rc));
  +
  +            twoS_rc = binding.testArray3S(twoS);
  +            assertTrue("testArray3S Two Failed", verifyS(two, twoS_rc));
  +
  +        } catch (java.rmi.RemoteException re) {
  +            throw new junit.framework.AssertionFailedError("Remote Exception caught: "
+ re );
  +        }
  +
  +    }
  +
  +    public void fill(int[][][] array3, String[][][] array3S) {
  +        for (int i=0; i<array3.length; i++) {
  +            int[][] array2 = array3[i];
  +            for (int j=0; j<array2.length; j++) {
  +                int[] array = array2[j];
  +                for (int k=0; k<array.length; k++) {
  +                    array[k] = i + 10*j + 100*k;
  +                    array3S[i][j][k] = String.valueOf(array[k]);
  +                }
  +            }
  +        }
  +    }
  +
  +    public boolean verify(int[][][] array3, int[][][] check) {
  +        for (int i=0; i<array3.length; i++) {
  +            int[][] array2 = array3[i];
  +            for (int j=0; j<array2.length; j++) {
  +                int[] array = array2[j];
  +                for (int k=0; k<array.length; k++) {
  +                    // The service will add 1000 to each valid index
  +                    if (array[k] != (check[i][j][k] - 1000))
  +                        return false;
  +                }
  +            }
  +        }
  +        return true;
  +    }
  +
  +    public boolean verifyS(int[][][] array3, String[][][] check) {
  +        for (int i=0; i<array3.length; i++) {
  +            int[][] array2 = array3[i];
  +            for (int j=0; j<array2.length; j++) {
  +                int[] array = array2[j];
  +                for (int k=0; k<array.length; k++) {
  +                    // The service will add 1000 to each valid index
  +                    if (!String.valueOf(array[k]+1000).equals(check[i][j][k]))
  +                        return false;
  +                }
  +            }
  +        }
  +        return true;
       }
   }
   
  
  
  
  1.4       +30 -0     xml-axis/java/test/arrays/PersonalInfoBookSOAPBindingImpl.java
  
  Index: PersonalInfoBookSOAPBindingImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/arrays/PersonalInfoBookSOAPBindingImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- PersonalInfoBookSOAPBindingImpl.java	2001/12/04 23:53:03	1.3
  +++ PersonalInfoBookSOAPBindingImpl.java	2001/12/14 18:48:31	1.4
  @@ -25,4 +25,34 @@
       public int getID2FromName(java.lang.String name) throws java.rmi.RemoteException {
           return ((test.arrays.PersonalInfo) table.get(name)).getId2();
       }
  +    public int[][][] testArray3(int[][][] array3) throws java.rmi.RemoteException {
  +        for (int i=0; i<array3.length; i++) {
  +            int[][] array2 = array3[i];
  +            for (int j=0; j<array2.length; j++) {
  +                int[] array = array2[j];
  +                for (int k=0; k<array.length; k++) {
  +                    // Expecting a value that is the sum of i + 10*j + 100*k.
  +                    // If so increase by 1000
  +                    if (array[k] == i + 10*j + 100*k);
  +                    array[k] += 1000;
  +                }
  +            }
  +        }
  +        return array3;
  +    }
  +    public String[][][] testArray3S(String[][][] array3) throws java.rmi.RemoteException
{
  +        for (int i=0; i<array3.length; i++) {
  +            String[][] array2 = array3[i];
  +            for (int j=0; j<array2.length; j++) {
  +                String[] array = array2[j];
  +                for (int k=0; k<array.length; k++) {
  +                    // Expecting a value that is the sum of i + 10*j + 100*k.
  +                    // If so increase by 1000
  +                    if (array[k].equals(String.valueOf(i + 10*j + 100*k)))
  +                        array[k] = String.valueOf(i + 10*j + 100*k + 1000);
  +                }
  +            }
  +        }
  +        return array3;
  +    }
   }
  
  
  
  1.6       +1 -4      xml-axis/java/test/wsdl/types/ComprehensiveTypes.wsdl
  
  Index: ComprehensiveTypes.wsdl
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/wsdl/types/ComprehensiveTypes.wsdl,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ComprehensiveTypes.wsdl	2001/12/13 20:54:01	1.5
  +++ ComprehensiveTypes.wsdl	2001/12/14 18:48:31	1.6
  @@ -217,7 +217,6 @@
         <output message="tns:array"/>
       </operation>
   
  -    <!-- Multi-Dimensional Arrays currently don't work
       <operation name="arrayMIn">
         <input message="tns:arrayM"/>
         <output message="tns:empty"/>
  @@ -230,7 +229,7 @@
         <input message="tns:emptyM"/>
         <output message="tns:arrayM"/>
       </operation>
  -     -->
  +
       <operation name="complexAllIn">
         <input message="tns:complexAll"/>
         <output message="tns:empty"/>
  @@ -422,7 +421,6 @@
         </output>
       </operation>
   
  -    <!-- Multi-Dimensional Arrays currently don't work
       <operation name="arrayMIn">
         <soap:operation soapAction=""/>
         <input>
  @@ -468,7 +466,6 @@
               encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
         </output>
       </operation>
  -    -->
   
       <operation name="complexAllIn">
         <soap:operation soapAction=""/>
  
  
  

Mime
View raw message