Previously we figured out how to send requests and receive reponses. Today we’re going to go further and take a look at RESTEasy Proxy Framework.
In this post we’re going to learn how to send Http Requests and receive Http Responses with RESTEasy.
RESTeasy Maven dependencies
First of all we need to add required Maven dependencies for RESTeasy Client
RESTEasy Proxy client.
Let’s assume we have the web service (BookService) that provides the CRUD functionality. We can describe it as an interface using JAX-RX annotations.
Let’s create a RESTEasy client
and make calls to the service
As you can see we can access DTOs (Book, List<Book>) without marshaling/unmarshaling. We can work directly with objects.
RESTEasy Proxy Client. ClientErrorException
If your web service returns a non-success response code then RESTEasy proxy client throws exceptions - ClientErrorException which extends WebApplicationException. So you have to handle those exceptions with try-catch blocks.