2
由於JAX-WS依賴於JAXB,並且由於我觀察到在JAX-B Reference Implementation中解壓縮XML bean的代碼,我猜這個區別並沒有產生,JAXWS客戶端總是返回一個空集合,甚至是web服務結果是一個空元素:JAXWS客戶端是否將空集合和空集合值作爲返回值區分?
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;
}
我同意,最佳的互操作性服務合同應當是非模糊,避免這種差異,但似乎JAX-WS服務我調用(託管與將JBossWS一個JBoss服務器上實現)總是按預期返回一個空的空集合(用SoapUI測試)。
我用於由wsimport生成的測試代碼。 返回元素被定義爲:
@XmlElement(name = "return", nillable = true)
protected List<String> _return;
我甚至測試,以從改變的響應類getReturn方法:
public List<String> getReturn() {
if (_return == null) {
_return = new ArrayList<String>();
}
return this._return;
}
到
public List<String> getReturn() {
return this._return;
}
但沒有成功。
歡迎任何有關此問題的有用信息/評論!