axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eran Chinthaka (JIRA)" <>
Subject [jira] Commented: (AXIS2-1254) ADB cannot handle null return value from service method
Date Wed, 04 Oct 2006 12:44:21 GMT
    [ ] 
Eran Chinthaka commented on AXIS2-1254:

Ok, I was working with this issue today and just saw this patch.

Anyway, the reason to the initial problem referred to in this issue was, ADB was not not allowing
to set null, even if   minOccurs=0. I fixed by checking the nullity, when you call the set
method (didn't commit the changes as I had more local changes which failed the build).

With that in mind, I don't think I can agree with you on the third point you have mentioned
above. IIUC, you must have the ability not to mention anything about nilable but to set minOccurs=0.
But you suggest to throw an exception in that case. 

One could argue about the meaning or the interpretation of "null" in java w.r.t. nillable
attribute and maxOccurs=0. IMO, if something is nillable then if the value is not set, you
should see xsi:nill. 
 1. if there is nothing mentioned about nillable
 2. maxOccurs=0
 3. User calls setXX(null), 

then the serialization should simply ignore that element. 

Let me take an example :

If the schema of the element Book is

 <element name="Book">
            <element name="name" type="xsd:string" minOccurs="0"/>
            <element name="author" type="xsd:string" minOccurs="0"/>

then if user calls

Book myBook = new Book();
myBook.setName("Handling Nulls");

then the serialization would be 

   <Name>Handling Nulls</Name>

But if the schema was 

<element name="Book">
            <element name="name" type="xsd:string" minOccurs="0"/>
            <element name="author" type="xsd:string" nillable="true"/>

Then the serialization will be 
   <Name>Handling Nulls</Name>
   <author xsi:nil="true" />

Dennis, please correct me if I am wrong. 

> ADB cannot handle null return value from service method
> -------------------------------------------------------
>                 Key: AXIS2-1254
>                 URL:
>             Project: Apache Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: databinding
>    Affects Versions: nightly
>         Environment: Linux, Java 1.5
>            Reporter: Dennis Sosnoski
>         Assigned To: Eran Chinthaka
>            Priority: Blocker
>         Attachments: ADBBeanTemplate.xsl-patch-041006.txt,
> When the response content is an optional element null should be a valid return value
from the corresponding method. I tried this with the following WSDL/schema fragment:
>       <element name="getBookResponse">
>         <complexType>
>           <sequence>
>             <element name="book" minOccurs="0" type="tns:BookInformation"/>
>           </sequence>
>         </complexType>
>       </element>
>   <wsdl:message name="getBookResponse">
>     <wsdl:part element="wns:getBookResponse" name="parameters"/>
>   </wsdl:message>
> The result was an error on the server side when the corresponding method returned null:
>      [java] Exception in thread "main" org.apache.axis2.AxisFault: java.lang.RuntimeException:
book cannot be null!!
>      [java]     at org.apache.axis2.description.OutInAxisOperationClient.execute(
>      [java]     at
>      [java]     at
>      ...
> A null return value should be accepted in this case, resulting in an empty wrapper element
(<getBookResponse/>, in this case).

This message is automatically generated by JIRA.
If you think it was sent incorrectly contact one of the administrators:
For more information on JIRA, see:


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message