REST Client

Steps for JAX-RS Client Programming 

  1. Create Client object 
  2. Create WebTarget object 
  3. Build HTTP request (including headers) 
  4. Invoke and receive response 
    • Domain object 
    • Response object 
  5. Handle exception

1. Create Client Object

Client & ClientBuilder 

  • javax.ws.rs.Client object manages client socket connection 
    • It is an expensive to create this object - it should be reused whenever possible 
  • Easiest way to create Client object is through ClientBuilder 
    • Client client = ClientBuilder.newClient();

 

You must have an active subscription to download PDF and Lab Zip of this course topic.Please click the "Subscribe" button or the "Login" button if you already have an account.