Thanks for your reply Keith.
But I think it is still wrong.
Even if it is nillable=true ,still inside the serialize() method, it has the 
same coding.
You have to look the serialize method of the SurnameType class(not in the 
PersonEntityType).
In the PersonEntityType class, it may identify it as a nillable = true, but it 
is useless because when it goes to the serialize method of the  SurnameType 
class, it still has that validation:
if (localSurnameType ==null){
  throw new org.apache.axis2.databinding.ADBException("Value cannot be null 
!!");
}else{
   xmlWriter.writeCharacters(localTelephoneNumberType);
}

I think you understand the problem and hope to hear a solution from you.

Thank you.
Regards,
Simen

-----Original Message-----
From: keith chapman [mailto:[EMAIL PROTECTED]
Sent: Friday, 8 August 2008 3:30 PM
To: [email protected]
Subject: Re: Bug in axis2 wsdl2java ?

Hi Shehan,

This is not a bug. The element for surname is as follows,

<xs:element name="surname" type="tns:SurnameType" minOccurs="0" />

It just says minOccurs="0" which means that surname is optional. But
if surname is present it cannot be null and should have some value
(According to the schema above). If you expect surname to be null then
you should change your schema to have the nillable="true" attribute as
below

<xs:element name="surname" type="tns:SurnameType" minOccurs="0"
nillable="true"/>

With the above schema you can send surname as nul.

Thanks,
Keith.

On Fri, Aug 8, 2008 at 10:14 AM, Shehan Simen <[EMAIL PROTECTED]> wrote:
>
> 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.


--
Keith Chapman
Senior Software Engineer
WSO2 Inc.
Oxygenating the Web Service Platform.
http://wso2.org/

blog: http://www.keith-chapman.org

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to