We use Resteasy and have problems figuring how to call some @GET methods.
If the interface for the method only has simple parameters, there is no problem. Ex:
@GET
@Path("/test/{myparam}")
public FacetQueryResultImpl testMethod(@PathParam("myparam")String myparam);
But if we try to use a POJO as the parameter, it seems RestEasy is not able to serialize it as querystring parameters. Ex:
@GET
@Path("/testGet")
public FacetQueryResultImpl testMethod(ParamPojo myparam);
or
@GET
@Path("/testGet")
public FacetQueryResultImpl testMethod(@QueryParam("myparam")ParamPojo myparam);
(with, ParamPojo.java:)
public class ParamPojo
{
private String name;
private String description;
(...)
}
When we try this, sometimes the services are not found and sometimes we get a “A GET request cannot have a body.” exception.
Using @POST we are able to use a POJO has the parameter, but some of our methods don’t modify anything on the server, and therefore should use @GET.
A workaround is to “explode” the ParamPojo, and use all of its properties as separated parameters for the method. But this removes the “Easy” part of “RestEasy”, doesn’t it?
You must use the
@org.jboss.resteasy.annotations.Formannotation on your method parameter.http://docs.jboss.org/resteasy/docs/2.2.1.GA/userguide/html_single/#_Form
Example: