If the element is both minOccurs="0" and nillable=true, JAXB usually will 
generate the property as a JAXBElement<Type> instead of just Type.   In that 
case, if you specify the element, but it's value is null, you get the 
nil=true.  If you leave the full property as null, it should be skipped.  

Dan

On Wednesday, April 18, 2012 01:08:15 PM Arthur van Dorp wrote:
> Hello all
> 
> I've figured out what the problem with the AXIS2 server is: The service
> isn't using proper beans. There are two pairs of getters/setters which
> map to the same Java field. So you have my AXIS2 client send
> 
> <el1>x<el1>
> 
> and my CXF client send
> 
> <el1>x<el1>
> <el2 xsi:nil="true"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
> 
> The second line overwriting the field both setE1 and setE2 map to on
> deserialization...
> 
> So it's neither an AXIS2 nor a CFX problem but a sloppily programmed
> service...
> 
> I'd still be interested in a way to remove all those nil-elements as the
> requests would be much more readable.
> 
> Kind regards
> 
> Arthur
> 
> > Datum: Wed, 18 Apr 2012 11:37:35 +0200
> > Von: "Arthur van Dorp" <[email protected]>
> > Betreff: How to not add nil-elements if minOccurs="0"
> > 
> > Hi everybody
> > 
> > Using CXF 2.5.2 with JAXB for generating a client for an AXIS2
> > webservice:
> > 
> > The wsdl has many elements defined with minOccurs="0" and
> > nillable="true". CXF sends requests for such elements like this:
> > <ps1:myElement xsi:nil="true"
> > xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>
> > 
> > Completely reasonable. Strangely enough the webservice doesn't like
> > that.
> > When I remove all nil elements (they have minOccurs="0" after all) all
> > works well. Is there a way to force CXF/JAXB to not send elements with
> > minOccurs="0" which would otherwise be sent as nil-elements? This would
> > also save quite a bit on messages size. I've found many posts
> > concerning nil-elements and minOccurs, but none describing this
> > specific problem.
> > 
> > Thanks and regards
> > 
> > Arthur
-- 
Daniel Kulp
[email protected] - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com

Reply via email to