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 <gl...@thoughtcraft.com> on 2004/10/11 17:11:28 UTC

RE: cvs commit: ws-axis/java/src/org/apache/axis/encoding/ser ArraySerializer.java

Hi Tom:

Please be sure that we still send xsi:type if necessary on array items after
this change.  Consider the case where we have an array of BaseType, and send
three BaseTypes followed by a SubType.  At LEAST the SubType element should
definitely have xsi:type on it!

Why was setting xsi:type on each element a problem??

--Glen 

> -----Original Message-----
> From: tomj@apache.org [mailto:tomj@apache.org] 
> Sent: Monday, October 11, 2004 7:15 AM
> To: ws-axis-cvs@apache.org
> Subject: cvs commit: 
> ws-axis/java/src/org/apache/axis/encoding/ser ArraySerializer.java
> 
> tomj        2004/10/11 07:15:17
> 
>   Modified:    java/src/org/apache/axis/encoding/ser 
> ArraySerializer.java
>   Log:
>   Fix regression problems with SOAP encoded arrays:
>   
>   - Don't use "currentXMLType" from context if we are encoded, get the
>     type of the array from the componentType.
>   - Always set the xsi:type attribute of encoded arrays to 
> soapenc:Array
>   - If we are doing encoded arrays, don't send xsi:type for 
> each element
>   
>   Revision  Changes    Path
>   1.57      +33 -19    
> ws-axis/java/src/org/apache/axis/encoding/ser/ArraySerializer.java
>   
>   Index: ArraySerializer.java
>   ===================================================================
>   RCS file: 
> /home/cvs/ws-axis/java/src/org/apache/axis/encoding/ser/ArrayS
> erializer.java,v
>   retrieving revision 1.56
>   retrieving revision 1.57
>   diff -u -r1.56 -r1.57
>   --- ArraySerializer.java	29 Jul 2004 21:40:26 -0000	1.56
>   +++ ArraySerializer.java	11 Oct 2004 14:15:17 -0000	1.57
>   @@ -125,14 +125,17 @@
>    
>            // Get the QName of the componentType.
>            // If not found, look at the super classes
>   -        QName componentQName = context.getCurrentXMLType();
>   -        if (componentQName != null) {
>   -            if ((componentQName.equals(xmlType) ||
>   -                    componentQName.equals(soap.getArrayType()))) {
>   -                componentQName = null;
>   +        QName componentQName = null;
>   +        if (!encoded) {
>   +            componentQName = context.getCurrentXMLType();
>   +            if (componentQName != null) {
>   +                if ((componentQName.equals(xmlType) ||
>   +                     componentQName.equals(soap.getArrayType()))) {
>   +                         componentQName = null;
>   +                     }
>                }
>            }
>   -        
>   +
>            if (componentQName == null) {
>                componentQName = 
> context.getQNameForClass(componentType);
>            }
>   @@ -292,29 +295,37 @@
>                //          and may be useful for operation 
> overloading.
>                //   Cons:  More interop test failures (as of 
> 2/6/2002).
>                //
>   +            String qname =
>   +                    context.getPrefixForURI(schema.getXsiURI(),
>   +                                            "xsi") + ":type";
>   +            QName soapArray;
>   +            if (soap == SOAPConstants.SOAP12_CONSTANTS) {
>   +                soapArray = Constants.SOAP_ARRAY12;
>   +            } else {
>   +                soapArray = Constants.SOAP_ARRAY;
>   +            }
>   +
>                int typeI = attrs.getIndex(schema.getXsiURI(),
>                                           "type");
>                if (typeI != -1) {
>   -                String qname =
>   -                      context.getPrefixForURI(schema.getXsiURI(),
>   -                                              "xsi") + ":type";
>   -                QName soapArray;
>   -                if (soap == SOAPConstants.SOAP12_CONSTANTS) {
>   -                    soapArray = Constants.SOAP_ARRAY12;
>   -                } else {
>   -                    soapArray = Constants.SOAP_ARRAY;
>   -                }
>   -
>                    attrs.setAttribute(typeI,
>                                       schema.getXsiURI(),
>                                       "type",
>                                       qname,
>                                       "CDATA",
>                                       
> context.qName2String(soapArray));
>   +            } else {
>   +                attrs.addAttribute(schema.getXsiURI(),
>   +                                   "type",
>   +                                   qname,
>   +                                   "CDATA",
>   +                                   
> context.qName2String(soapArray));
>                }
>   +
>                attributes = attrs;
>            }
>    
>   +        Boolean sendType = null;
>            // 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>
>   @@ -324,8 +335,11 @@
>                serializeAttr = null;  // since we are putting 
> them here
>                context.startElement(name, attributes);
>                elementName = Constants.QNAME_LITERAL_ITEM;
>   +            // If we are doing SOAP encoded arrays, no 
> need to add xsi:type to the items
>   +            sendType = Boolean.FALSE;
>            }
>    
>   +
>            if (dim2Len < 0) {
>                // Normal case, serialize each array element
>                if (list == null) {
>   @@ -336,7 +350,7 @@
>                        context.serialize(elementName, 
> serializeAttr, aValue,
>                                          componentQName, // 
> prefered type QName
>                                          true,   // Send null values
>   -                                      null);  // Respect 
> default type config
>   +                                      sendType);  // Add xsi:type?
>                    }
>                } else {
>                    for (Iterator iterator = list.iterator(); 
> iterator.hasNext();) {
>   @@ -346,7 +360,7 @@
>                        context.serialize(elementName, 
> serializeAttr, aValue,
>                                          componentQName, // 
> prefered type QName
>                                          true,   // Send null values
>   -                                      null);  // Respect 
> default type config
>   +                                      sendType);  // Add xsi:type?
>    
>                    }
>                }
>   @@ -355,7 +369,7 @@
>                for (int index = 0; index < len; index++) {
>                    for (int index2 = 0; index2 < dim2Len; index2++) {
>                        Object aValue = 
> Array.get(Array.get(value, index), index2);
>   -                    context.serialize(elementName, null, 
> aValue, componentQName, true, null);
>   +                    context.serialize(elementName, null, 
> aValue, componentQName, true, sendType);
>                    }
>                }
>            }
>   
>   
>   
> 
>