You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Glen Daniels <gd...@macromedia.com> on 2002/09/05 03:50:57 UTC

RE: cvs commit: xml-axis/java/test/wsdl/wrapped CityBBB.wsdl City _BBBBindingImpl.java City_BBBTestCase.java

Nice work!  A couple of comments:

1) This fix, although functional, still has a 'bug' in that if the schema says:

<element name="param" type="xsd:String"/>

...for a parameter, we'd still be able to do a dynamic call.invoke() which passes a String[] instead of a String and get:

<param>String1</param>
<param>String2</param>

...which would be illegal according to the schema.  As mentioned on the chat earlier, this is nowhere near as big a deal, but something we should think about dealing with later.  For that matter, we should support validating minOccurs/maxOccurs in general.

2) (also noted to Rich on the chat) I still think the SerializationContext/DeserializationContext interfaces should go away.  We keep needing to make these little tweaks in two places, it causes another level of trace-through when dealing with dev tools, and (the big reason) the interfaces are way too specific to a particular way of doing things to make it worthwhile to implement them differently.  They should just be classes, and if it makes sense to turn pieces of their APIs into interfaces, we should do that where appropriate instead of just having the whole class API indirect through the iface.  That's my $0.02. :)

--Glen

> -----Original Message-----
> From: scheu@apache.org [mailto:scheu@apache.org]
> Sent: Wednesday, September 04, 2002 9:09 PM
> To: xml-axis-cvs@apache.org
> Subject: cvs commit: xml-axis/java/test/wsdl/wrapped CityBBB.wsdl
> City_BBBBindingImpl.java City_BBBTestCase.java
> 
> 
> scheu       2002/09/04 18:08:38
> 
>   Modified:    java     TODO.txt
>                java/src/org/apache/axis/encoding 
> SerializationContext.java
>                         SerializationContextImpl.java
>                java/src/org/apache/axis/encoding/ser 
> ArraySerializer.java
>                java/test/wsdl/wrapped CityBBB.wsdl 
> City_BBBBindingImpl.java
>                         City_BBBTestCase.java
>   Log:
>   Bug fix for document-literal array defect (10739)
>   
>   Worked with Glen to agree on an implementation.
>   
>   The ArraySerializer needs to know whether the array is
>   a normal SOAP-ENC:array or is the result of maxOccurs usage.
>   This information is known during SerializationContextImpl,
>   but not known within the ArraySerializer.
>   
>   The 'solution' is to remember the preferred xmlType during
>   SerializationContextImpl.  This information is queried
>   within the ArraySerializer using the new getCurrentXMLType()
>   method.  For the maxOccurs case, the current XMLType is
>   the same as the qname for the component of the array.  (For
>   the normal array case, the current XMLType is an actual array,
>   SOAP-ENC:Array or something else).
>   
>   Changed the code in ArraySerializer to properly generate
>   the message using the literal/encoded maxOccurs/normalArray 
> information.
>   
>   Also changed the wsdl/wrapped literal testcase to have both 
> kinds of usages.
>   getAttractions uses the maxOccurs method of passing the 
> input values.
>   getAttractions2 uses the array method of passing the input values.
>   
>   The test passes and I verified the messages with tcpmon.
>   
>   Revision  Changes    Path
>   1.74      +7 -7      xml-axis/java/TODO.txt
>   
>   Index: TODO.txt
>   ===================================================================
>   RCS file: /home/cvs/xml-axis/java/TODO.txt,v
>   retrieving revision 1.73
>   retrieving revision 1.74
>   diff -u -r1.73 -r1.74
>   --- TODO.txt	28 Aug 2002 16:03:37 -0000	1.73
>   +++ TODO.txt	5 Sep 2002 01:08:37 -0000	1.74
>   @@ -28,7 +28,7 @@
>    7407 - B
>    8419 - C
>    8435 - C
>   -8598 - E - Glen/Rich
>   +8598 - E - changed to WONTFIX
>    9393 - D
>    9452 - E
>    9473 - closed
>   @@ -52,7 +52,7 @@
>    10290 - closed
>    10355 - A
>    10365 - B
>   -10477 - C
>   +10477 - closed
>    10479 - B
>    10512 - B
>    10585 - NR
>   @@ -60,7 +60,7 @@
>    10605 - B - Tom
>    10613 - closed
>    10645 - C
>   -10739 - A
>   +10739 - A, closed
>    10841 - C
>    10847 - A
>    10853 - D
>   @@ -90,21 +90,21 @@
>    11595 - NR 
>    11622 - NR 
>    11690 - NR
>   -11706 - NR
>   -11707 - NR
>   +11706 - closed
>   +11707 - closed
>    11713 - NR
>    11718 - NR
>    11720 - NR
>    11726 - NR 
>    11766 - NR
>    11781 - NR
>   -11804 - NR
>   +11804 - presume fixed
>    11815 - NR
>    11855 - NR
>    11874 - NR 
>    11893 - NR
>    11923 - NR
>   -11945 - NR
>   +11945 - General Performance Question, need more specific info
>    12012 - NR
>    12055 - NR
>    
>   
>   
>   
>   1.82      +7 -0      
> xml-axis/java/src/org/apache/axis/encoding/SerializationContext.java
>   
>   Index: SerializationContext.java
>   ===================================================================
>   RCS file: 
> /home/cvs/xml-axis/java/src/org/apache/axis/encoding/Serializa
> tionContext.java,v
>   retrieving revision 1.81
>   retrieving revision 1.82
>   diff -u -r1.81 -r1.82
>   --- SerializationContext.java	16 Aug 2002 11:07:09 
> -0000	1.81
>   +++ SerializationContext.java	5 Sep 2002 01:08:37 
> -0000	1.82
>   @@ -319,6 +319,13 @@
>        public void writeDOMElement(Element el) throws IOException;
>    
>        public String getValueAsString(Object value, QName 
> xmlType) throws IOException;
>   +
>   +    /**
>   +     * Get the currently prefered xmlType
>   +     `* @return QName of xmlType or null
>   +     */
>   +    public QName getCurrentXMLType();
>   +
>    }
>    
>    
>   
>   
>   
>   1.64      +13 -0     
> xml-axis/java/src/org/apache/axis/encoding/SerializationContex
> tImpl.java
>   
>   Index: SerializationContextImpl.java
>   ===================================================================
>   RCS file: 
> /home/cvs/xml-axis/java/src/org/apache/axis/encoding/Serializa
> tionContextImpl.java,v
>   retrieving revision 1.63
>   retrieving revision 1.64
>   diff -u -r1.63 -r1.64
>   --- SerializationContextImpl.java	31 Aug 2002 11:27:33 
> -0000	1.63
>   +++ SerializationContextImpl.java	5 Sep 2002 01:08:37 
> -0000	1.64
>   @@ -118,6 +118,7 @@
>        private Writer writer;
>        private int lastPrefixIndex = 1;
>        private MessageContext msgContext;
>   +    private QName currentXMLType;
>    
>        /** The SOAP context we're using */
>        private SOAPConstants soapConstants = 
> SOAPConstants.SOAP11_CONSTANTS;
>   @@ -1177,6 +1178,11 @@
>                                                 "" + this));
>                }
>    
>   +            // Set currentXMLType to the one desired one.
>   +            // Note for maxOccurs usage this xmlType is the 
>   +            // type of the component not the type of the array.
>   +            currentXMLType = xmlType;
>   +
>                // if we're looking for xsd:anyType, accept anything...
>                if (Constants.XSD_ANYTYPE.equals(xmlType)) {
>                    xmlType = null;
>   @@ -1209,6 +1215,13 @@
>            // !!! Write out a generic null, or get type info 
> from somewhere else?
>        }
>    
>   +    /**
>   +     * Get the currently prefered xmlType
>   +     * @return QName of xmlType or null
>   +     */
>   +    public QName getCurrentXMLType() {
>   +        return currentXMLType;
>   +    }
>    
>        /**
>         * Walk the interfaces of a class looking for a 
> serializer for that
>   
>   
>   
>   1.31      +13 -7     
> xml-axis/java/src/org/apache/axis/encoding/ser/ArraySerializer.java
>   
>   Index: ArraySerializer.java
>   ===================================================================
>   RCS file: 
> /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/Array
> Serializer.java,v
>   retrieving revision 1.30
>   retrieving revision 1.31
>   diff -u -r1.30 -r1.31
>   --- ArraySerializer.java	25 Aug 2002 17:13:52 -0000	1.30
>   +++ ArraySerializer.java	5 Sep 2002 01:08:38 -0000	1.31
>   @@ -130,6 +130,7 @@
>                componentType = Object.class;
>            }
>    
>   +
>            // 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 "[]"
>   @@ -218,10 +219,16 @@
>                }
>            }
>    
>   +        // Need to distinguish if this is array processing for an
>   +        // actual schema array or for a maxOccurs usage.
>   +        // For the maxOccurs case, the currentXMLType of 
> the context is
>   +        // the same as the componentQName.
>   +        boolean maxOccursUsage = 
> componentQName.equals(context.getCurrentXMLType());
>   +
>            // Are we encoded?
>            boolean isEncoded = 
> context.getMessageContext().isEncoded();
>    
>   -        if (isEncoded) {
>   +        if (isEncoded && !maxOccursUsage) {
>                AttributesImpl attrs;
>                if (attributes == null) {
>                    attrs = new AttributesImpl();
>   @@ -272,12 +279,11 @@
>                attributes = attrs;
>            }
>    
>   -        // For non-encoded (literal) use, each item is 
> named with the QName
>   -        // we got in the arguments.  For encoded, we write 
> an element with
>   -        // that QName, and then each item is an <item> inside that.
>   +        // For the maxOccurs case, each item is named with 
> the QName
>   +        // we got in the arguments.  For normal array 
> case, we write an element with
>   +        // that QName, and then serialize each item as <item>
>            QName elementName = name;
>   -
>   -        if (isEncoded) {
>   +        if (!maxOccursUsage) {
>                context.startElement(name, attributes);
>                elementName = Constants.QNAME_LITERAL_ITEM;
>            }
>   @@ -316,7 +322,7 @@
>                }
>            }
>    
>   -        if (isEncoded)
>   +        if (!maxOccursUsage)
>                context.endElement();
>        }
>    
>   
>   
>   
>   1.3       +64 -0     xml-axis/java/test/wsdl/wrapped/CityBBB.wsdl
>   
>   Index: CityBBB.wsdl
>   ===================================================================
>   RCS file: /home/cvs/xml-axis/java/test/wsdl/wrapped/CityBBB.wsdl,v
>   retrieving revision 1.2
>   retrieving revision 1.3
>   diff -u -r1.2 -r1.3
>   --- CityBBB.wsdl	18 Jul 2002 20:00:38 -0000	1.2
>   +++ CityBBB.wsdl	5 Sep 2002 01:08:38 -0000	1.3
>   @@ -2,6 +2,8 @@
>    <definitions name="City_BBB" targetNamespace="urn:CityBBB"
>    xmlns="http://schemas.xmlsoap.org/wsdl/"
>    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>   +xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
>   +xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
>    xmlns:tns="urn:CityBBB" 
> xmlns:xsd="http://www.w3.org/2001/XMLSchema">
>      <types>
>        <xsd:schema attributeFormDefault="qualified"
>   @@ -24,6 +26,14 @@
>            </xsd:complexType>
>          </xsd:element>
>    
>   +      <xsd:element name="getAttractions2">
>   +        <xsd:complexType>
>   +          <xsd:sequence>
>   +            <xsd:element name="queryList" type="tns:QueryArray" />
>   +          </xsd:sequence>
>   +        </xsd:complexType>
>   +      </xsd:element>
>   +
>          <xsd:element name="getAttractionResponse">
>            <xsd:complexType>
>              <xsd:sequence>
>   @@ -42,6 +52,36 @@
>            </xsd:complexType>
>          </xsd:element>
>    
>   +      <xsd:element name="getAttractions2Response">
>   +        <xsd:complexType>
>   +          <xsd:sequence>
>   +            <xsd:element name="_return" 
> type="tns:AttractionArray" />
>   +          </xsd:sequence>
>   +        </xsd:complexType>
>   +      </xsd:element>
>   +
>   +      <xsd:complexType name="Query">
>   +        <xsd:sequence>
>   +          <xsd:element name="value" type="xsd:string" />
>   +        </xsd:sequence>
>   +      </xsd:complexType>
>   +
>   +      <xsd:complexType name="QueryArray">
>   +	  <xsd:complexContent>
>   +             <xsd:restriction base="soapenc:Array">
>   +                <xsd:attribute ref="soapenc:arrayType" 
> wsdl:arrayType="tns:Query[]"/> 
>   +             </xsd:restriction>
>   +          </xsd:complexContent>
>   +      </xsd:complexType>
>   + 
>   +      <xsd:complexType name="AttractionArray">
>   +	  <xsd:complexContent>
>   +             <xsd:restriction base="soapenc:Array">
>   +                <xsd:attribute ref="soapenc:arrayType" 
> wsdl:arrayType="tns:Attraction[]"/> 
>   +             </xsd:restriction>
>   +          </xsd:complexContent>
>   +      </xsd:complexType>
>   +  
>          <xsd:complexType name="Attraction">
>            <xsd:sequence>
>              <xsd:element maxOccurs="1" minOccurs="0" name="_OID"
>   @@ -151,6 +191,14 @@
>        <part element="tns:getAttractionsResponse" name="parameters" />
>      </message>
>    
>   +  <message name="getAttractions2In">
>   +    <part element="tns:getAttractions2" name="parameters" />
>   +  </message>
>   +
>   +  <message name="getAttractions2Out">
>   +    <part element="tns:getAttractions2Response" 
> name="parameters" />
>   +  </message>
>   +
>      <portType name="City_BBBPortType">
>        <operation name="getAttraction">
>          <input message="tns:getAttractionIn" />
>   @@ -162,6 +210,11 @@
>    
>          <output message="tns:getAttractionsOut" />
>        </operation>
>   +    <operation name="getAttractions2">
>   +      <input message="tns:getAttractions2In" />
>   +
>   +      <output message="tns:getAttractions2Out" />
>   +    </operation>
>      </portType>
>    
>      <binding name="City_BBBBinding" type="tns:City_BBBPortType">
>   @@ -181,6 +234,17 @@
>        </operation>
>        <operation name="getAttractions">
>          <soap:operation soapAction="getAttractions" />
>   +
>   +      <input>
>   +        <soap:body use="literal" />
>   +      </input>
>   +
>   +      <output>
>   +        <soap:body use="literal" />
>   +      </output>
>   +    </operation>
>   +    <operation name="getAttractions2">
>   +      <soap:operation soapAction="getAttractions2" />
>    
>          <input>
>            <soap:body use="literal" />
>   
>   
>   
>   1.5       +14 -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.4
>   retrieving revision 1.5
>   diff -u -r1.4 -r1.5
>   --- City_BBBBindingImpl.java	20 Jul 2002 00:30:20 
> -0000	1.4
>   +++ City_BBBBindingImpl.java	5 Sep 2002 01:08:38 
> -0000	1.5
>   @@ -9,6 +9,7 @@
>    
>    import test.wsdl.wrapped.City_BBBPortType;
>    import test.wsdl.wrapped.Attraction;
>   +import test.wsdl.wrapped.Query;
>    
>    public class City_BBBBindingImpl implements City_BBBPortType {
>        public static final String OID_STRING = 
> "Attraction@cityCF::1028:1028";
>   @@ -60,6 +61,19 @@
>                attractions = new Attraction[attnames.length]; 
>                for (int i=0; i < attnames.length; i++) {
>                    attractions[i] = getAttraction(attnames[i]);
>   +            }
>   +        }
>   +        return attractions;
>   +    }
>   +
>   +    public Attraction[] getAttractions2(Query[] attnames) 
> throws java.rmi.RemoteException {
>   +        Attraction[] attractions = null;
>   +        if (attnames != null) {
>   +            attractions = new Attraction[attnames.length]; 
>   +            for (int i=0; i < attnames.length; i++) {
>   +                if (attnames[i] != null) {
>   +                    attractions[i] = 
> getAttraction(attnames[i].getValue());
>   +                }
>                }
>            }
>            return attractions;
>   
>   
>   
>   1.5       +54 -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.4
>   retrieving revision 1.5
>   diff -u -r1.4 -r1.5
>   --- City_BBBTestCase.java	20 Jul 2002 00:30:20 -0000	1.4
>   +++ City_BBBTestCase.java	5 Sep 2002 01:08:38 -0000	1.5
>   @@ -123,5 +123,59 @@
>                throw new 
> junit.framework.AssertionFailedError("Remote Exception 
> caught: " + re);
>            }
>        }
>   +
>   +    public void test6CityBBBPortGetAttractions() {
>   +        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 getAttractions2 with two inputs
>   +            Query[] query = new Query[2];
>   +            query[0] = new Query();
>   +            query[0].setValue("Christmas");
>   +            query[1] = new Query();
>   +            query[1].setValue("Xmas");
>   +
>   +            Attraction[] value = binding.getAttractions2(query);
>   +            assertEquals("OID value was wrong for first 
> attraction", value[0].get_OID(),
>   +                         City_BBBBindingImpl.OID_STRING);
>   +            assertEquals("OID value was wrong for second 
> attaction", value[1].get_OID(),
>   +                         City_BBBBindingImpl.OID_STRING);
>   +        }
>   +        catch (java.rmi.RemoteException re) {
>   +            throw new 
> junit.framework.AssertionFailedError("Remote Exception 
> caught: " + re);
>   +        }
>   +    }
>   +
>   +    public void test7CityBBBPortGetAttractions() {
>   +        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 getAttractions2 with one input
>   +            Query[] query = new Query[1];
>   +            query[0] = new Query();
>   +            query[0].setValue("Christmas");
>   +
>   +            Attraction[] value = binding.getAttractions2(query);
>   +            assertEquals("OID value was wrong for first 
> attraction", value[0].get_OID(),
>   +                         City_BBBBindingImpl.OID_STRING);
>   +        }
>   +        catch (java.rmi.RemoteException re) {
>   +            throw new 
> junit.framework.AssertionFailedError("Remote Exception 
> caught: " + re);
>   +        }
>   +    }
>    }
>    
>   
>   
>   
>