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

Unexpected subelement - pojo - Inherited Complex Type

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Fixed
    • 1.3
    • None
    • adb
    • None
    • jdk jdk1.5.0_14, axis2 1.3, Fedora 8, Intel x86

    Description

      $AXİS2_HOME/samples/pojo sample,
      I created ZEntry class with "String custom" field and updated Entry class to extend ZEntry class, after deployment I build and run adb client and got
      org.apache.axis2.databinding.ADBException: Unexpected subelement city

      exception.

      Response Message:
      <?xml version='1.0' encoding='UTF-8'?>
      <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
      <soapenv:Body>
      <ns:findEntryResponse xmlns:ns="http://service.addressbook.sample">
      <ns:return xmlns:ax21="http://entry.addressbook.sample/xsd" type="sample.addressbook.entry.Entry">
      <ax21:city>Sesame City</ax21:city>
      <ax21:name>Abby Cadabby</ax21:name>
      <ax21:postalCode>11111</ax21:postalCode>
      <ax21:state>Sesame State</ax21:state>
      <ax21:street>Sesame Street</ax21:street>
      <ax21:custom xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
      </ns:return>
      </ns:findEntryResponse>
      </soapenv:Body>
      </soapenv:Envelope>

      Reason for that exception is that generated stub expects first "custom" element because schema for Entry and ZEntry class in wsdl is :

      *****************************************************************************************************************************************************************************************************************
      <xs:schema xmlns:ax21="http://entry.addressbook.sample/xsd" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://entry.addressbook.sample/xsd">
      <xs:complexType name="ZEntry">
      <xs:sequence>
      <xs:element minOccurs="0" name="custom" nillable="true" type="xs:string"/>
      </xs:sequence>
      </xs:complexType>
      <xs:complexType name="Entry">
      <xs:complexContent>
      <xs:extension base="ax21:ZEntry">
      <xs:sequence>
      <xs:element minOccurs="0" name="city" nillable="true" type="xs:string"/>
      <xs:element minOccurs="0" name="name" nillable="true" type="xs:string"/>
      <xs:element minOccurs="0" name="postalCode" nillable="true" type="xs:string"/>
      <xs:element minOccurs="0" name="state" nillable="true" type="xs:string"/>
      <xs:element minOccurs="0" name="street" nillable="true" type="xs:string"/>
      </xs:sequence>
      </xs:extension>
      </xs:complexContent>
      </xs:complexType>
      </xs:schema>
      *****************************************************************************************************************************************************************************************************************

      Reason for expected response (first Entry fields (city,name,postalCode,state,street) and then super class ZEntry fields (custom) ) is BeanUtil class takes all the fields and put to an arraylist and then sort that array list. Because ZEntry.custom field comes after Entry.xxx fields,custom element is serialized last.

      When I use AEntry class instead of ZEntry class, no problem occurs.

      My solution to this problem is changing BeanUtil class in such a way that, first get super class properties and sort that properties and then put to an arrayList containing all properties, and after that get sub class properties and sort that properties and then put to that arrayList.

      Any other ideas, solutions?

      Attachments

        1. AddressBookService_NotWorking.wsdl
          7 kB
          Mehmet Döngel
        2. AddressBookService_Working.wsdl
          7 kB
          Mehmet Döngel
        3. pojo_Working.tar.gz
          4 kB
          Mehmet Döngel
        4. pojo_NotWorking.tar.gz
          4 kB
          Mehmet Döngel
        5. BeanUtil.java
          38 kB
          Mehmet Döngel
        6. BeanUtil.java
          40 kB
          Mai Sun
        7. BeanUtil.java
          40 kB
          michael schiller

        Issue Links

          Activity

            People

              amilachinthaka Amila Chinthaka Suriarachchi
              mehmetd Mehmet Döngel
              Votes:
              1 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: