Learn to use RestTemplateBuilder to create or build RestTemplate class which can be used to send HTTP requests. 1) Default RestTemplateBuilder To inject RestTemplateBuilder, pass it as constructor argument in your service class. 2) Custom RestTemplateBuilder To create custom RestTemplateBuilder, create @Bean of type RestTemplateBuilder in Spring context. RestTemplateBuilder Bean RestTemplateCustomizer Bean Create custom RestTemplateCustomizer […]
Learn to use ClientHttpRequestInterceptor with Spring RestTemplate to log request and response headers and body in Spring AOP style. Interceptor Usages We can use this interceptor for many useful tasks. To add custom header to the response To log HTTP request and response To deny certain requests etc. 1) Interceptor to log request and response […]
We have already gone through the RestTemplate examples for accessing REST APIs inside spring application. In this example, we are extending the configuration to use Apache HttpClient 4. The purpose of this tutorial is to give you pre-cooked recipe for little head-start, and save you from writing all bits and pieces.
Learn to create Spring REST client using Spring RestTemplate class and it’s template methods to access HTTP GET, POST, PUT and DELETE requests in easy step.
In Spring 4 REST JSON example, we will learn to write RESTful webservices capable of returning JSON representations of resources. We will use MappingJackson2JsonView to resolve views to JSON body. Read More: Spring REST XML tutorial 1. Spring REST JSON – @ResponseBody Annotation This first technique is simple and easy. We have to include only […]
In this tutorial, I am writing hello world example for RESTful APIs using Spring REST features. In this example, I will be creating two APIs which will return XML representation of resources. Maven Dependencies Let’s start with runtime dependencies which you will need to write these RESTFul APIs. In fact, all you need is Spring […]
Learn to create Spring REST controller which can handle REST API calls in any Spring MVC application. It invloves adding @Controller and @RequestMapping annotations. For writing this application, I am modifying the source code written in Spring MVC example. So, if want, you can download the source code from given link. 1. Update maven dependencies […]