简体   繁体   English

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

[英]WSDL2Java. Apache CXF. ArrayOf{Type} to List<Type>

How to generate List<Type> instead ArrayOf{Type} ? 如何生成List<Type>而不是ArrayOf {Type}? For example method return 例如方法返回

[WebMethod]
public List<long> GetSimple()

WSDL2Java will generate: WSDL2Java将生成:

public ru.test.ws.ArrayOfLong GetSimple();

ArrayOfLong: 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;
    }
}

How to configure CXF and JAXB to use List<Long> instead ArrayOfLong? 如何配置CXF和JAXB以使用List<Long>而不是ArrayOfLong?

2 things: 2件事:

1) make sure <jxb:globalBindings collectionType="indexed"/> doesn't exist. 1)确保<jxb:globalBindings collectionType="indexed"/> 存在。 It will turn all collections to arrays. 它会将所有集合转换为数组。

2) try to force the type with the @WebResult annotation 2)尝试使用@WebResult注释强制类型

Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM