Hi,
Previously I have used wsdl2java with no binding configuration, and the
generated classes has been working fine. But when I now added more
functionallity to the webservice I noticed that the generated List fields
wasn't proper javabean properties (since they lacked a setter method), and that
didn't work well together with Apache Commons BeanUtilsBean. The result was
that all List fields were silently ignored when I used the copyProperties
method (so I don't have to manually copy all properties from the generated
class into my own java beans).
Then I noticed that I can use a binding file, and set collectionType="indexed"
in the globalBindings-tag, and thereby make CXF/JAXB generate classes with
array fields, and they are proper javabean fields, with a getter and a setter
method.
BUT... now I noticed that the generated setter method has no null-check. The
first thing it does is:
int len = values.length;
...and that ofcourse causes a NPE if the array is null, something that is not
that uncommon. And one would think that the setter method supports null, since
the wsdl schema specifically states nillable="true" for the field, in the
complexType definition.
Is there a specific reason for not having a null-check here? Why not simply do
like this:
if (values == null) {
this.myArrayField = null;
} else {
int len = values.length;
....
Does anyone know? Maybe this is some setting one can provide in the binding
file to fix this? Or is this a known bug?
Regards
/Jimi