I have a webservice defined with Jersey in the server side like this:
@POST
@Consumes(MediaType.APPLICATION_XML)
@Path("/foo")
public Response bar(List<Foo> listFoo) {
try {
//save the resource
} catch (Exception e) {
log.error("Error saving", e);
return Response.status(Status.INTERNAL_SERVER_ERROR).build();
}
return Response.status(Status.OK).build();
}
I am trying to get the server status in my Jersey client like this:
Response response = ws.type(MediaType.APPLICATION_XML).post(Response.class,list);
But I get the error:
A message body reader for Java class javax.ws.rs.core.Response, and Java type class javax.ws.rs.core.Response, and MIME media type application/xml was not found javax.ws.rs.core.Response
I don't really need the Response object, just the status code, how could I get it?
Ok, I solved it by changing the request response type:
Response response = ws.type(MediaType.APPLICATION_XML).post(Response.class,list);
with
ClientResponse response = ws.type(MediaType.APPLICATION_XML).post(ClientResponse.class,list);
being ClientResponse
a com.sun.jersey.api.client.ClientResponse
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With