Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-4923

Incorrect parse function for ArrayOfAnyType

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 1.5.4
    • 1.7.0
    • adb
    • None
    • Jave 1.5.0_08
      Tomcat 5.5.18
      Eclipse Helios Build id: 20100917-0705
      Axis2 Tools (Eclipse XML Editors and Tools) Version: 1.1.100.v201005241530-78-FF0DZRDKDDePSKwHj

    Description

      Autogeneration of a client using a WSDL with a segment like this:

      <s:complexType name="ArrayOfAnyType">
      <s:sequence>
      <s:element minOccurs="0" maxOccurs="unbounded" name="anyType" nillable="true"/>
      </s:sequence>
      </s:complexType>

      Generates a ArrayOfAnyType.Factory.parse method like this:

      try {
      while (!reader.isStartElement() && !reader.isEndElement())
      reader.next();

      if (reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type")!=null){
      java.lang.String fullTypeName = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance", "type");
      if (fullTypeName!=null){
      java.lang.String nsPrefix = null;
      if (fullTypeName.indexOf(":") > -1)

      { nsPrefix = fullTypeName.substring(0,fullTypeName.indexOf(":")); }

      nsPrefix = nsPrefix==null?"":nsPrefix;
      java.lang.String type = fullTypeName.substring(fullTypeName.indexOf(":")+1);
      if (!"ArrayOfAnyType".equals(type))

      { //find namespace for the prefix java.lang.String nsUri = reader.getNamespaceContext().getNamespaceURI(nsPrefix); return (ArrayOfAnyType)ExtensionMapper.getTypeObject(nsUri,type,reader); }

      }
      }

      // Note all attributes that were handled. Used to differ normal attributes
      // from anyAttributes.
      java.util.Vector handledAttributes = new java.util.Vector();

      reader.next();

      while (!reader.isStartElement() && !reader.isEndElement()) reader.next();

      if (reader.isStartElement()){
      nillableValue = reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil");
      if (!"true".equals(nillableValue) && !"1".equals(nillableValue))

      { java.lang.String content = reader.getElementText(); org.apache.axiom.om.OMFactory fac = org.apache.axiom.om.OMAbstractFactory.getOMFactory(); org.apache.axiom.om.OMNamespace omNs = fac.createOMNamespace("http://<removed>.com", ""); org.apache.axiom.om.OMElement _valueAnyType = fac.createOMElement("anyType", omNs); _valueAnyType.addChild(fac.createOMText(_valueAnyType, content)); object.setAnyType(_valueAnyType); }

      else

      { reader.getElementText(); // throw away text nodes if any. }

      reader.next();
      } // End of if for expected property start element
      else {

      }

      while (!reader.isStartElement() && !reader.isEndElement())
      reader.next();

      if (reader.isStartElement())

      { // A start element we are not expecting indicates a trailing invalid property throw new org.apache.axis2.databinding.ADBException("Unexpected subelement " + reader.getLocalName()); }

      } catch (javax.xml.stream.XMLStreamException e)

      { throw new java.lang.Exception(e); }

      Which basically reads the first element in the array and then treats the next one as an unexpected element. So the error "Unexpected element anyType" is produced.

      I regenerated the client using XMLBeans instead of ADB and it seems to be fine.

      Attachments

        Activity

          People

            Unassigned Unassigned
            andyc Andy Clark
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: