axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mai Sun (JIRA)" <j...@apache.org>
Subject [jira] Commented: (AXIS2-3418) Unexpected subelement - pojo - Inherited Complex Type
Date Tue, 22 Jan 2008 08:40:34 GMT

    [ https://issues.apache.org/jira/browse/AXIS2-3418?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12561258#action_12561258
] 

Mai Sun commented on AXIS2-3418:
--------------------------------

Hi,

I also noticed this problem which causes .NET client cannot see values defined in super class.
I modified the BeanUtil so that it appends elements from super class first, please see my
modification below:

   // properties from JAM
   ArrayList propertyList = new ArrayList();
   JProperty properties[] = jClass.getDeclaredProperties();
   for (int i = 0; i < properties.length; i++) {
    JProperty property = properties[i];
    propertyList.add(property);    
   }
   Collections.sort(propertyList);
   JClass supClass = jClass.getSuperclass();
   while (!"java.lang.Object".equals(supClass.getQualifiedName())) {
    ArrayList list = new ArrayList();
    properties = supClass.getDeclaredProperties();
    for (int i = 0; i < properties.length; i++) {
     JProperty property = properties[i];
     // Changed by MSU to make sure inheritance works!
     list.add(property);
     // propertyList.add(property);
    }
    Collections.sort(list);
    // Added by MSU
    for (int i = 0; i < propertyList.size(); i++) {
     list.add(propertyList.get(i));
    }
    propertyList = list;
    supClass = supClass.getSuperclass();
   }



Regards,
Mai Sun

> Unexpected subelement - pojo - Inherited Complex Type
> -----------------------------------------------------
>
>                 Key: AXIS2-3418
>                 URL: https://issues.apache.org/jira/browse/AXIS2-3418
>             Project: Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: adb
>    Affects Versions: 1.3
>         Environment: jdk jdk1.5.0_14, axis2 1.3, Fedora 8, Intel x86
>            Reporter: Mehmet Döngel
>            Priority: Critical
>         Attachments: AddressBookService_NotWorking.wsdl, AddressBookService_Working.wsdl,
BeanUtil.java, pojo_NotWorking.tar.gz, pojo_Working.tar.gz
>
>
> $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?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


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


Mime
View raw message