Hi Shankar,
for your scenario, i am afraid, as you do not send the JSON as the request body,
but as a query parameter, this won't work. The exception you are getting is probably
related to the explicit input mime-type (@Consumes annotation), which in the case of GET
request does not make sense. You can workaround this by POSTing the JSON data
to create a new query resource, return back it's URI location, and then GET back
the query result in a separate GET request without specifying the query data.
~Jakub
On Tue, Mar 02, 2010 at 07:05:21PM +0530, Shankar K wrote:
> Hi All,
>
> I'm trying to see if i can directly consume a json query parameter of a GET
> request to a custom type object. Can this deserialization (ie. json to java
> custom object) occur automatically? I'm not able to get it working, provided
> below the use case, code snippet that I was expecting to work and the error
> that I get when I deploy. Appreciate your help/suggestions on this!!
>
> *Use Case:*
>
> my client(browser based) sends a search query as json (which will have
> page#, page size, filter/sort criteria etc) and on the Rest side, i will
> have to map it to SearchQuery object which I would use to return to matching
> objects(as json) back to the client. Following is the code that i have
> written for the same. But when I deploy it, i get an error which I have also
> mentioned below.
>
> *Code Snippet:
> *
> @GET
> @Consumes("application/json")
> @Produces("application/json")
> @Path("/Users")
>
> public MinimalUserDTO[] getUserByCriteria(@QueryParam("searchQuery")
> SearchQuery searchQuery)
> {
> //get User Data based on searchQuery
> //return array of user
> }
>
> *Error:
> *
> Method, public java.lang.String getUserByCriteria(MinimalUserDTO[]),
> annotated with GET of resource, class UserRestService, is not recognized as
> valid Java method annotated with @HttpMethod.
>
> Thanks,
> Shankar
--
http://blogs.sun.com/japod