Skip to Content
RESTful Java Web Services - Third Edition
book

RESTful Java Web Services - Third Edition

by Balachandar Bogunuva Mohanram
November 2017
Intermediate to advanced
420 pages
10h 29m
English
Packt Publishing
Content preview from RESTful Java Web Services - Third Edition

Simplified client APIs for accessing REST APIs

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

RESTful Java Web Services, Second Edition

RESTful Java Web Services, Second Edition

Jobinesh Purushothaman
Java Web Services

Java Web Services

David A Chappell, Tyler Jewell

Publisher Resources

ISBN: 9781788294041Supplemental Content