How to generate List<Type>
instead ArrayOf{Type} ?
For example method return
[WebMethod]
public List<long> GetSimple()
WSDL2Java will generate:
public ru.test.ws.ArrayOfLong GetSimple();
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?
You will have to make sure that you create an appropriate directory structure for your project and add the earlier shown hello. wsdl file to the specified folder. The wsdl2java plugin will compile this wsdl and create Apache CXF classes in a pre-defined folder.
wsdl2java takes a WSDL document and generates fully annotated Java code from which to implement a service. The WSDL document must have a valid portType element, but it does not need to contain a binding element or a service element. Using the optional arguments you can customize the generated code.
2 things:
1) make sure <jxb:globalBindings collectionType="indexed"/>
doesn't exist. It will turn all collections to arrays.
2) try to force the type with the @WebResult
annotation
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With