From the course: Learning Java Enterprise Edition
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
JAX-RS in practice, part 2 - Java EE Tutorial
From the course: Learning Java Enterprise Edition
JAX-RS in practice, part 2
- [Instructor] Okay, let's have a look at an example of how JAX-RS can be used to consume a RESTful API. First of all I'm going to open up the class external routing service. This class is used to access a rest endpoint and we do this by creating an instance of the client. Here we have a new client being built, and also here we are injecting a URI of the resource endpoint. If we scroll down a little bit further we can see here the JAX-RS client is being configured with a URI we injected above. Further down is where we make the actual call to the rest endpoint. What we're doing here is we're constructing a URI. We have query parameters and a media type, and then we make a get request to the endpoint by calling the get method, and that's it. Let's have a look at the other end of this transaction. So to see where this request is handled we need to go to the graph traversal service. Again you will notice the path to the resource being specified at the class level and also at the method…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.