wsimport creates unexpected rest code

238 views Asked by At

I have a wsdl with the following type fragment modeling a self association on an organisationunit:

...<xs:complexType name="OrganisationUnitBIAssocType">
 <xs:complexContent>
  <xs:extension base = "tns:OrgUnitBIType">
   <xs:sequence>
     <xs:element name ="ParentUnit" minOccurs="0" type="tns:OrgUnitBIType"/>
   </xs:sequence>
  </xs:extension>
 </xs:complexContent>
</xs:complexType>
<xs:complexType name="OrgUnitBIType">
 <xs:complexContent>
    <xs:extension base="tns:refableWebServiceParameterType">
      <xs:sequence>
       <xs:element name="Oid" type="xs:long"/>
       <xs:element name="NAme" type="xs:String"/>
      </xs:sequence>
    </xs:extension>
   </xs:complexContent>
</xs:complexType>...

The wsimport tool generates the following two Java classes for the organisationunit and the association:

@XmlAccessorType(XmlAccessType.Field)
@XmlType(name = "OrgUnitBIType", porpOrder = {"rest"})
@XmlSeeAlso({OrganisationUnitBIAssocType.class})

public class OrgUnitBIType extends RefableWebServiceParameterType
{
 @XmlElementRefs({
   @XmlElementRefs(name = "Name", type =JAXBElement.class, required = false),
   @XmlElementRefs(name = "Oid", type =JAXBElement.class, required = false)
    })
 protected List<JAXBElement<? extends Serializable>> rest;
 if(rest == null) {`
    rest = new ArrayList<JAXBElement<? extends Serializable>>();`
 }
 return this.rest;`
 }
}
@XmlAccessorType(XmlAccessType.Field)
@XmlType(name = "OrganisationUnitBIAssocType", porpOrder = {"rest"})
public class OrganisationUnitBIAssocType extends OrgUnitBIType {}

I am wondering why these JAXBElements appear. I would prefer code having getters and setters in a JAX-WS style without the getRest methods.

Does anybody know how to achieve this?

1

There are 1 answers

0
user8953399 On
protected List<JAXBElement<? extends Serializable>> rest;

Check for duplicate elements with the same name. wsimport generates a list instead of individual getter and setter if any of the elements are repeated.