Since JAX-WS rely on JAXB, and since I observed the code that unpack the XML bean in JAX-B Reference Implementation, I guess the difference is not made and that a JAXWS client always return an empty collection, even the webservice result was a null element:
public T startPacking(BeanT bean, Accessor<BeanT, T> acc) throws AccessorException {
T collection = acc.get(bean);
if(collection==null) {
collection = ClassFactory.create(implClass);
if(!acc.isAdapted())
acc.set(bean,collection);
}
collection.clear();
return collection;
}
I agree that for best interoperability service contracts should be non ambiguous and avoid such differences, but it seems that the JAX-WS service I'm invoking (hosted on a Jboss server with Jbossws implementation) is always returning as expected a null empty collection (tested with SoapUI).
I used for my test code generated by wsimport. Return element is defined as:
@XmlElement(name = "return", nillable = true)
protected List<String> _return;
I even tested to change the Response class getReturn method from :
public List<String> getReturn() {
if (_return == null) {
_return = new ArrayList<String>();
}
return this._return;
}
to
public List<String> getReturn() {
return this._return;
}
but without success.
Any helpful information/comment regarding this problem is welcome !