Reputation: 17337
I just made a jax-rs service and I'm trying to convert the String I get from the service to entities. While with jax-rs everything is done automatically on the server side I assume there is a possibility to do it on the client side as well but I'm not finding it.
public class MyClient {
public static void main(String[] args) {
ResteasyClient client = new ResteasyClientBuilder().build();
ResteasyWebTarget target = client.target("http://localhost:8080/restapp/api/paints/1");
Response response = target.request().get();
Paint values = response.readEntity(Paint.class);
response.close();
}
}
this give an e:
Exception in thread "main" javax.ws.rs.ProcessingException: RESTEASY003145: Unable to find a MessageBodyReader of content-type application/json and type class client.Paint
(It works with String).
Upvotes: 0
Views: 646
Reputation: 89
hi you can write ReastEasy or Jersy Client to get Json from your Service. how to write client you can follow :http://entityclass.in/rest/jerseyClientGetXml.htm
Upvotes: 1
Reputation: 209004
You need to add a JSON provider. For RESTeasy, you can see this link and select your version, and add the dependency.
<dependency>
<groupId>org.jboss.resteasy</groupId>
<artifactId>resteasy-jackson2-provider</artifactId>
<version>${resteasy3.version}</version>
</dependency>
Upvotes: 1