Interacting with our services

We will proceed by adding the necessary methods to the ClientResource class, bound to the GET requests so they can be easily triggered with a browser. We need to add methods for creating, updating, deleting, and retrieving contacts, which we will trigger by performing appropriate HTTP requests.

How to do it…

  1. Add the #showContact() method to the ClientResource class, binding the query String parameter id as the input using the @QueryParam annotation.
     @GET @Path("showContact") public String showContact(@QueryParam("id") int id) { WebResource contactResource = client.resource("http://localhost:8080/contact/"+id); Contact c = contactResource.get(Contact.class); String output = "ID: "+ id +"\nFirst name: " + c.getFirstName() ...

Get RESTful Web Services with Dropwizard now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.