Server-side consuming

Another scenario of consuming a REST API is that the backend needs to invoke a remote RESTful API. Since RESTful APIs are over HTTP, we can use libraries such as Apache HttpClient to make the call. However, we will have to take care of establishing an HTTP connection, checking the HTTP response, converting a response from a string into required objects, and then closing the connection. There is a lot of boilerplate code. Another option is to use the RestTemplate class that Spring provides. This class simplifies communication with HTTP servers by handling HTTP connections, leaving application code to provide URLs (with possible template variables) and extract results. And most importantly, it enforces RESTful principles.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.119.170