From the course: Java EE 7: Web Services

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Use the JAX-RS Client API

Use the JAX-RS Client API - Java EE Tutorial

From the course: Java EE 7: Web Services

Start my 1-month free trial

Use the JAX-RS Client API

- [Instructor] Let's see using a client API in action. I've opened the project in IntelliJ, and navigated to the RestClient module. So I've created this new IntelliJ module here, called RestClient, and this is where I have the code for the client API. So, notice in the pom.xml, I've added two dependencies. The resteasy-jaxrs artifact ID, and the resteasy client. So, now let's review the code for the RestClient API. So that is the RestClient API here, and this is the Java file. So notice here on line 11 I'm creating the client using ClientBuilder.newClient, and then notice here on lines 14 through 19, I'm getting a single application by passing in a path parameter. In the previous lesson, we saw that we first had to create the client, as shown on line 11, in order to access web resources, and now, without this client API, we would have to use the low-level HTTP URL connection to access the REST endpoint, so this definitely makes life easier. So notice here on line 15, we set the URL…

Contents