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 "Eric George (JIRA)" <ax...@ws.apache.org> on 2006/11/13 23:51:37 UTC

[jira] Created: (AXIS-2591) Unmarshal error in generated objects for lists elements

Unmarshal error in generated objects for lists elements
-------------------------------------------------------

                 Key: AXIS-2591
                 URL: http://issues.apache.org/jira/browse/AXIS-2591
             Project: Apache Axis
          Issue Type: Bug
          Components: WSDL processing
    Affects Versions: 1.4
         Environment: Client running Axis1.4/Java 1.5.0_06/Linux 2.6.15
Server (unaffected by bug) running XFire 1.2.2/XMLBeans 2.1.0/Spring 2.0/Geronimo 1.1.1/Java 1.5.0_06/Linux 2.6.15
            Reporter: Eric George
            Priority: Minor


The objects created by WSDL2Java for certain schemas result in an unmarshal error while reading valid objects.  Here is a sample schema, describing a container which has an element which is a list.

    <xs:complexType name="One">
      <xs:sequence>
        <xs:element maxOccurs="1" minOccurs="0" name="foo" type="xs:string"/>
      </xs:sequence>
    </xs:complexType>
    <xs:element name="One" type="containertest:One"/>
    
    <xs:complexType name="Multi">
      <xs:sequence>
        <xs:element maxOccurs="unbounded" minOccurs="0" ref="containertest:One"/>
      </xs:sequence>
    </xs:complexType>
    
    <xs:complexType name="Container">
      <xs:sequence>
        <xs:element name="multi" minOccurs="0" maxOccurs="1" type="containertest:Multi" />
      </xs:sequence>
    </xs:complexType>
    <xs:element name="Container" type="containertest:Container"/>

I generated stubs and beans using WSDL2Java for a schema like this.  While demarshalling a valid element of type Container, an error like the following is encountered:

org.xml.sax.SAXException: Invalid element in containertest.One - One
    [junit]     at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:258)
    [junit]     at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
    [junit]     at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)

It seems that it is confusing the element of type "Multi" as being of type "One" possibly due to its efforts to optimize "Multi" into an array of One objects.

The following schema change is a valid workaround

    <!-- Add a new top-level element called "Multi" -->
    <xs:element name="Multi" type="containertest:Multi"/>
    <xs:complexType name="Container">
      <xs:sequence>
        <!-- Change element of type Multi to point to existing element instead -->
        <xs:element minOccurs="0" maxOccurs="1" ref="Multi" />
      </xs:sequence>
    </xs:complexType>

This is probably a better schema, however, WSDL2Java should create valid objects out of valid schema.


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org