Oh what a lot of time we've wasted on this...
We ran into the <... minOccurs="0" nillable="true">
minefield this
week... We've a Java CXF client talking to a (by way of what's effectively a proxy)
some services delivered from a third party. The WSDL exposed by the server we
were talking to had minOccurs="0" nillable="true"
, the downstream service was
insistent that we not send a tag if it was nil (using the XML serialisation),
only of course by saying minOccurs="0" nillable="true"
the server we were
talking to allowed two
representations and CXF/JAXB picked the wrong one.
So we fixed the WSDL (and then got all confused because no one had changed the embedded version...) and then started discovering all sorts of things we didn't know before!
Number one – if you've a JAXB binding file and are using
generateElementProperty
, it looks like it's Boolean, but actually it's
tri-state... confused the ... out of us for a while – more details here.
Number two – if you've got an element you want to be nil, don't even
initialise the member... if you're running with generateElementProperty
absent
or false
, you'll get empty tags generated even where minOccurs="0"
, not
initialising the member at all will omit the tag.