Hi,
With my wsdl, I generated all the server side classes from wsdl2java tool in 
axis2 1.4.
See the following example:
<xs:complexType name="PersonEntityType">
            <xs:sequence>
                        <xs:element name="entityId" type="tns:EntityIdType"/>
                        <xs:element name="surname" type="tns:SurnameType" 
minOccurs="0" />
                        <xs:element name="givenName" type="tns:GivenNameType"/>
                        <xs:element name="middleNameOrInitials" 
type="tns:MiddleNameType" />
                        <xs:element name="registrationCustomerIdList" 
type="IdentifierListType" />
                        <xs:element name="driverLicence" 
type="tns:DriverLicenceType" />
                        <xs:element name="tradingNameList" 
type="tns:NameListType" />
            </xs:sequence>
</xs:complexType>

(EntityIdType, SurnameType, GivenNameType, MiddleNameType, IdentifierListType, 
DriverLicenceType and NameListType are simple types of String)

Now, I want to get the OMElement from the  PersonEntityType.
So I will use the method personEntityType.getOMElement() which is generated by 
wsdl2java.
The Surname is optional. But my client may have added a surname without any 
value inside(create a null SurnameType and insert to the PersonEntityType 
object), which is still valid according to the above schema.
So now, if I Call the  personEntityType.getOMElement(), an exception is raised 
as:
org.apache.axis2.databinding.ADBException("Value cannot be null !!")
This exception is raised from serialize() method (generated by wsdl2java) of 
the SurnameType class.

The code inside the serialize method is as follows:

if (localSurnameType ==null){
     throw new org.apache.axis2.databinding.ADBException("Value cannot be null 
!!");
 }else{
      xmlWriter.writeCharacters(localABNType);
  }

I think this is wrong. If the localSurnameType is null, it should not throw 
such exception (just do nothing is good enough), because still the xml is valid 
against the schema. So I had to modify around 150 classes to remove this 
exception throw, which was a real pain.

Also, in the SetSurnameType() method, which is auto generated by wsdl2java, has 
a code as bellow:
if (  (java.lang.String.valueOf(param).length() <= 10)  )
{
     this. localSurnameType =param;
}else {
     throw new java.lang.RuntimeException();
}
So if the surname length is 11, it will end up with an unknown exception and my 
web service client does not have any clue of what is wrong.
I think axis2 should return more sensible format exceptions in this kind of 
situations. Otherwise we always have to modify the generated classes which is a 
real pain.
Has anyone experienced same kind of problems? I would like to know your 
suggestions.

Thanks.

Reply via email to