Best unofficial Apache Server developers community |
|
Hi,
I am newer to REST web service. Recently, I created a simple REST web service based on CXF 2.3.2: @Path("/luckynumbers") @Produces("text/plain") public class LuckyNumbers { @GET @Path("/getWADL") @Produces("application/xml") public ResponseWrapper getWADL(@QueryParam("") RequestWrapper arg) { return new ResponseWrapper(); } @XmlRootElement public static class ResponseWrapper { List<String> theList; String theResponse; public String getTheResponse() { return theResponse; } public void setTheResponse(String theResponse) { this.theResponse = theResponse; } @XmlElement(name="listItem") public List<String> getTheList() { return theList; } public void setTheList(List<String> theList) { this.theList = theList; } } @XmlRootElement public static class RequestWrapper { List<String> theList; String theRequest; @XmlElement(name="listItem") public Collection<String> getTheList() { return theList; } public void setTheList(List<String> theList) { this.theList = theList; } public String getTheRequest() { return theRequest; } public void setTheRequest(String theRequest) { this.theRequest = theRequest; } } } The WADL (generated by accessing in IE: http://localhost:8080/ws-rest-prototype/services/LuckyNumbersRest?_wadl&_type=xml) is as below: <application xmlns="http://wadl.dev.java.net/2009/02" xmlns:xs="http://www.w3.org/2001/XMLSchema"><grammars><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" attributeFormDefault="unqualified" elementFormDefault="unqualified"> <xs:element name="responseWrapper" type="responseWrapper"/> <xs:complexType name="responseWrapper"> <xs:sequence> <xs:element maxOccurs="unbounded" minOccurs="0" name="listItem" type="xs:string"/> <xs:element minOccurs="0" name="theResponse" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:schema> </grammars> <resources base="http://localhost:8080/ws-rest-prototype/services/LuckyNumbersRest"> <resource path="/luckynumbers"><resource path="/getWADL"><method name="GET"> <request><param name="therequest" style="query" type="xs:string" /> </request> <response><representation mediaType="application/xml"/></response> </method></resource></resource> </resources></application> We can see that in method <request> element, only the primitive type "therequest" is generated, but the java.util.List is not. However, the responseWrapper for the method return is generated. RequestWrapper and ResponseWrapper are totally same except for the name. Can any one advice me why a "requestWrapper" is not generated in the WADL like "responseWrapper"? How I can modify the code or configure to make it generated successfully? Thanks
|