WSDL2Java的.Apache CXF.ArrayOf {Type}到List <Type>

Ale*_*der 9 apache wsdl cxf jaxb

如何生成List<Type>ArrayOf {Type}?例如方法返回

[WebMethod]
public List<long> GetSimple()
Run Code Online (Sandbox Code Playgroud)

WSDL2Java将生成:

public ru.test.ws.ArrayOfLong GetSimple();
Run Code Online (Sandbox Code Playgroud)

ArrayOfLong:

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ArrayOfLong", propOrder = {
    "_long"
})
public class ArrayOfLong
    implements Serializable
{
    @XmlElement(name = "long", type = Long.class)
    protected List<Long> _long;

    public List<Long> getLong() {
        if (_long == null) {
            _long = new ArrayList<Long>();
        }
        return this._long;
    }
}
Run Code Online (Sandbox Code Playgroud)

如何配置CXF和JAXB来List<Long>代替ArrayOfLong?

OnR*_*lve 2

2件事:

1)确保<jxb:globalBindings collectionType="indexed"/> 存在。它将把所有集合转换为数组。

@WebResult2)尝试使用注释强制类型

希望这可以帮助。