You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Chen Zhang <cz...@linkshare.com> on 2007/05/31 23:10:37 UTC
JavaBean Properties Order Sequence
Hello,
I am using Axis2 1.2 and my ws endpoint is a pojo class. The return type
is a java bean. No matter in what order I define the properties in the
java bean, Axis always sorts the property names in alphabetical order
and render them in that order in xml. Eg. my bean is defined as:
public class balance{
private String id;
private String name;
private int balance;
...//getters& setters
}
The xml schema that axis generates would be like(in alphabetical order
of the property names):
- <#> <xs:complexType name="Balance">
- <#> <xs:sequence>
<xs:element name="balance" nillable="true" type="xs:int" />
//becomes first because of alphabetic order
<xs:element name="id" nillable="true" type="xs:string" />
<xs:element name="name" type="xs:string" />
</xs:sequence>
And if I query the service thru REST, the response xml would be like:
...
<balance.../>
<id.../>
<name.../>
Is there a way that I can change the behavior of the formatter and the
sequence of the properties?
Thanks!
Re: JavaBean Properties Order Sequence
Posted by Deepal Jayasinghe <de...@opensource.lk>.
Hi Chen ,
There is no way to change that , and if you are going to do so you will
have issues as well. According to my experience Annogen behave
differently in different JVM and JDK , to overcome that I had to short
the bean property order. In the meantime we generate the correct XML
schema as well
> Hello,
>
> I am using Axis2 1.2 and my ws endpoint is a pojo class. The return
> type is a java bean. No matter in what order I define the properties
> in the java bean, Axis always sorts the property names in alphabetical
> order and render them in that order in xml. Eg. my bean is defined as:
>
> public class balance{
> private String id;
> private String name;
> private int balance;
> ...//getters& setters
> }
>
> The xml schema that axis generates would be like(in alphabetical order
> of the property names):
>
> - <#> <xs:complexType name="*Balance*">
> - <#> <xs:sequence>
> <xs:element name="*balance*" nillable="*true*" type="*xs:int*" />
> //becomes first because of alphabetic order
> <xs:element name="*id*" nillable="*true*" type="*xs:string*" />
> <xs:element name="*name*" type="*xs:string*" />
> </xs:sequence>
>
> And if I query the service thru REST, the response xml would be like:
>
> ...
> <balance.../>
> <id.../>
> <name.../>
>
> Is there a way that I can change the behavior of the formatter and the
> sequence of the properties?
>
> Thanks!
>
--
Thanks,
Deepal
................................................................
"The highest tower is built one brick at a time"
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org