axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@apache.org
Subject cvs commit: xml-axis/java/src/org/apache/axis/handlers/soap SOAPService.java
Date Fri, 20 Dec 2002 17:28:23 GMT
dims        2002/12/20 09:28:23

  Modified:    java/src/org/apache/axis/encoding/ser ArrayDeserializer.java
                        ArraySerializer.java BeanDeserializer.java
                        JAFDataHandlerDeserializer.java
                        JAFDataHandlerSerializer.java
               java/src/org/apache/axis Constants.java
               java/src/org/apache/axis/encoding
                        DefaultTypeMappingImpl.java DeserializerImpl.java
                        SerializationContextImpl.java TypeMappingImpl.java
               java/test/soap12 PackageTests.java TestDeser.java
                        TestSer.java
               java/src/org/apache/axis/handlers MD5AttachHandler.java
               java/src/org/apache/axis/message MessageElement.java
                        RPCHandler.java SOAPFaultDetailsBuilder.java
                        SOAPHeaderElement.java
               java/src/org/apache/axis/i18n resource.properties
               java/src/org/apache/axis/providers/java RPCProvider.java
               java/src/org/apache/axis/soap SOAP11Constants.java
                        SOAP12Constants.java SOAPConstants.java
               java/src/org/apache/axis/handlers/soap SOAPService.java
  Added:       java/test/soap12 Echo.java TestFault.java TestHrefs.java
                        TestRPC.java
  Log:
  Fix and test cases for Bug 15363 - soap 1.2 patches for rpc array ser/deser, rpc result, href attr, notunderstood header, etc.
  from andras.avar@nokia.com (Andras Avar)
  
  Revision  Changes    Path
  1.33      +79 -20    xml-axis/java/src/org/apache/axis/encoding/ser/ArrayDeserializer.java
  
  Index: ArrayDeserializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/ArrayDeserializer.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- ArrayDeserializer.java	11 Dec 2002 22:38:15 -0000	1.32
  +++ ArrayDeserializer.java	20 Dec 2002 17:28:20 -0000	1.33
  @@ -67,6 +67,9 @@
   import org.apache.axis.utils.Messages;
   import org.apache.axis.wsdl.symbolTable.SchemaUtils;
   import org.apache.commons.logging.Log;
  +import org.apache.axis.soap.SOAPConstants;
  +import org.apache.axis.MessageContext;
  +
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   
  @@ -99,6 +102,7 @@
       Class arrayClass = null;
       ArrayList mDimLength = null;  // If set, array of multi-dim lengths 
       ArrayList mDimFactor = null;  // If set, array of factors for multi-dim []
  +    SOAPConstants soapConstants = SOAPConstants.SOAP11_CONSTANTS;
   
       /**
        * This method is invoked after startElement when the element requires
  @@ -146,6 +150,11 @@
               log.debug("Enter: ArrayDeserializer::startElement()");
           }
   
  +        MessageContext msgContext = context.getMessageContext();
  +        if (msgContext != null) {
  +            soapConstants = msgContext.getSOAPConstants();
  +        }
  +
           // Get the qname for the array type=, set it to null if
           // the generic type is used.
           QName typeQName = context.getTypeFromAttributes(namespace,
  @@ -164,7 +173,7 @@
           QName arrayTypeValue = context.getQNameFromString(
                         Constants.getValue(attributes,
                                            Constants.URIS_SOAP_ENC,
  -                                         Constants.ATTR_ARRAY_TYPE));
  +                                         soapConstants.getAttrItemType()));
   
           // The first part of the arrayType expression is 
           // the default item type qname.
  @@ -177,6 +186,8 @@
                   arrayTypeValue.getNamespaceURI();
               String arrayTypeValueLocalPart = 
                   arrayTypeValue.getLocalPart();
  +
  +            if (soapConstants != SOAPConstants.SOAP12_CONSTANTS) {
               int leftBracketIndex = 
                   arrayTypeValueLocalPart.lastIndexOf('[');
               int rightBracketIndex = 
  @@ -209,6 +220,33 @@
                   defaultItemType = new QName(arrayTypeValueNamespaceURI,
                                               arrayTypeValueLocalPart);
               }
  +
  +            } else {
  +                String arraySizeValue = attributes.getValue(soapConstants.getEncodingURI(), Constants.ATTR_ARRAY_SIZE);
  +                int leftStarIndex = arraySizeValue.lastIndexOf('*');
  +
  +                // Skip to num if any
  +                if (leftStarIndex != -1) {
  +                    // "*" => ""
  +                    if (leftStarIndex == 0 && arraySizeValue.length() == 1) {
  +                    // "* *" => ""
  +                    } else if (leftStarIndex == (arraySizeValue.length() - 1)) {
  +                        innerQName = arrayTypeValue;
  +                        innerDimString = arraySizeValue.substring(0, leftStarIndex - 1);
  +                    // "* N" => "N"
  +                    } else {
  +                        dimString = arraySizeValue.substring(leftStarIndex + 2);
  +                        innerQName = arrayTypeValue;
  +                        innerDimString = arraySizeValue.substring(0, leftStarIndex + 1);
  +                    }
  +                }
  +
  +                if (innerDimString == null) {
  +                    defaultItemType = Constants.SOAP_ARRAY12;
  +                } else {
  +                    defaultItemType = arrayTypeValue;
  +                }
  +            }
           }
   
           // If no type QName and no defaultItemType qname, use xsd:anyType
  @@ -226,27 +264,38 @@
               // Get an array of the default item type.
               Class arrayItemClass = null;
               QName compQName = defaultItemType;
  -            String dims = "[]";
  +
               // Nested array, use the innermost qname
  +            String dims = "[]";
               if (innerQName != null) {
                   compQName = innerQName;
  +
  +                if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) {
  +                    int offset = 0;
  +                    while ((offset = innerDimString.indexOf('*', offset)) != -1) {
  +                        dims += "[]";
  +                        offset ++;
  +                    }
  +                } else {
                   dims += innerDimString;                
               }
  -            arrayItemClass = context.getTypeMapping().
  -                getClassForQName(compQName);
  -            if (arrayItemClass != null) {
  -                try {
  -                    arrayClass = ClassUtils.forName(
  -                      JavaUtils.getLoadableClassName(
  -                        JavaUtils.getTextClassName(arrayItemClass.getName()) +
  -                        dims));
  -                } catch (Exception e) {
  -                    throw new SAXException(
  -                       Messages.getMessage("noComponent00",  
  -                                            "" + defaultItemType));
  -                }
  +        }
  +
  +        arrayItemClass = context.getTypeMapping().
  +            getClassForQName(compQName);
  +        if (arrayItemClass != null) {
  +            try {
  +                arrayClass = ClassUtils.forName(
  +                  JavaUtils.getLoadableClassName(
  +                    JavaUtils.getTextClassName(arrayItemClass.getName()) +
  +                    dims));
  +            } catch (Exception e) {
  +                throw new SAXException(
  +                   Messages.getMessage("noComponent00",  
  +                                        "" + defaultItemType));
               }
           }
  +        }
   
           if (arrayClass == null) {
               throw new SAXException(
  @@ -260,13 +309,15 @@
           else {
               try
               {
  -                StringTokenizer tokenizer = new StringTokenizer(dimString,
  -                                                                "[],");
  +                StringTokenizer tokenizer;
  +                if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) {
  +                    tokenizer = new StringTokenizer(dimString);
  +                } else {
  +                    tokenizer = new StringTokenizer(dimString, "[],");
  +                }
   
                   length = Integer.parseInt(tokenizer.nextToken());
  -
  -                if (tokenizer.hasMoreTokens())
  -                    {
  +                if (tokenizer.hasMoreTokens()) {
                           // If the array is passed as a multi-dimensional array
                           // (i.e. int[2][3]) then store all of the 
                           // mult-dim lengths.
  @@ -304,6 +355,10 @@
                                            Constants.URIS_SOAP_ENC,
                                            Constants.ATTR_OFFSET);
           if (offset != null) {
  +            if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) {
  +                throw new SAXException(Messages.getMessage("noSparseArray"));
  +            }
  +
               int leftBracketIndex = offset.lastIndexOf('[');
               int rightBracketIndex = offset.lastIndexOf(']');
   
  @@ -357,6 +412,10 @@
                                      Constants.URIS_SOAP_ENC,
                                      Constants.ATTR_POSITION);
               if (pos != null) {
  +                if (soapConstants == SOAPConstants.SOAP12_CONSTANTS) {
  +                    throw new SAXException(Messages.getMessage("noSparseArray"));
  +                }
  +
                   int leftBracketIndex = pos.lastIndexOf('[');
                   int rightBracketIndex = pos.lastIndexOf(']');
   
  
  
  
  1.45      +42 -8     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/ArraySerializer.java,v
  retrieving revision 1.44
  retrieving revision 1.45
  diff -u -r1.44 -r1.45
  --- ArraySerializer.java	11 Dec 2002 22:38:15 -0000	1.44
  +++ ArraySerializer.java	20 Dec 2002 17:28:20 -0000	1.45
  @@ -144,7 +144,10 @@
           String dims = "";
           while (componentType.isArray()) {
               componentType = componentType.getComponentType();
  -            dims += "[]";
  +            if (soap == SOAPConstants.SOAP12_CONSTANTS)
  +                dims += "* ";
  +            else
  +                dims += "[]";
           }
   
           // Get the QName of the componentType.
  @@ -170,8 +173,11 @@
           String compType = prefix + ":" + componentQName.getLocalPart();
           int len = (list == null) ? Array.getLength(value) : list.size();
   
  -        String arrayType = compType + dims + "[" + len + "]";
  -
  +        String arrayType;
  +        if (soap == SOAPConstants.SOAP12_CONSTANTS)
  +            arrayType = dims + len;
  +        else
  +            arrayType = dims + "[" + len + "]";
   
           // Discover whether array can be serialized directly as a two-dimensional
           // array (i.e. arrayType=int[2,3]) versus an array of arrays.
  @@ -231,7 +237,10 @@
                   // Update the arrayType to use mult-dim array encoding
                   if (okay) {
                       dims = dims.substring(0, dims.length()-2);
  -                    arrayType = compType + dims + "[" + len + "," + dim2Len + "]";
  +                    if (soap == SOAPConstants.SOAP12_CONSTANTS)
  +                        arrayType = dims + len + " " + dim2Len;
  +                    else
  +                        arrayType = dims + "[" + len + "," + dim2Len + "]";
                   } else {
                       dim2Len = -1;
                   }
  @@ -255,15 +264,33 @@
                   attrs = new AttributesImpl(attributes);
               }
   
  -            if (attrs.getIndex(soap.getEncodingURI(),
  -                               Constants.ATTR_ARRAY_TYPE) == -1) {
  +
  +            if (attrs.getIndex(soap.getEncodingURI(), soap.getAttrItemType()) == -1) {
                   String encprefix =
                          context.getPrefixForURI(soap.getEncodingURI());
  +
  +                if (soap != SOAPConstants.SOAP12_CONSTANTS) {
  +                    compType = compType + arrayType;
  +
                   attrs.addAttribute(soap.getEncodingURI(),
  -                                   Constants.ATTR_ARRAY_TYPE,
  +                                       soap.getAttrItemType(),
                                      encprefix + ":arrayType",
                                      "CDATA",
  +                                       compType);
  +
  +                } else {
  +                    attrs.addAttribute(soap.getEncodingURI(),
  +                                       soap.getAttrItemType(),
  +                                       encprefix + ":itemType",
  +                                       "CDATA",
  +                                       compType);
  +
  +                    attrs.addAttribute(soap.getEncodingURI(),
  +                                       "arraySize",
  +                                       encprefix + ":arraySize",
  +                                       "CDATA",
                                      arrayType);
  +                }
               }
   
               // Force type to be SOAP_ARRAY for all array serialization.
  @@ -286,12 +313,19 @@
                   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(Constants.SOAP_ARRAY));
  +                                   context.qName2String(soapArray));
               }
               attributes = attrs;
           }
  
  
  
  1.59      +3 -1      xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java
  
  Index: BeanDeserializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/BeanDeserializer.java,v
  retrieving revision 1.58
  retrieving revision 1.59
  diff -u -r1.58 -r1.59
  --- BeanDeserializer.java	11 Dec 2002 22:38:15 -0000	1.58
  +++ BeanDeserializer.java	20 Dec 2002 17:28:20 -0000	1.59
  @@ -66,6 +66,7 @@
   import org.apache.axis.message.SOAPHandler;
   import org.apache.axis.utils.BeanPropertyDescriptor;
   import org.apache.axis.utils.Messages;
  +import org.apache.axis.soap.SOAPConstants;
   import org.apache.commons.logging.Log;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
  @@ -187,6 +188,7 @@
           BeanPropertyDescriptor propDesc = null;
           FieldDesc fieldDesc = null;
   
  +        SOAPConstants soapConstants = context.getMessageContext().getSOAPConstants();
           String encodingStyle = context.getMessageContext().getEncodingStyle();
           boolean isEncoded = Constants.isSOAP_ENC(encodingStyle);
   
  @@ -265,7 +267,7 @@
                                                               localName,
                                                               attributes);
   
  -        String href = attributes.getValue("href");
  +        String href = attributes.getValue(soapConstants.getAttrHref());
   
           // If no xsi:type or href, check the meta-data for the field
           if (childXMLType == null && fieldDesc != null && href == null) {
  
  
  
  1.18      +4 -2      xml-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerDeserializer.java
  
  Index: JAFDataHandlerDeserializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerDeserializer.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- JAFDataHandlerDeserializer.java	11 Dec 2002 22:38:15 -0000	1.17
  +++ JAFDataHandlerDeserializer.java	20 Dec 2002 17:28:20 -0000	1.18
  @@ -61,6 +61,7 @@
   import org.apache.axis.encoding.DeserializerImpl;
   import org.apache.axis.message.SOAPHandler;
   import org.apache.axis.utils.Messages;
  +import org.apache.axis.soap.SOAPConstants;
   import org.apache.commons.logging.Log;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
  @@ -89,6 +90,8 @@
           }
   //        super.startElement(namespace, localName, qName, attributes, context);
   
  +        SOAPConstants soapConstants = context.getMessageContext().getSOAPConstants();
  +
           QName type = context.getTypeFromAttributes(namespace,
                                                      localName,
                                                      attributes);
  @@ -96,8 +99,7 @@
               log.debug(Messages.getMessage("gotType00", "Deser", "" + type));
           }
           
  -        String href = attributes.getValue("href");
  -        log.debug("href=" + href);
  +        String href = attributes.getValue(soapConstants.getAttrHref());
           if (href != null) {
               Object ref = context.getObjectByRef(href);
               try{
  
  
  
  1.23      +3 -1      xml-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerSerializer.java
  
  Index: JAFDataHandlerSerializer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/ser/JAFDataHandlerSerializer.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- JAFDataHandlerSerializer.java	4 Nov 2002 17:01:27 -0000	1.22
  +++ JAFDataHandlerSerializer.java	20 Dec 2002 17:28:20 -0000	1.23
  @@ -63,6 +63,7 @@
   import org.apache.axis.encoding.Serializer;
   import org.apache.axis.utils.Messages;
   import org.apache.axis.wsdl.fromJava.Types;
  +import org.apache.axis.soap.SOAPConstants;
   import org.apache.commons.logging.Log;
   import org.w3c.dom.Element;
   import org.xml.sax.Attributes;
  @@ -99,6 +100,7 @@
               // we used to do, throw something meaningful.
               throw new IOException(Messages.getMessage("noAttachments"));
           }
  +        SOAPConstants soapConstants = context.getMessageContext().getSOAPConstants();
   
           Part attachmentPart= attachments.createAttachmentPart(dh);
   
  @@ -114,7 +116,7 @@
               attrs.removeAttribute(typeIndex);
           }
   
  -        attrs.addAttribute("", Constants.ATTR_HREF, "href",
  +        attrs.addAttribute("", soapConstants.getAttrHref(), soapConstants.getAttrHref(),
                                  "CDATA", attachmentPart.getContentIdRef() );
   
           context.startElement(name, attrs);
  
  
  
  1.101     +5 -1      xml-axis/java/src/org/apache/axis/Constants.java
  
  Index: Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/Constants.java,v
  retrieving revision 1.100
  retrieving revision 1.101
  diff -u -r1.100 -r1.101
  --- Constants.java	11 Dec 2002 22:38:06 -0000	1.100
  +++ Constants.java	20 Dec 2002 17:28:21 -0000	1.101
  @@ -406,7 +406,7 @@
       public static final String ELEM_BODY     = "Body" ;
       public static final String ELEM_FAULT    = "Fault" ;
   
  -    public static final String ELEM_MISUNDERSTOOD = "Misunderstood";
  +    public static final String ELEM_NOTUNDERSTOOD = "NotUnderstood";
   
       public static final String ELEM_FAULT_CODE   = "faultcode" ;
       public static final String ELEM_FAULT_STRING = "faultstring" ;
  @@ -428,8 +428,11 @@
       public static final String ATTR_ROOT            = "root" ;
       public static final String ATTR_ID              = "id" ;
       public static final String ATTR_HREF            = "href" ;
  +    public static final String ATTR_REF             = "ref" ;
       public static final String ATTR_QNAME           = "qname";
       public static final String ATTR_ARRAY_TYPE      = "arrayType";
  +    public static final String ATTR_ITEM_TYPE       = "itemType";
  +    public static final String ATTR_ARRAY_SIZE      = "arraySize";
       public static final String ATTR_OFFSET          = "offset";
       public static final String ATTR_POSITION        = "position";
       public static final String ATTR_TYPE            = "type";
  @@ -558,6 +561,7 @@
       public static final QName SOAP_INTEGER = new QName(URI_DEFAULT_SOAP_ENC, "integer");
       public static final QName SOAP_DECIMAL = new QName(URI_DEFAULT_SOAP_ENC, "decimal");
       public static final QName SOAP_ARRAY = new QName(URI_DEFAULT_SOAP_ENC, "Array");
  +    public static final QName SOAP_ARRAY12 = new QName(URI_SOAP12_ENC, "Array");
   
       public static final QName SOAP_MAP = new QName(NS_URI_XMLSOAP, "Map");
       public static final QName SOAP_ELEMENT = new QName(NS_URI_XMLSOAP, "Element");
  
  
  
  1.66      +12 -0     xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java
  
  Index: DefaultTypeMappingImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DefaultTypeMappingImpl.java,v
  retrieving revision 1.65
  retrieving revision 1.66
  diff -u -r1.65 -r1.66
  --- DefaultTypeMappingImpl.java	11 Dec 2002 22:38:13 -0000	1.65
  +++ DefaultTypeMappingImpl.java	20 Dec 2002 17:28:21 -0000	1.66
  @@ -594,6 +594,18 @@
                      new ArrayDeserializerFactory()
           );
   
  +        // TODO: move it to the DefaultSOAPEncodingTypeMappingImpl class
  +        myRegister(Constants.SOAP_ARRAY12,     java.util.Collection.class,
  +                   new ArraySerializerFactory(),
  +                   new ArrayDeserializerFactory()
  +        );
  +
  +        myRegister(Constants.SOAP_ARRAY12,     Object[].class,
  +                   new ArraySerializerFactory(),
  +                   new ArrayDeserializerFactory()
  +        );
  +
  +
           //
           // Now register the schema specific types
           //
  
  
  
  1.33      +4 -1      xml-axis/java/src/org/apache/axis/encoding/DeserializerImpl.java
  
  Index: DeserializerImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/DeserializerImpl.java,v
  retrieving revision 1.32
  retrieving revision 1.33
  diff -u -r1.32 -r1.33
  --- DeserializerImpl.java	11 Dec 2002 22:38:13 -0000	1.32
  +++ DeserializerImpl.java	20 Dec 2002 17:28:21 -0000	1.33
  @@ -64,6 +64,7 @@
   import org.apache.axis.message.SAXOutputter;
   import org.apache.axis.message.SOAPHandler;
   import org.apache.axis.utils.Messages;
  +import org.apache.axis.soap.SOAPConstants;
   import org.apache.commons.logging.Log;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
  @@ -360,6 +361,8 @@
               return;
           }
   
  +        SOAPConstants soapConstants = context.getMessageContext().getSOAPConstants();
  +
           // If this element has an id, then associate the value with the id.
           // (Prior to this association, the MessageElement of the element is
           // associated with the id. Failure to replace the MessageElement at this
  @@ -376,7 +379,7 @@
               context.registerFixup("#" + id, this);
           }
   
  -        String href = attributes.getValue("href");
  +        String href = attributes.getValue(soapConstants.getAttrHref());
           if (href != null) {
               isHref = true;
   
  
  
  
  1.88      +1 -1      xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java
  
  Index: SerializationContextImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/SerializationContextImpl.java,v
  retrieving revision 1.87
  retrieving revision 1.88
  diff -u -r1.87 -r1.88
  --- SerializationContextImpl.java	17 Dec 2002 21:07:36 -0000	1.87
  +++ SerializationContextImpl.java	20 Dec 2002 17:28:21 -0000	1.88
  @@ -745,7 +745,7 @@
               AttributesImpl attrs = new AttributesImpl();
               if (attributes != null && 0 < attributes.getLength())
                   attrs.setAttributes(attributes);
  -            attrs.addAttribute("", Constants.ATTR_HREF, "href",
  +            attrs.addAttribute("", soapConstants.getAttrHref(), soapConstants.getAttrHref(),
                                  "CDATA", '#' + id);
   
               startElement(elemQName, attrs);
  
  
  
  1.38      +11 -1     xml-axis/java/src/org/apache/axis/encoding/TypeMappingImpl.java
  
  Index: TypeMappingImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/encoding/TypeMappingImpl.java,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- TypeMappingImpl.java	11 Dec 2002 22:38:14 -0000	1.37
  +++ TypeMappingImpl.java	20 Dec 2002 17:28:21 -0000	1.38
  @@ -573,7 +573,17 @@
           if (xmlType == null && (javaType.isArray() ||
                javaType == List.class ||
                List.class.isAssignableFrom(javaType))) {
  -            xmlType = Constants.SOAP_ARRAY;
  +
  +            // get the registered array if any
  +            pair = (Pair) class2Pair.get(Object[].class);
  +            // TODO: it always returns the last registered one,
  +            //  so that's why the soap 1.2 typemappings have to 
  +            //  move to an other registry to differentiate them
  +            if (pair != null) {
  +                xmlType = pair.xmlType;
  +            } else {
  +                xmlType = Constants.SOAP_ARRAY;
  +            }
           }
   
           //log.debug("getTypeQName xmlType =" + xmlType);
  
  
  
  1.2       +4 -1      xml-axis/java/test/soap12/PackageTests.java
  
  Index: PackageTests.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/soap12/PackageTests.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- PackageTests.java	20 Nov 2002 18:05:44 -0000	1.1
  +++ PackageTests.java	20 Dec 2002 17:28:21 -0000	1.2
  @@ -71,7 +71,10 @@
   
           suite.addTestSuite(TestDeser.class);
           suite.addTestSuite(TestHeaderAttrs.class);
  -        //suite.addTestSuite(TestSer.class);
  +        suite.addTestSuite(TestSer.class);
  +        suite.addTestSuite(TestFault.class);
  +        suite.addTestSuite(TestHrefs.class);
  +        suite.addTestSuite(TestRPC.class);
   
           return suite;
       }
  
  
  
  1.3       +209 -31   xml-axis/java/test/soap12/TestDeser.java
  
  Index: TestDeser.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/soap12/TestDeser.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestDeser.java	11 Dec 2002 22:40:18 -0000	1.2
  +++ TestDeser.java	20 Dec 2002 17:28:21 -0000	1.3
  @@ -4,63 +4,121 @@
   import org.apache.axis.Constants;
   import org.apache.axis.Message;
   import org.apache.axis.MessageContext;
  +import org.apache.axis.encoding.TypeMapping;
  +import org.apache.axis.encoding.TypeMappingRegistry;
   import org.apache.axis.message.RPCElement;
   import org.apache.axis.message.RPCParam;
   import org.apache.axis.message.SOAPEnvelope;
   import org.apache.axis.server.AxisServer;
   import org.apache.axis.soap.SOAPConstants;
  +import org.apache.axis.utils.JavaUtils;
   import org.apache.axis.utils.Messages;
   
  +import javax.xml.namespace.QName;
  +import java.lang.reflect.Array;
  +import java.util.ArrayList;
  +import java.util.Iterator;
  +import java.util.List;
  +import java.util.Map;
  +import java.util.Set;
   import java.util.Vector;
  +
   /**
    * Test deserialization of SOAP responses
    */
   public class TestDeser extends TestCase {
  +    private AxisServer server = null;
   
  -    private AxisServer server = new AxisServer();
   
       public TestDeser(String name) {
           super(name);
  +
  +        server = new AxisServer();
  +
  +        TypeMappingRegistry tmr = server.getTypeMappingRegistry();
  +        TypeMapping tm = (TypeMapping) tmr.createTypeMapping();
  +        tm.setSupportedEncodings(new String[] {Constants.URI_SOAP12_ENC});
  +        tmr.register(Constants.URI_SOAP12_ENC, tm);
  +        tm.register(java.lang.String[].class,
  +                    new QName("http://soapinterop.org/xsd", "ArrayOfString"),
  +                    new org.apache.axis.encoding.ser.ArraySerializerFactory(),
  +                    new org.apache.axis.encoding.ser.ArrayDeserializerFactory());
       }
  -    
  -    String text1 = 
  +
  +    private final String SOAP_HEAD =
           "<?xml version=\"1.0\"?>\n" +
           "<soap:Envelope " +
             "xmlns:soap=\"http://www.w3.org/2002/06/soap-envelope\" " +
  -          "xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\" " +
  -          "xmlns:me=\"http://soapinterop.org/xsd\" " +
  -          "xmlns:this=\"http://encoding.test\" " + 
  +          "xmlns:soapenc=\"http://www.w3.org/2002/06/soap-encoding\" " +
  +          "xmlns:this=\"http://encoding.test\" " +
             "xmlns:xsi=\"" + Constants.URI_DEFAULT_SCHEMA_XSI + "\" " +
  -          "xmlns:xsd=\"" + Constants.URI_DEFAULT_SCHEMA_XSD + "\">\n" +
  -          "<soap:Body>\n" +
  -            "<methodResult xmlns=\"http://tempuri.org/\">\n" +
  -            "<item xsi:type=\"xsd:string\">abc</item>\n" +
  -            "</methodResult>\n" +
  +          "xmlns:xsd=\"" + Constants.URI_DEFAULT_SCHEMA_XSD + "\">\n";
  +
  +    private final String ITEM =
  +           "<item xsi:type=\"xsd:string\">abc</item>\n";
  +
  +    private final String BODY_HEAD =
  +          "<soap:Body>\n";
  +
  +    private final String METHOD_HEAD =
  +            "<methodResult xmlns=\"http://tempuri.org/\">\n";
  +
  +    private final String METHOD_TAIL =
  +            "</methodResult>\n";
  +
  +    private final String BODY_TAIL =
             "</soap:Body>\n";
  -    String text2 =
  +
  +    private final String SOAP_TAIL =
           "</soap:Envelope>\n";
   
  -    public void testDeser1() throws Exception {
  -        assertEquals(deserialize(""), "abc");
  -    }
  -    
  -    public void testDeser2() throws Exception {
  -        boolean expectedExceptionThrown = false;
  -        try {
  -            deserialize("<hello/>");
  -        } catch (org.apache.axis.AxisFault af) {
  -            String expected = Messages.getMessage("noElemAfterBody12");
  -            if(af.getFaultString().indexOf(expected)!=-1)
  -                expectedExceptionThrown = true;
  -        }
  -        assertTrue(expectedExceptionThrown);
  +
  +    private final String HEAD = SOAP_HEAD + BODY_HEAD + METHOD_HEAD;
  +    private final String TAIL = METHOD_TAIL + BODY_TAIL + SOAP_TAIL;
  +
  +
  +    private static boolean equals(Object obj1, Object obj2) {
  +       if ( (obj1 == null) || (obj2 == null) ) return (obj1 == obj2);
  +       if (obj1.equals(obj2)) return true;
  +       if (obj2.getClass().isArray() && obj1.getClass().isArray()) {
  +           if (Array.getLength(obj1) != Array.getLength(obj2)) return false;
  +           for (int i=0; i<Array.getLength(obj1); i++)
  +               if (!equals(Array.get(obj1,i),Array.get(obj2,i))) return false;
  +           return true;
  +       }
  +       if ((obj1 instanceof List) && (obj2 instanceof List)) {
  +           List list1 = (List)obj1;
  +           List list2 = (List)obj2;
  +           if (list1.size() != list2.size()) return false;
  +           for (int i=0; i < list1.size(); i++) {
  +               if (!equals(list1.get(i), list2.get(i))) return false;
  +           }
  +           return true;
  +       }
  +       if ((obj1 instanceof Map) && (obj2 instanceof Map)) {
  +           Map map1 = (Map)obj1;
  +           Map map2 = (Map)obj2;
  +           Set keys1 = map1.keySet();
  +           Set keys2 = map2.keySet();
  +           if (!(keys1.equals(keys2))) return false;
  +           Iterator i = keys1.iterator();
  +           while (i.hasNext()) {
  +               Object key = i.next();
  +               if (!map1.get(key).equals(map2.get(key)))
  +                   return false;
  +           }
  +           return true;
  +       }
  +
  +       return false;
       }
  -            
  -    public String deserialize (String extra) throws Exception {
  -        Message message = new Message(text1 + extra + text2);
  +
  +
  +    public void deserialize(String soap, Object expected, boolean tryConvert) throws Exception {
  +        Message message = new Message(soap);
           MessageContext context = new MessageContext(server);
           context.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);
  -        
  +
           message.setMessageContext(context);
   
           SOAPEnvelope envelope = message.getSOAPEnvelope();
  @@ -76,6 +134,126 @@
           RPCParam param = (RPCParam) arglist.get(0);
           assertNotNull("SOAP param should not be null", param);
   
  -        return (String)param.getValue();
  +        Object result = param.getValue();
  +        if (!equals(result, expected)) {
  +           // Try to convert to the expected class
  +           if (tryConvert) {
  +               Object result2 = JavaUtils.convert(result, expected.getClass());
  +               if (!equals(result2, expected)) {
  +                   assertEquals("The result is not what is expected.", expected, result);
  +               }
  +           } else {
  +               assertEquals("The result is not what is expected.", expected, result);
  +           }
  +        }
  +    }
  +
  +    public void testDeser1() throws Exception {
  +        deserialize(SOAP_HEAD + BODY_HEAD + METHOD_HEAD + ITEM + METHOD_TAIL + BODY_TAIL + SOAP_TAIL, "abc", false);
  +    }
  +
  +    public void testDeser2() throws Exception {
  +        boolean expectedExceptionThrown = false;
  +        try {
  +            deserialize(SOAP_HEAD + BODY_HEAD + METHOD_HEAD + ITEM + METHOD_TAIL + BODY_TAIL + "<hello/>" + SOAP_TAIL, null, false);
  +        } catch (org.apache.axis.AxisFault af) {
  +            String expected = Messages.getMessage("noElemAfterBody12");
  +            if(af.getFaultString().indexOf(expected)!=-1)
  +                expectedExceptionThrown = true;
  +        }
  +        assertTrue(expectedExceptionThrown);
  +    }
  +
  +    public void testAfterBody() throws Exception {
  +        boolean expectedExceptionThrown = false;
  +        try {
  +            deserialize(SOAP_HEAD + BODY_HEAD + METHOD_HEAD + ITEM + METHOD_TAIL + "<hello/>" + BODY_TAIL + SOAP_TAIL, null, false);
  +        } catch (org.apache.axis.AxisFault af) {
  +            // Should drop an ex about soap 1.2 doesn't permit any element after body
  +            String expected = Messages.getMessage("onlyOneBodyFor12");
  +            if(af.getFaultString().indexOf(expected)!=-1)
  +                expectedExceptionThrown = true;
  +        }
  +        assertTrue(expectedExceptionThrown);
  +    }
  +
  +    public void testArray() throws Exception {
  +        Vector v = new Vector();
  +        v.addElement("abc");
  +        v.addElement("def");
  +        deserialize(HEAD +
  +                    "<result xsi:type=\"soapenc:Array\" " +
  +                            "soapenc:itemType=\"xsd:string\" soapenc:arraySize=\"2\"> " +
  +                       "<item xsi:type=\"xsd:string\">abc</item>" +
  +                       "<item xsi:type=\"xsd:string\">def</item>" +
  +                    "</result>" +
  +                    TAIL,
  +                    v, true);
       }
  +
  +    public void testSparseArray1() throws Exception {
  +        ArrayList list = new ArrayList(4);
  +        list.add(null);
  +        list.add(null);
  +        list.add("abc");
  +        list.add("def");
  +        boolean expectedExceptionThrown = false;
  +        try {
  +            deserialize(HEAD +
  +                        "<result xsi:type=\"soapenc:Array\" " +
  +                                "soapenc:itemType=\"xsd:string\" soapenc:arraySize=\"4\" " +
  +                                " soapenc:offset=\"[2]\">" +
  +                           "<item xsi:type=\"xsd:string\">abc</item>" +
  +                           "<item xsi:type=\"xsd:string\">def</item>" +
  +                        "</result>" +
  +                        TAIL,
  +                        list, true);
  +        } catch (Exception af) {
  +            String expected = Messages.getMessage("noSparseArray");
  +            if(af.toString().indexOf(expected)!=-1)
  +                expectedExceptionThrown = true;
  +        }
  +        assertTrue(expectedExceptionThrown);
  +    }
  +
  +    public void testSparseArray2() throws Exception {
  +        ArrayList list = new ArrayList(4);
  +        list.add("abc");
  +        list.add(null);
  +        list.add("def");
  +        list.add(null);
  +
  +        boolean expectedExceptionThrown = false;
  +        try {
  +            deserialize(HEAD +
  +                        "<result xsi:type=\"soapenc:Array\" " +
  +                        "soapenc:itemType=\"xsd:string\" soapenc:arraySize=\"4\">" +
  +                        "<item soapenc:position=\"[0]\" xsi:type=\"xsd:string\">abc</item>" +
  +                        "<item soapenc:position=\"[2]\" xsi:type=\"xsd:string\">def</item>" +
  +                        "</result>" +
  +                        TAIL,
  +                        list, true);
  +        } catch (Exception af) {
  +            String expected = Messages.getMessage("noSparseArray");
  +            if(af.toString().indexOf(expected)!=-1)
  +                expectedExceptionThrown = true;
  +        }
  +        assertTrue(expectedExceptionThrown);
  +    }
  +
  +    public void testNoSizeDefinedArray() throws Exception {
  +        ArrayList a = new ArrayList();
  +        a.add("abc");
  +        a.add("def");
  +
  +        deserialize(HEAD +
  +                    "<result xsi:type=\"soapenc:Array\" " +
  +                    "soapenc:itemType=\"xsd:string\" soapenc:arraySize=\"*\">" +
  +                        "<item xsi:type=\"xsd:string\">abc</item>" +
  +                        "<item xsi:type=\"xsd:string\">def</item>" +
  +                    "</result>" +
  +                    TAIL,
  +                    a, true);
  +    }
  +
   }
  
  
  
  1.3       +7 -8      xml-axis/java/test/soap12/TestSer.java
  
  Index: TestSer.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/test/soap12/TestSer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestSer.java	11 Dec 2002 22:40:18 -0000	1.2
  +++ TestSer.java	20 Dec 2002 17:28:21 -0000	1.3
  @@ -15,6 +15,7 @@
   import org.apache.axis.message.SOAPEnvelope;
   import org.apache.axis.server.AxisServer;
   import org.apache.axis.soap.SOAPConstants;
  +import org.apache.axis.utils.XMLUtils;
   import org.apache.commons.logging.Log;
   import org.w3c.dom.Document;
   import org.xml.sax.InputSource;
  @@ -23,8 +24,6 @@
   import test.encoding.DataSerFactory;
   
   import javax.xml.namespace.QName;
  -import javax.xml.parsers.DocumentBuilder;
  -import javax.xml.parsers.DocumentBuilderFactory;
   import java.io.StringReader;
   import java.io.StringWriter;
   import java.io.Writer;
  @@ -70,8 +69,8 @@
           // Create a TypeMapping and register the specialized Type Mapping
           TypeMappingRegistry reg = context.getTypeMappingRegistry();
           TypeMapping tm = (TypeMapping) reg.createTypeMapping();
  -        tm.setSupportedEncodings(new String[] {Constants.URI_DEFAULT_SOAP_ENC});
  -        reg.register(Constants.URI_DEFAULT_SOAP_ENC, tm);
  +        tm.setSupportedEncodings(new String[] {Constants.URI_SOAP12_ENC});
  +        reg.register(Constants.URI_SOAP12_ENC, tm);
   
           QName dataQName = new QName("typeNS", "Data");
           tm.register(Data.class, dataQName, new DataSerFactory(), new DataDeserFactory());
  @@ -126,8 +125,9 @@
       {
           try {
               MessageContext msgContext = new MessageContext(new AxisServer());
  +            msgContext.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);
               String req =
  -                "<xsd1:A xmlns:xsd1='urn:myNamespace'>"
  +                "<xsd1:A xmlns:xsd1=\"urn:myNamespace\">"
                       + "<xsd1:B>"
                       + "<xsd1:C>foo bar</xsd1:C>"
                       + "</xsd1:B>"
  @@ -137,12 +137,11 @@
               StringReader reqReader = new StringReader(req);
               InputSource reqSource = new InputSource(reqReader);
   
  -            DocumentBuilder xdb = DocumentBuilderFactory.newInstance().newDocumentBuilder();
  -            Document document = xdb.parse(reqSource );
  +            Document document = XMLUtils.newDocument(reqSource);
   
               String msgString = null;
   
  -            SOAPEnvelope msg = new SOAPEnvelope();
  +            SOAPEnvelope msg = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS);
               RPCParam arg1 = new RPCParam("urn:myNamespace", "testParam", document.getFirstChild());
               arg1.setXSITypeGeneration(Boolean.FALSE);
   
  
  
  
  1.1                  xml-axis/java/test/soap12/Echo.java
  
  Index: Echo.java
  ===================================================================
  package test.soap12;
  
  public class Echo {
      public String echo(String text) {
          return text;
      }
  }
  
  
  
  1.1                  xml-axis/java/test/soap12/TestFault.java
  
  Index: TestFault.java
  ===================================================================
  package test.soap12;
  
  import junit.framework.Test;
  import junit.framework.TestCase;
  import junit.framework.TestSuite;
  import org.apache.axis.AxisFault;
  import org.apache.axis.Message;
  import org.apache.axis.MessageContext;
  import org.apache.axis.encoding.SerializationContext;
  import org.apache.axis.encoding.SerializationContextImpl;
  import org.apache.axis.message.SOAPBodyElement;
  import org.apache.axis.message.SOAPEnvelope;
  import org.apache.axis.message.SOAPFault;
  import org.apache.axis.server.AxisServer;
  import org.apache.axis.soap.SOAPConstants;
  
  import javax.xml.namespace.QName;
  import java.io.StringWriter;
  import java.io.Writer;
  
  /**
   * A test of soap 1.2 fault serialization and deserialization.
   *
   * @author Andras Avar (andras.avar@nokia.com)
   */
  public class TestFault extends TestCase {
      public static Test suite() {
          return new TestSuite(TestFault.class);
      }
  
      public TestFault(String name) {
          super(name);
      }
      public void setUp() throws Exception {
      }
  
      public static final QName FAULTCODE = new QName("http://c","faultcode_c");
      public static final QName FAULTSUBCODE[] = { new QName("http://a","subcode_a"),
                                                   new QName("http://b","subcode_b") };
      public static final String FAULTREASON = "reason";
      public static final String FAULTROLE = "role";
      public static final String FAULTNODE = "node";
  
      public void testFault() throws Exception
      {
          // Serialize
          MessageContext msgContext = new MessageContext(new AxisServer());
          msgContext.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);
          SOAPEnvelope msg = new SOAPEnvelope(SOAPConstants.SOAP12_CONSTANTS);
  
          SOAPFault fault = new SOAPFault(new AxisFault(FAULTCODE, FAULTSUBCODE ,FAULTREASON, FAULTROLE, FAULTNODE, null));
  
          msg.addBodyElement(fault);
          Writer stringWriter = new StringWriter();
          SerializationContext context = new SerializationContextImpl(stringWriter, msgContext);
          context.setDoMultiRefs(false);
          msg.output(context);
          String msgString = stringWriter.toString();
  
          // Deserialize and check
          AxisServer server = new AxisServer();
          Message message = new Message(msgString);
          message.setMessageContext(new MessageContext(server));
  
          SOAPEnvelope envelope = (SOAPEnvelope) message.getSOAPEnvelope();
          assertNotNull("envelope should not be null", envelope);
  
          SOAPBodyElement respBody = envelope.getFirstBody();
          assertTrue("respBody should be a SOAPFaultElement", respBody
                          instanceof SOAPFault);
          AxisFault aFault = ((SOAPFault) respBody).getFault();
  
          assertNotNull("Fault should not be null", aFault);
  
          assertTrue(aFault.getFaultCode().equals(FAULTCODE));
          assertTrue(aFault.getFaultReason().equals(FAULTREASON));
          assertTrue(aFault.getFaultRole().equals(FAULTROLE));
          assertTrue(aFault.getFaultNode().equals(FAULTNODE));
          QName q[] = aFault.getFaultSubCodes();
          for (int i = 0; i < q.length; i++)
              assertTrue(q[i].equals(FAULTSUBCODE[i]));
  
      }
  
  }
  
  
  
  1.1                  xml-axis/java/test/soap12/TestHrefs.java
  
  Index: TestHrefs.java
  ===================================================================
  package test.soap12;
  
  import junit.framework.TestCase;
  import org.apache.axis.Constants;
  import org.apache.axis.Message;
  import org.apache.axis.MessageContext;
  import org.apache.axis.message.RPCElement;
  import org.apache.axis.message.RPCParam;
  import org.apache.axis.message.SOAPEnvelope;
  import org.apache.axis.server.AxisServer;
  
  import java.util.Vector;
  
  /**
   * Test deserialization of SOAP 1.2 messages with references, by putting the
   * actual value in various places in the message.
   */
  public class TestHrefs extends TestCase {
  
      private String HEAD;
      private String HEADERT;
      private String BODYT;
  
      public TestHrefs(String name) {
          this(name, Constants.URI_DEFAULT_SCHEMA_XSI,
               Constants.URI_DEFAULT_SCHEMA_XSD);
      }
  
      public TestHrefs(String name, String NS_XSI, String NS_XSD) {
          super(name);
  
          HEAD =
                  "<?xml version=\"1.0\"?>\n" +
                  "<soap:Envelope " +
                  "xmlns:soap=\"http://www.w3.org/2002/06/soap-envelope\" " +
                  "xmlns:soapenc=\"http://www.w3.org/2002/06/soap-encoding\" " +
                  "xmlns:xsi=\"" + NS_XSI + "\" " +
                  "xmlns:xsd=\"" + NS_XSD + "\">\n" +
                  "<soap:Header>\n";
  
          HEADERT = "</soap:Header>\n" +
                    "<soap:Body>\n" +
                    "<methodResult xmlns=\"http://tempuri.org/\">\n";
  
          BODYT = "</methodResult>\n" +
                   "</soap:Body>\n" +
                   "</soap:Envelope>\n";
      }
  
      private void deserialize(String data, Object expected, int pos)
              throws Exception
      {
          Message message = new Message(data);
          message.setMessageContext(new MessageContext(new AxisServer()));
  
          SOAPEnvelope envelope = (SOAPEnvelope)message.getSOAPEnvelope();
          assertNotNull("SOAP envelope should not be null", envelope);
  
          RPCElement body = (RPCElement)envelope.getFirstBody();
          assertNotNull("SOAP body should not be null", body);
  
          Vector arglist = body.getParams();
          assertNotNull("arglist", arglist);
          assertTrue("SOAP param.size()<=0 {Should be > 0}", arglist.size()>0);
  
          RPCParam param = (RPCParam) arglist.get(pos);
          assertNotNull("SOAP param should not be null", param);
  
          Object result = param.getValue();
          assertEquals("Expected result not received", expected, result);
      }
  
      public void testStringReference1() throws Exception {
          String result = HEAD + HEADERT +
                          "<result root=\"0\" id=\"1\" xsi:type=\"xsd:string\">abc</result>" +
                          "<reference ref=\"#1\"/>\n" +
                          BODYT;
          deserialize(result, "abc", 1);
      }
  
      public void testIntReference1() throws Exception {
          String result = HEAD + HEADERT +
                          "<result root=\"0\" id=\"1\" xsi:type=\"xsd:int\">567</result>" +
                          "<reference ref=\"#1\"/>\n" +
                          BODYT;
          deserialize(result, new Integer(567), 1);
      }
  
      public void testStringReferenceInHeader() throws Exception {
          String result = HEAD +
                          "<result root=\"0\" id=\"1\" xsi:type=\"xsd:string\">abc</result>" +
                          HEADERT +
                          "<reference ref=\"#1\"/>\n" +
                          BODYT;
          deserialize(result, "abc", 0);
      }
  
  }
  
  
  1.1                  xml-axis/java/test/soap12/TestRPC.java
  
  Index: TestRPC.java
  ===================================================================
  package test.soap12;
  
  import junit.framework.TestCase;
  import org.apache.axis.AxisFault;
  import org.apache.axis.Message;
  import org.apache.axis.MessageContext;
  import org.apache.axis.configuration.SimpleProvider;
  import org.apache.axis.description.ServiceDesc;
  import org.apache.axis.handlers.soap.SOAPService;
  import org.apache.axis.message.RPCElement;
  import org.apache.axis.message.RPCParam;
  import org.apache.axis.message.SOAPEnvelope;
  import org.apache.axis.providers.java.RPCProvider;
  import org.apache.axis.server.AxisServer;
  import org.apache.axis.soap.SOAPConstants;
  import org.apache.axis.transport.local.LocalTransport;
  import org.w3c.dom.Element;
  import org.w3c.dom.NodeList;
  import org.xml.sax.SAXException;
  
  import java.util.Vector;
  
  /**
   * A test for RPC response
   *
   * @author Andras Avar (andras.avar@nokia.com)
   */
  public class TestRPC extends TestCase {
  
      private SimpleProvider provider = new SimpleProvider();
      private AxisServer server = new AxisServer(provider);
  
      public TestRPC(String name) {
          super(name);
          server.init();
      }
  
      private RPCElement rpc(String method, Object[] params)
          throws AxisFault, SAXException
      {
          String SERVICE_NAME = "echoservice";
          LocalTransport transport = new LocalTransport(server);
  
          SOAPService service = new SOAPService(new RPCProvider());
          service.setOption("className", "test.soap12.Echo");
          service.setOption("allowedMethods", "*");
  
          ServiceDesc desc = service.getInitializedServiceDesc(null);
          desc.setDefaultNamespace(method);
  
          provider.deployService(SERVICE_NAME, service);
  
          MessageContext msgContext = new MessageContext(server);
          msgContext.setSOAPConstants(SOAPConstants.SOAP12_CONSTANTS);
  
          String methodNS = null;
          msgContext.setTargetService(SERVICE_NAME);
  
          // Construct the soap request
          SOAPEnvelope envelope = new SOAPEnvelope();
          msgContext.setRequestMessage(new Message(envelope));
          RPCElement body = new RPCElement(methodNS, method, params);
  
          envelope.addBodyElement(body);
  
          server.invoke(msgContext);
  
          Message message = msgContext.getResponseMessage();
          envelope = (SOAPEnvelope)message.getSOAPEnvelope();
          assertNotNull("SOAP envelope was null", envelope);
          body = (RPCElement)envelope.getFirstBody();
  
          return body;
      }
  
      public void testRPCReturn() throws Exception {
  
          RPCElement body = rpc("echo", new Object[] {"abc"});
          assertNotNull("SOAP body was null", body);
  
          // Check RPC result
          Vector arglist = body.getParams();
          assertNotNull("SOAP argument list was null", arglist);
          RPCParam param = (RPCParam) arglist.get(1);
          assertTrue("Not expected result", ((String)param.getValue()).equals("abc"));
  
          // Check DOM
          Element e = body.getAsDOM();
          NodeList l = e.getElementsByTagNameNS("http://www.w3.org/2002/06/soap-rpc","result");
          assertTrue("No result element was fount", l.getLength() == 1);
          String ptr = l.item(0).getFirstChild().getNodeValue();
          assertNotNull("Ptr to the result value was null", ptr);
          l = e.getElementsByTagName(ptr);
          assertTrue("No return element was fount", l.getLength() == 1);
          String res = l.item(0).getFirstChild().getNodeValue();
          assertTrue("Not expected result", res.equals("abc"));
      }
  }
  
  
  
  1.21      +4 -2      xml-axis/java/src/org/apache/axis/handlers/MD5AttachHandler.java
  
  Index: MD5AttachHandler.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/MD5AttachHandler.java,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- MD5AttachHandler.java	11 Dec 2002 22:38:18 -0000	1.20
  +++ MD5AttachHandler.java	20 Dec 2002 17:28:22 -0000	1.21
  @@ -60,6 +60,7 @@
   import org.apache.axis.Message;
   import org.apache.axis.MessageContext;
   import org.apache.axis.components.logger.LogFactory;
  +import org.apache.axis.soap.SOAPConstants;
   import org.apache.axis.utils.Messages;
   import org.apache.commons.logging.Log;
   
  @@ -78,6 +79,7 @@
           try {
               // log.debug("IN MD5");        
               Message  msg = msgContext.getRequestMessage();
  +            SOAPConstants soapConstants = msgContext.getSOAPConstants();
               org.apache.axis.message.SOAPEnvelope env = (org.apache.axis.message.SOAPEnvelope) msg.getSOAPEnvelope();
               org.apache.axis.message.SOAPBodyElement sbe = env.getFirstBody();//env.getBodyByName("ns1", "addedfile");
               org.w3c.dom.Element sbElement = sbe.getAsDOM();
  @@ -87,7 +89,7 @@
               for (; n != null && !(n instanceof org.w3c.dom.Element); n = n.getNextSibling());
               org.w3c.dom.Element paramElement = (org.w3c.dom.Element) n;
               //Get the href associated with the attachment.
  -            String href = paramElement.getAttribute(org.apache.axis.Constants.ATTR_HREF);
  +            String href = paramElement.getAttribute(soapConstants.getAttrHref());
               org.apache.axis.Part ap = msg.getAttachmentsImpl().getAttachmentByReference(href);
               javax.activation.DataHandler dh = org.apache.axis.attachments.AttachmentUtils.getActivationDataHandler(ap);
               org.w3c.dom.Node timeNode = paramElement.getFirstChild();
  @@ -136,7 +138,7 @@
               n = sbElement.getFirstChild();
               for (; n != null && !(n instanceof org.w3c.dom.Element); n = n.getNextSibling());
               paramElement = (org.w3c.dom.Element) n;
  -            // paramElement.setAttribute(org.apache.axis.Constants.ATTR_HREF, respHref);
  +            // paramElement.setAttribute(soapConstants.getAttrHref(), respHref);
               String MD5String = org.apache.axis.encoding.Base64.encode(md.digest());
               String senddata = " elapsedTime=" + elapsedTimeStr + " MD5=" + MD5String;
   
  
  
  
  1.140     +7 -6      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.139
  retrieving revision 1.140
  diff -u -r1.139 -r1.140
  --- MessageElement.java	11 Dec 2002 22:38:20 -0000	1.139
  +++ MessageElement.java	20 Dec 2002 17:28:22 -0000	1.140
  @@ -237,18 +237,19 @@
                   }
               }
   
  -            href = attributes.getValue(Constants.ATTR_HREF);
  -
  -            // If there's an arrayType attribute, we can pretty well guess that we're an Array???
  -            if (attributes.getValue(Constants.URI_DEFAULT_SOAP_ENC, Constants.ATTR_ARRAY_TYPE) != null)
  -                typeQName = Constants.SOAP_ARRAY;
  -
               // Set the encoding style to the attribute value.  If null,
               // we just automatically use our parent's (see getEncodingStyle)
               MessageContext mc = context.getMessageContext();
               SOAPConstants sc = (mc != null) ?
                                               mc.getSOAPConstants() :
                                               SOAPConstants.SOAP11_CONSTANTS;
  +
  +            href = attributes.getValue(sc.getAttrHref());
  +
  +            // If there's an arrayType attribute, we can pretty well guess that we're an Array???
  +            if (attributes.getValue(Constants.URI_DEFAULT_SOAP_ENC, Constants.ATTR_ARRAY_TYPE) != null)
  +                typeQName = Constants.SOAP_ARRAY;
  +
   
               encodingStyle =
                       attributes.getValue(sc.getEncodingURI(),
  
  
  
  1.69      +8 -0      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.68
  retrieving revision 1.69
  diff -u -r1.68 -r1.69
  --- RPCHandler.java	11 Dec 2002 22:38:20 -0000	1.68
  +++ RPCHandler.java	20 Dec 2002 17:28:22 -0000	1.69
  @@ -70,6 +70,7 @@
   import org.apache.axis.encoding.MethodTarget;
   import org.apache.axis.utils.JavaUtils;
   import org.apache.axis.utils.Messages;
  +import org.apache.axis.soap.SOAPConstants;
   import org.apache.commons.logging.Log;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
  @@ -171,6 +172,13 @@
           QName type = null;
           QName qname = new QName(namespace, localName);
           ParameterDesc paramDesc = null;
  +
  +        SOAPConstants soapConstants = context.getMessageContext().getSOAPConstants();
  +        if (soapConstants == SOAPConstants.SOAP12_CONSTANTS &&
  +            Constants.QNAME_RPC_RESULT.equals(qname)) {
  +            // TODO: fix it ... now we just skip it
  +            return new DeserializerImpl();
  +        }
   
           Vector params = rpcElem.getParams();
           
  
  
  
  1.7       +3 -1      xml-axis/java/src/org/apache/axis/message/SOAPFaultDetailsBuilder.java
  
  Index: SOAPFaultDetailsBuilder.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPFaultDetailsBuilder.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SOAPFaultDetailsBuilder.java	11 Dec 2002 22:38:20 -0000	1.6
  +++ SOAPFaultDetailsBuilder.java	20 Dec 2002 17:28:22 -0000	1.7
  @@ -64,6 +64,7 @@
   import org.apache.axis.encoding.Deserializer;
   import org.apache.axis.encoding.DeserializerImpl;
   import org.apache.axis.utils.ClassUtils;
  +import org.apache.axis.soap.SOAPConstants;
   import org.xml.sax.Attributes;
   import org.xml.sax.SAXException;
   
  @@ -106,6 +107,7 @@
           // Look up this element in our faultMap
           // if we find a match, this element is the fault data
           MessageContext msgContext = context.getMessageContext();
  +        SOAPConstants soapConstants = msgContext.getSOAPConstants();
           OperationDesc op = msgContext.getOperation();
           if (op != null) {
               FaultDesc faultDesc = op.getFaultByQName(qn);
  @@ -129,7 +131,7 @@
                   builder.setWaiting(true);
                   // register callback for the data, use the xmlType from fault info
                   Deserializer dser = null;
  -                if (attributes.getValue("href") == null) {
  +                if (attributes.getValue(soapConstants.getAttrHref()) == null) {
                       dser = context.getDeserializerForType(faultDesc.getXmlType());
                   } else {
                       dser = new DeserializerImpl();
  
  
  
  1.18      +2 -2      xml-axis/java/src/org/apache/axis/message/SOAPHeaderElement.java
  
  Index: SOAPHeaderElement.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/message/SOAPHeaderElement.java,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- SOAPHeaderElement.java	11 Dec 2002 22:38:20 -0000	1.17
  +++ SOAPHeaderElement.java	20 Dec 2002 17:28:22 -0000	1.18
  @@ -111,7 +111,7 @@
                                            Constants.ATTR_MUST_UNDERSTAND);
   
           if (soapConstants == SOAPConstants.SOAP12_CONSTANTS)
  -            mustUnderstand = ((val != null) && val.equals("true")) ? true : false;
  +            mustUnderstand = ((val != null) && (val.equals("true") || val.equals("1"))) ? true : false;
           else
               mustUnderstand = ((val != null) && val.equals("1")) ? true : false;
   
  @@ -153,7 +153,7 @@
                                            Constants.ATTR_MUST_UNDERSTAND);
   
           if (soapConstants == SOAPConstants.SOAP12_CONSTANTS)
  -            mustUnderstand = ((val != null) && val.equals("true")) ? true : false;
  +            mustUnderstand = ((val != null) && (val.equals("true") || val.equals("1"))) ? true : false;
           else
               mustUnderstand = ((val != null) && val.equals("1")) ? true : false;
   
  
  
  
  1.38      +1 -0      xml-axis/java/src/org/apache/axis/i18n/resource.properties
  
  Index: resource.properties
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/i18n/resource.properties,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- resource.properties	18 Dec 2002 00:39:55 -0000	1.37
  +++ resource.properties	20 Dec 2002 17:28:22 -0000	1.38
  @@ -992,6 +992,7 @@
   
   onlyOneBodyFor12=Only one body allowed for SOAP 1.2 RPC
   noElemAfterBody12=No element allowed after SOAP 1.2 body
  +noSparseArray=Partially transmitted and sparse arrays is not supported in SOAP 1.2
   differentTypes00=Error: The input and output parameter have the same name, ''{0}'', but are defined with type ''{1}'' and also with type ''{2}''.
   
   badMsgMethodParam=Message service must take either a single Vector or a Document - method {0} takes a single {1}
  
  
  
  1.102     +8 -6      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.101
  retrieving revision 1.102
  diff -u -r1.101 -r1.102
  --- RPCProvider.java	11 Dec 2002 22:38:21 -0000	1.101
  +++ RPCProvider.java	20 Dec 2002 17:28:22 -0000	1.102
  @@ -325,15 +325,17 @@
                       returnQName = new QName("", methodName + "Return");
                   }
                   
  -                // For SOAP 1.2, add a result
  -                if (msgContext.getSOAPConstants() ==
  -                        SOAPConstants.SOAP12_CONSTANTS) {
  -                    returnQName = Constants.QNAME_RPC_RESULT;
  -                }
  -
                   RPCParam param = new RPCParam(returnQName, objRes);
                   param.setParamDesc(operation.getReturnParamDesc());
  +
                   if (!operation.isReturnHeader()) {
  +                    // For SOAP 1.2 rpc style, add a result
  +                    if (msgContext.getSOAPConstants() == SOAPConstants.SOAP12_CONSTANTS &&
  +                            !(serviceDesc.getStyle().equals(Style.DOCUMENT))) {
  +                        RPCParam resultParam = new RPCParam(Constants.QNAME_RPC_RESULT, returnQName);
  +                        resultParam.setXSITypeGeneration(Boolean.FALSE);
  +                        resBody.addParam(resultParam);
  +                    }
                       resBody.addParam(param);
                   } else {
                       resEnv.addHeader(new RPCHeaderParam(param));
  
  
  
  1.8       +15 -0     xml-axis/java/src/org/apache/axis/soap/SOAP11Constants.java
  
  Index: SOAP11Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/soap/SOAP11Constants.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SOAP11Constants.java	16 Oct 2002 15:03:04 -0000	1.7
  +++ SOAP11Constants.java	20 Dec 2002 17:28:23 -0000	1.8
  @@ -113,4 +113,19 @@
       public String getNextRoleURI() {
           return Constants.URI_SOAP11_NEXT_ACTOR;
       }
  +
  +    /**
  +     * Obtain the ref attribute name
  +     */
  +    public String getAttrHref() {
  +        return Constants.ATTR_HREF;
  +    }
  +
  +    /**
  +     * Obtain the item type name of an array
  +     */
  +    public String getAttrItemType() {
  +        return Constants.ATTR_ARRAY_TYPE;
  +    }
  +
   }
  
  
  
  1.9       +16 -0     xml-axis/java/src/org/apache/axis/soap/SOAP12Constants.java
  
  Index: SOAP12Constants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/soap/SOAP12Constants.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SOAP12Constants.java	16 Oct 2002 15:03:04 -0000	1.8
  +++ SOAP12Constants.java	20 Dec 2002 17:28:23 -0000	1.9
  @@ -118,4 +118,20 @@
       public String getNextRoleURI() {
           return Constants.URI_SOAP12_NEXT_ACTOR;
       }
  +
  +    /**
  +     * Obtain the ref attribute name
  +     */
  +    public String getAttrHref() {
  +        return Constants.ATTR_REF;
  +    }
  +
  +    /**
  +     * Obtain the item type name of an array
  +     */
  +    public String getAttrItemType() {
  +        return Constants.ATTR_ITEM_TYPE;
  +    }
  +
  +
   }
  
  
  
  1.9       +14 -0     xml-axis/java/src/org/apache/axis/soap/SOAPConstants.java
  
  Index: SOAPConstants.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/soap/SOAPConstants.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SOAPConstants.java	11 Dec 2002 22:38:22 -0000	1.8
  +++ SOAPConstants.java	20 Dec 2002 17:28:23 -0000	1.9
  @@ -113,4 +113,18 @@
        * Obtain the "next" role/actor URI
        */ 
       public String getNextRoleURI();
  +
  +    /**
  +     * Obtain the href attribute name
  +     */
  +    public String getAttrHref();
  +
  +    /**
  +     * Obtain the item type name of an array
  +     */
  +    public String getAttrItemType();
  +
  +
  +
  +
   }
  
  
  
  1.91      +6 -6      xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java
  
  Index: SOAPService.java
  ===================================================================
  RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/handlers/soap/SOAPService.java,v
  retrieving revision 1.90
  retrieving revision 1.91
  diff -u -r1.90 -r1.91
  --- SOAPService.java	11 Dec 2002 22:38:19 -0000	1.90
  +++ SOAPService.java	20 Dec 2002 17:28:23 -0000	1.91
  @@ -162,11 +162,11 @@
       }
   
       /**
  -     * SOAPRequestHandler is used to inject SOAP semantics just before
  +     * SOAPResponseHandler is used to inject SOAP semantics just before
        * the pivot handler.
        */
  -    private class SOAPRequestHandler extends BasicHandler {
  -        public SOAPRequestHandler() {}
  +    private class SOAPResponseHandler extends BasicHandler {
  +        public SOAPResponseHandler() {}
   
           public void invoke(MessageContext msgContext) throws AxisFault {
               // Do SOAP semantics here
  @@ -217,7 +217,7 @@
   
                           SOAPHeaderElement newHeader = new
                               SOAPHeaderElement(Constants.URI_SOAP12_FAULT,
  -                                              Constants.ELEM_MISUNDERSTOOD);
  +                                              Constants.ELEM_NOTUNDERSTOOD);
                           newHeader.addAttribute(null,
                                                  Constants.ATTR_QNAME,
                                                  badQName);
  @@ -254,7 +254,7 @@
       public SOAPService(Handler reqHandler, Handler pivHandler,
                          Handler respHandler) {
           this();
  -        init(reqHandler, new SOAPRequestHandler(), pivHandler, null, respHandler);
  +        init(reqHandler, null, pivHandler, new SOAPResponseHandler(), respHandler);
       }
   
       public TypeMappingRegistry getTypeMappingRegistry()
  @@ -267,7 +267,7 @@
        */
       public SOAPService(Handler serviceHandler)
       {
  -        init(null, new SOAPRequestHandler(), serviceHandler, null, null);
  +        init(null, null, serviceHandler, new SOAPResponseHandler(), null);
       }
   
       /** Tell this service which engine it's deployed to.
  
  
  

Mime
View raw message