11 Consuming REST endpoints

 

This chapter covers

  • Calling REST endpoints using Spring Cloud OpenFeign
  • Calling REST endpoints using RestTemplate
  • Calling REST endpoints using WebClient

In chapter 10, we discussed implementing REST endpoints. REST services are a common way to implement the communication between two system components. Not only the client of a web app may call the backend, but also two backend components may communicate one with the other to accomplish their responsibilities. In a backend solution composed of multiple services (see appendix A), these components need to “speak” to exchange data. So when you implement such a service using Spring, you need to know how to call a REST endpoint exposed by another service (figure 11.1).

Figure 11.1 Often, a backend app needs to act as a client for another backend app and call exposed REST endpoints to work with specific data.
A picture containing text, electronics, screen, screenshot Description automatically generated

In this chapter, you’ll learn three ways to call REST endpoints from a Spring app:

11.1  Calling REST endpoints using Spring Cloud OpenFeign

11.2  Calling REST endpoints using RestTemplate

11.3  Calling REST endpoints using WebClient

11.4  Summary

sitemap