axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stig Hagen Dommarsnes <>
Subject inconsistency in bean serialization vs. java2wsdl
Date Wed, 20 Mar 2002 19:35:07 GMT

congratulations on beta1 - great work!

Now, in 'beta1rc3' there seems to be a minor inconsistency between bean 
serialization and wsdl production. Consider this simplistic java bean:

public class MyBean {
   public MyBean() {}
   private String testField;

   public getTestField() { return testField; }

The wsdl for a service using this contains a complexType MyBean
<complexType name="MyBean">
     <element name="testField" nillable="true" type="xsd:string"/>

and the serialization of the field (leaving out the endless multiRef tag) is
    <testField xsi:type="xsd:string">field content</message>

which is fine. However, if we change the private field name from 
testField to testfield (lowercase 'f'), the wsdl type changes to
<complexType name="MyBean">
     <element name="TestField" nillable="true" type="xsd:string"/>

while the serialization is unchanged. This has lead to a couple of 
problems in interop using .NET web references, though it's easy to fix 
by renaming the field.

The problem seems to be that ser.BeanSerializer uses the property name 
from java.beans.Introspector (in BeanSerializer.serialize() around line 
160), while in wsdl.fromJava.ClassRep.addFields() uses the name of the 
accessor method (minus 'is'/'get') - with no case change - if no 
corresponding field (according to ClassRep.isJavaBeanNormal()) exists.

Whew. Anyway, a quick fix would be to add

name = name.substring(0,1).toLowerCase() + name.substring(1);

on line 379 in BeanSerializer (sorry, don't have diff here :( ).
Alternatively, it would be nice if this behaviour was documented, maybe 
as a FAQ (though the frequency of asking hasn't been too high yet...). I 
could type that one up.

Thanks for your patience through this rather lenghty mail,


Stig Hagen Dommarsnes
Partner, Machina AS / +47 55 96 21 25

View raw message