Hi!
I'm getting this error:
WSDLToJava Error : Thrown by JAXB : undefined element declaration
'ns1:orderBy'
when trying to generate java stubs from the wsdl.
This is my original service:
@WebService(endpointInterface = "com.aaa.bbb.ccc.MyService")
public interface MyService {
[...]
@WebResult(name="MyList")
@WebMethod
MyList getItems( @WebParam(name="listId") int listId);
[...]
}
the MyList class:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {"items"})
@XmlRootElement(name = "myList")
public class MyList {
@XmlElement(required = true)
private List<Item> items;
public List<Item> getItems() {
if (items == null) {
items = new ArrayList<Item>();
}
return items;
}
public void setItems(List<Item> items) {
this.items = items;
}
}
The Item is a JAXB generated file from a schema:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"attributesPD",
"orderBy"
})
@XmlRootElement(name = "item")
public class Item {
@XmlElement(name = "attributes", required = true)
protected AttributesPD attributesPD;
protected Item.OrderBy orderBy;
@XmlAttribute
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlSchemaType(name = "token")
protected String id;
@XmlAttribute
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
@XmlSchemaType(name = "token")
protected String createdBy;
@XmlAttribute
@XmlSchemaType(name = "date")
protected XMLGregorianCalendar creationDate;
public AttributesPD getAttributesPD() {
return attributesPD;
}
public void setAttributesPD(AttributesPD value) {
this.attributesPD = value;
}
public Item.OrderBy getOrderBy() {
return orderBy;
}
public void setOrderBy(Item.OrderBy value) {
this.orderBy = value;
}
public String getId() {
return id;
}
public void setId(String value) {
this.id = value;
}
public String getCreatedBy() {
return createdBy;
}
public void setCreatedBy(String value) {
this.createdBy = value;
}
public XMLGregorianCalendar getCreationDate() {
return creationDate;
}
public void setCreationDate(XMLGregorianCalendar value) {
this.creationDate = value;
}
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
"orderedAttributeRef"
})
public static class OrderBy {
@XmlElement(required = true)
protected List<OrderedAttributeRefType> orderedAttributeRef;
public List<OrderedAttributeRefType> getOrderedAttributeRef() {
if (orderedAttributeRef == null) {
orderedAttributeRef = new
ArrayList<OrderedAttributeRefType>();
}
return this.orderedAttributeRef;
}
}
}
The wsdl generated by cxf:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://myservice.bbb.aaa.com/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="MyServiceImplService"
targetNamespace="http://myservice.bbb.aaa.com/">
<wsdl:types>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:tns="http://www.aaa.com/AaaOtherService"
attributeFormDefault="unqualified" elementFormDefault="qualified"
targetNamespace="http://www.aaa.com/AaaOtherService">
[...]
<xs:element name="item">
<xs:complexType>
<xs:sequence>
<xs:element ref="tns:attributes"/>
<xs:element minOccurs="0"
name="orderBy">
<xs:complexType>
<xs:sequence>
<xs:element
maxOccurs="unbounded" name="orderedAttributeRef"
type="tns:orderedAttributeRefType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="id" type="xs:token"/>
<xs:attribute name="createdBy"
type="xs:token"/>
<xs:attribute name="creationDate"
type="xs:date"/>
</xs:complexType>
</xs:element>
[...]
</xs:schema>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns="http://myservice.bbb.aaa.com/"
xmlns:ns1="http://www.aaa.com/AaaOtherService"
attributeFormDefault="unqualified" elementFormDefault="unqualified"
targetNamespace="http://myservice.bbb.aaa.com/">
<xs:import
namespace="http://www.aaa.com/AaaOtherService"/>
<xs:element name="myList">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded"
name="items">
<xs:complexType>
<xs:sequence>
<xs:element
ref="ns1:attributes"/>
<xs:element
minOccurs="0" ref="ns1:orderBy"/>
</xs:sequence>
<xs:attribute name="id"
type="xs:token"/>
<xs:attribute
name="createdBy" type="xs:token"/>
<xs:attribute
name="creationDate" type="xs:date"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
[...]
<xs:element name="getItemsResponse"
type="getItemsResponse"/>
<xs:complexType name="getItemsResponse">
<xs:sequence>
<xs:element minOccurs="0" ref="myList"/>
</xs:sequence>
</xs:complexType>
[...]
</xs:schema>
</wsdl:types>
[...]
</wsdl:definitions>
I think it's a bit weird that it defines myList as a sequence of the
elements that form an Item, instead of a sequence of items.
Anyway I'm not sure why it does not work if it is mostly all generated
code.
Any ideas?
Help or pointers very much appreciated!
MonicaAccelrys Limited (http://www.accelrys.com)
Registered office: 334 Cambridge Science Park, Cambridge, CB4 0WN, UK
Registered in England: 2326316