CXF wsdl2java - generate list without wrapper (static inner class)

I am trying to create a ws and I have a little problem with the cxf generated classes.

Whenever I try to create a list, it is generated as a field of a static inner class (wrapper).

eg

<xs:complexType name="customer">
    <xs:sequence>
        <xs:element name="customerId" type="xs:int"/>
        <xs:element name="orders">
            <xs:complexType>
                <xs:sequence>
                    <xs:element name="order" type="tns:order" maxOccurs="unbounded"/>
                </xs:sequence>
            </xs:complexType>
        </xs:element>
    </xs:sequence>
</xs:complexType>

<xs:complexType name="order">
    <xs:sequence>
        <xs:element name="id" type="xs:long" />
        <xs:element name="name" type="xs:string" />
    </xs:sequence>
</xs:complexType>

      

will generate

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "customer", propOrder = {
"customerId",
"orders"
})
public class Customer {

    protected int customerId;
    @XmlElement(required = true)
    protected Customer.Orders orders;
...
    public static class Orders {

        @XmlElement(required = true)
        protected List<Order> order;
...

      

and I would like to receive

public class Customer {

    protected int customerId;
    protected List<Order> orders;
...

      

xml for this type of example should look like this:

<customer>
    ...
    <orders>
        <order>
            <id></id>
            <name></name>
        </order>
        <order>
            <id></id>
            <name></name>
        </order>
        ...
    </orders>
</customer>

      

from what i understand @XmlRootElement can be used when executing java2wsdl, but is there a way to generate this class type from wsdl?

Customer.getOrders () is currently calling. getOrder () will return a list of orders which is a bit inconsistent

+3


source to share


1 answer


Struggling with the same problem (CXF wsdl2java) and solved it with jaxb-xew-plugin .



0


source







All Articles