I have problem to read REST Integer response with jersey client, but if
I try with browser it display it correctly.
1) server side:
maven:
-----------
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.18.1</version>
</dependency>
rest:
----------
@Path("/int")
@GET
@Produces({"application/json"})
public Integer getInt();
And in javax.ws.rs.core.Application I add JacksonJsonProvider.class
2) client side:
maven:
-----------
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.18.1</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>1.18.1</version>
</dependency>
rest:
----------
ClientResponse clientResponse = webResource
.path(PATH_BASIC+"/"+"int")
.accept("application/json")
.get(ClientResponse.class);
testInt = clientResponse.getEntity(Integer.class);
HTTP Header:
------------------
GET /aai-api-server/rest/wc/int HTTP/1.1
Accept: application/json
Authorization: Basic
Ymxhei5kaXZqYWtAYXJuZXMuc2k6Ymxhei5kaXZqYWtAYXJuZXMuc2k=
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.7.0_25
Host: localhost:8181
Connection: keep-alive
Error:
----------
com.sun.jersey.api.client.ClientHandlerException: A message body reader
for Java class java.lang.Integer, and Java type class java.lang.Integer,
and MIME media type text/html; charset=ISO-8859-1 was not found
What I'm doing wrong?
Regards, Tomaz