November 2017
Intermediate to advanced
420 pages
10h 29m
English
Apart from the preceding approach, you can use a simplified version of the client API available on the Invocation.Builder object, such as head(), get(), post(), update(), put(), or delete(), to invoke the appropriate REST API. The following code snippet invokes the HTTP GET method on the department resource API in a more simplified way:
// Obtain a client reference Client client = javax.ws.rs.client.ClientBuilder.newClient(); // Bind the target to the REST service String BASE_URI = "http://localhost:8080/rest-chapter3-service/webresources"; WebTarget resource = client.target(BASE_URI).path("departments"); GenericType responseType=new GenericType<List<Department>>() { }; // Invoke GET method on ...