I am using CXF 3.1.4.
I searched for "queryparam" and "recursive" in the user group archive and found
discussions related to JIRA ticket CXF-2153. I understand its purpose, but this
recursiveness does not work well for certain classes like
javax.xml.datatype.XMLGregorianCalendar.
I defined my data structure in XSD like
<xsd:complexType name="RetrieveRequestType">
<xsd:attribute name="start" type="xsd:dateTime" use="required" />
<xsd:attribute name="end" type="xsd:dateTime" use="required" />
<xsd:attribute name="count" type="xsd:nonNegativeInteger" />
</xsd:complexType>
<xsd:element name="Retrieve">
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="p1:RetrieveRequestType" />
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
In the generated Java files, "xsd:dateTime" is represented by
XMLGregorianCalendar class. I then defined an interface like
@GET
@Path("retrieve")
@Produces({ MediaType.APPLICATION_JSON })
public RetrieveResponseType retrieve(@QueryParam("") Retrieve message) ;
The generated WADL has the following resource definition
<resource path="retrieve">
<method name="GET">
<request>
<param name="count" style="query" />
<param name="end.day" style="query" type="xs:int" />
<param name="end.month" style="query" type="xs:int" />
<param name="end.year" style="query" type="xs:int" />
<param name="end.valid" style="query" type="xs:boolean"
/>
<param name="end.hour" style="query" type="xs:int" />
<param name="end.minute" style="query" type="xs:int" />
<param name="end.second" style="query" type="xs:int" />
<param name="end.eon" style="query" />
<param name="end.eonAndYear" style="query" />
<param name="end.fractionalSecond" style="query" />
<param name="end.millisecond" style="query"
type="xs:int" />
<param name="end.xMLSchemaType.namespaceURI"
style="query" type="xs:string" />
<param name="end.xMLSchemaType.prefix" style="query"
type="xs:string" />
<param name="end.xMLSchemaType.localPart" style="query"
type="xs:string" />
<param name="end.timezone" style="query" type="xs:int"
/>
<param name="start.day" style="query" type="xs:int" />
<param name="start.month" style="query" type="xs:int" />
<param name="start.year" style="query" type="xs:int" />
<param name="start.valid" style="query"
type="xs:boolean" />
<param name="start.hour" style="query" type="xs:int" />
<param name="start.minute" style="query" type="xs:int"
/>
<param name="start.second" style="query" type="xs:int"
/>
<param name="start.eon" style="query" />
<param name="start.eonAndYear" style="query" />
<param name="start.fractionalSecond" style="query" />
<param name="start.millisecond" style="query"
type="xs:int" />
<param name="start.xMLSchemaType.namespaceURI"
style="query" type="xs:string" />
<param name="start.xMLSchemaType.prefix" style="query"
type="xs:string" />
<param name="start.xMLSchemaType.localPart"
style="query" type="xs:string" />
<param name="start.timezone" style="query"
type="xs:int" />
</request>
<response>
<representation mediaType="application/json"
element="prefix1:RetrieveResponseType" />
</response>
</method>
</resource>
And CXF JAXRSClientFactory.create() generated client sends the following URL to
the server
/retrieve?end.valid=true&end.hour=21&end.minute=14&end.second=0&end.timezone=-360&end.month=2&end.year=2014&end.day=27&end.millisecond=718&end.fractionalSecond=0.718&end.eonAndYear=2014&end.xMLSchemaType.prefix&end.xMLSchemaType.namespaceURI=http%3A//www.w3.org/2001/XMLSchema&end.xMLSchemaType.localPart=dateTime&start.valid=true&start.hour=21&start.minute=11&start.second=0&start.timezone=-360&start.month=2&start.year=2014&start.day=27&start.millisecond=718&start.fractionalSecond=0.718&start.eonAndYear=2014&start.xMLSchemaType.prefix&start.xMLSchemaType.namespaceURI=http%3A//www.w3.org/2001/XMLSchema&start.xMLSchemaType.localPart=dateTime&count=1
Clearly this is not what I wanted. I wanted simple queries like
/retrieve?start=2014-02-27T21%3A11%3A00.718-06%3A00&end=2014-02-27T21%3A14%3A00.718-06%3A00&count=1
or
/retrieve?start=1393557240718&count=2&end=1393558240718
With a customized ParamConverter for XMLGregorianCalendar both simplified
queries work well if I just send them directly to the server. However, the WADL
is still wrong, and I could not find way to have CXF client to send correct
URLs to the server.
I believe this is the side effect of the fix for CXF-2153 ticket. Is there a
way to configure it so it only goes down one level into Retrieve class, and not
into its components' XMLGregorianCalendar classes?
Thanks,Dongfeng