Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 546
Alexander Avatar asked Jul 02 '12 10:07

Alexander


People also ask

How do I generate a class from WSDL using Apache CXF?

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.

How does wsdl2java work?

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.


1 Answers

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.

like image 157
OnResolve Avatar answered Sep 26 '22 09:09

OnResolve