You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Amila Suriarachchi <am...@gmail.com> on 2010/01/05 09:40:58 UTC

Re: [Axis2] making minOccurs=1 by default for wsdl generated with POJO

On Tue, Jan 5, 2010 at 12:06 PM, Dennis Sosnoski <dm...@sosnoski.com> wrote:

> Hi Amila,
>
> It's definitely best to use minOccurs=1 for primitives. nillable=true is
> *not* a good choice in general, and I'd recommend you instead go with
> minOccurs=0 for object types.
>
> Why is nillable=true bad? 1. It requires the element to still be present in
> the message, adding unnecessary bloat (including the xsi namespace
> definition and usage) and confusion for human viewers of the message. 2. If
> required attributes are defined for the element (not an issue for POJO
> deployment, since it doesn't use attributes, but applicable in terms of the
> general use of nillable=true) those attributes need to be present even with
> xsi:nil=true in the document. minOccurs=0 is a cleaner representation of
> optional values.
>

if we use minOccurs=0 instead of nillable=true does that fix the issue given
here[1]. Currently POJO gives preference to nillable=true when returning
null objects.

thanks,
Amila.

[1] https://issues.apache.org/jira/browse/AXIS2-3300

>
>  - Dennis
>
> --
> Dennis M. Sosnoski
> Java XML and Web Services
> Axis2 Training and Consulting
> http://www.sosnoski.com - http://www.sosnoski.co.nz
> Seattle, WA +1-425-939-0576 - Wellington, NZ +64-4-298-6117
>
>
>
>
> Amila Suriarachchi wrote:
>
>> this is related to issue[1]
>>
>> I think it is better to make minOccurs=1 considering the following points
>> and the issue given here[1].
>>
>> 1. if the type is a primitive type then anyway it get assigned a value and
>> hence nillable=true and minOccurs=0 can not be supported.
>> 2. if not primitive always minOccurs=0 and nillable=true maps to null
>> value. hence nillable=true is enough.
>>
>> WDYT?
>>
>> [1] https://issues.apache.org/jira/browse/AXIS2-3300
>>
>> --
>> Amila Suriarachchi
>> WSO2 Inc.
>> blog: http://amilachinthaka.blogspot.com/
>>
>
>


-- 
Amila Suriarachchi
WSO2 Inc.
blog: http://amilachinthaka.blogspot.com/

Re: [Axis2] making minOccurs=1 by default for wsdl generated with POJO

Posted by Dennis Sosnoski <dm...@sosnoski.com>.
Amila Suriarachchi wrote:
>
>
> On Tue, Jan 5, 2010 at 12:06 PM, Dennis Sosnoski <dms@sosnoski.com 
> <ma...@sosnoski.com>> wrote:
>
>     Hi Amila,
>
>     It's definitely best to use minOccurs=1 for primitives.
>     nillable=true is *not* a good choice in general, and I'd recommend
>     you instead go with minOccurs=0 for object types.
>
>     Why is nillable=true bad? 1. It requires the element to still be
>     present in the message, adding unnecessary bloat (including the
>     xsi namespace definition and usage) and confusion for human
>     viewers of the message. 2. If required attributes are defined for
>     the element (not an issue for POJO deployment, since it doesn't
>     use attributes, but applicable in terms of the general use of
>     nillable=true) those attributes need to be present even with
>     xsi:nil=true in the document. minOccurs=0 is a cleaner
>     representation of optional values.
>
>
> if we use minOccurs=0 instead of nillable=true does that fix the issue 
> given here[1]. Currently POJO gives preference to nillable=true when 
> returning null objects.
>
> thanks,
> Amila.
>
> [1] https://issues.apache.org/jira/browse/AXIS2-3300

I think the .Net people prefer using nillable=true, for no good reason 
that I've ever seen presented - somehow they got the idea early on that 
xsi:nil="true" in an instance document is equivalent to a null value in 
code. It's not - required attributes still need to be present on the 
element, as mentioned before, and the element cannot be an abstract 
element in the schema definition (unlike in code, where you commonly use 
references with abstract types to hold either a null or an instance of 
any of the possible matching concrete types).

I'd say it's always a bad idea to specify *both* minOccurs="0" and 
nillable="true". I don't know offhand what .Net does if you only specify 
minOccurs="0", but from the discussion it sounds like it would probably 
still generate the flag variables - so if you want the schemas to be 
optimized for .Net you're probably better off using nillable="true" to 
fit with their misconceptions.

  - Dennis