public class RestTemplate extends InterceptingHttpAccessor implements RestOperations
The main entry points of this template are the methods named after the six main HTTP methods:
The exchange and execute methods are generalized versions of the more specific methods listed
above them. They support additional, less frequently used combinations including support for requests using the
HTTP PATCH method. However, note that the underlying HTTP library must also support the desired combination.
For each of these HTTP methods, there are three corresponding Java methods in the RestTemplate.
Two variants take a String URI as first argument (eg. getForObject(String, Class, Object[]),
getForObject(String, Class, Map)), and are capable of substituting any URI templates
in that URL using either a String variable arguments array, or a Map<String, String>.
The string varargs variant expands the given template variables in order, so that
String result = restTemplate.getForObject("http://example.com/hotels/{hotel}/bookings/{booking}", String.class, "42",
"21");
will perform a GET on http://example.com/hotels/42/bookings/21. The map variant expands the template based
on variable name, and is therefore more useful when using many variables, or when a single variable is used multiple
times. For example:
Map<String, String> vars = Collections.singletonMap("hotel", "42");
String result = restTemplate.getForObject("http://example.com/hotels/{hotel}/rooms/{hotel}", String.class, vars);
will perform a GET on http://example.com/hotels/42/rooms/42. Alternatively, there are URI variant
methods (getForObject(URI, Class)), which do not allow for URI templates, but allow you to reuse a single,
expanded URI multiple times.
Furthermore, the String-argument methods assume that the URL String is unencoded. This means that
restTemplate.getForObject("http://example.com/hotel list");
will perform a GET on http://example.com/hotel%20list. As a result, any URL passed that is already encoded
will be encoded twice (i.e. http://example.com/hotel%20list will become http://example.com/hotel%2520list). If this behavior is undesirable, use the URI-argument methods, which
will not perform any URL encoding.
Objects passed to and returned from these methods are converted to and from HTTP messages by
HttpMessageConverter instances. Converters for the main mime types are registered by default,
but you can also write your own converter and register it via the messageConverters
bean property.
This template uses a SimpleClientHttpRequestFactory and a
DefaultResponseErrorHandler as default strategies for creating HTTP connections or handling HTTP errors,
respectively. These defaults can be overridden through the requestFactory and errorHandler bean properties.
HttpMessageConverter,
RequestCallback,
ResponseExtractor,
ResponseErrorHandler,
AsyncRestTemplatelogger| Constructor and Description |
|---|
RestTemplate()
Create a new instance of the
RestTemplate using default settings. |
RestTemplate(ClientHttpRequestFactory requestFactory)
Create a new instance of the
RestTemplate based on the given ClientHttpRequestFactory. |
RestTemplate(List<HttpMessageConverter<?>> messageConverters)
Create a new instance of the
RestTemplate using the given list of
HttpMessageConverter to use |
| Modifier and Type | Method and Description |
|---|---|
protected <T> RequestCallback |
acceptHeaderRequestCallback(Class<T> responseType)
Returns a request callback implementation that prepares the request
Accept
headers based on the given response type and configured
message converters. |
void |
delete(String url,
Map<String,?> urlVariables)
Delete the resources at the specified URI.
|
void |
delete(String url,
Object... urlVariables)
Delete the resources at the specified URI.
|
void |
delete(URI url)
Delete the resources at the specified URL.
|
protected <T> T |
doExecute(URI url,
HttpMethod method,
RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor)
Execute the given method on the provided URI.
|
<T> ResponseEntity<T> |
exchange(String url,
HttpMethod method,
HttpEntity<?> requestEntity,
Class<T> responseType,
Map<String,?> uriVariables)
Execute the HTTP method to the given URI template, writing the given request entity to the request, and
returns the response as
ResponseEntity. |
<T> ResponseEntity<T> |
exchange(String url,
HttpMethod method,
HttpEntity<?> requestEntity,
Class<T> responseType,
Object... uriVariables)
Execute the HTTP method to the given URI template, writing the given request entity to the request, and
returns the response as
ResponseEntity. |
<T> ResponseEntity<T> |
exchange(String url,
HttpMethod method,
HttpEntity<?> requestEntity,
ParameterizedTypeReference<T> responseType,
Map<String,?> uriVariables)
Execute the HTTP method to the given URI template, writing the given
request entity to the request, and returns the response as
ResponseEntity. |
<T> ResponseEntity<T> |
exchange(String url,
HttpMethod method,
HttpEntity<?> requestEntity,
ParameterizedTypeReference<T> responseType,
Object... uriVariables)
Execute the HTTP method to the given URI template, writing the given
request entity to the request, and returns the response as
ResponseEntity. |
<T> ResponseEntity<T> |
exchange(URI url,
HttpMethod method,
HttpEntity<?> requestEntity,
Class<T> responseType)
Execute the HTTP method to the given URI template, writing the given request entity to the request, and
returns the response as
ResponseEntity. |
<T> ResponseEntity<T> |
exchange(URI url,
HttpMethod method,
HttpEntity<?> requestEntity,
ParameterizedTypeReference<T> responseType)
Execute the HTTP method to the given URI template, writing the given
request entity to the request, and returns the response as
ResponseEntity. |
<T> T |
execute(String url,
HttpMethod method,
RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor,
Map<String,?> urlVariables)
Execute the HTTP method to the given URI template, preparing the request with the
RequestCallback, and reading the response with a ResponseExtractor. |
<T> T |
execute(String url,
HttpMethod method,
RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor,
Object... urlVariables)
Execute the HTTP method to the given URI template, preparing the request with the
RequestCallback, and reading the response with a ResponseExtractor. |
<T> T |
execute(URI url,
HttpMethod method,
RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor)
Execute the HTTP method to the given URL, preparing the request with the
RequestCallback, and reading the response with a ResponseExtractor. |
ResponseErrorHandler |
getErrorHandler()
Return the error handler.
|
<T> ResponseEntity<T> |
getForEntity(String url,
Class<T> responseType,
Map<String,?> urlVariables)
Retrieve a representation by doing a GET on the URI template.
|
<T> ResponseEntity<T> |
getForEntity(String url,
Class<T> responseType,
Object... urlVariables)
Retrieve an entity by doing a GET on the specified URL.
|
<T> ResponseEntity<T> |
getForEntity(URI url,
Class<T> responseType)
Retrieve a representation by doing a GET on the URL .
|
<T> T |
getForObject(String url,
Class<T> responseType,
Map<String,?> urlVariables)
Retrieve a representation by doing a GET on the URI template.
|
<T> T |
getForObject(String url,
Class<T> responseType,
Object... urlVariables)
Retrieve a representation by doing a GET on the specified URL.
|
<T> T |
getForObject(URI url,
Class<T> responseType)
Retrieve a representation by doing a GET on the URL .
|
List<HttpMessageConverter<?>> |
getMessageConverters()
Return the message body converters.
|
protected ResponseExtractor<HttpHeaders> |
headersExtractor()
Returns a response extractor for
HttpHeaders. |
HttpHeaders |
headForHeaders(String url,
Map<String,?> urlVariables)
Retrieve all headers of the resource specified by the URI template.
|
HttpHeaders |
headForHeaders(String url,
Object... urlVariables)
Retrieve all headers of the resource specified by the URI template.
|
HttpHeaders |
headForHeaders(URI url)
Retrieve all headers of the resource specified by the URL.
|
protected <T> RequestCallback |
httpEntityCallback(Object requestBody)
Returns a request callback implementation that writes the given object to the
request stream.
|
protected <T> RequestCallback |
httpEntityCallback(Object requestBody,
Type responseType)
Returns a request callback implementation that writes the given object to the
request stream.
|
Set<HttpMethod> |
optionsForAllow(String url,
Map<String,?> urlVariables)
Return the value of the Allow header for the given URI.
|
Set<HttpMethod> |
optionsForAllow(String url,
Object... urlVariables)
Return the value of the Allow header for the given URI.
|
Set<HttpMethod> |
optionsForAllow(URI url)
Return the value of the Allow header for the given URL.
|
<T> ResponseEntity<T> |
postForEntity(String url,
Object request,
Class<T> responseType,
Map<String,?> uriVariables)
Create a new resource by POSTing the given object to the URI template,
and returns the response as
HttpEntity. |
<T> ResponseEntity<T> |
postForEntity(String url,
Object request,
Class<T> responseType,
Object... uriVariables)
Create a new resource by POSTing the given object to the URI template,
and returns the response as
ResponseEntity. |
<T> ResponseEntity<T> |
postForEntity(URI url,
Object request,
Class<T> responseType)
Create a new resource by POSTing the given object to the URL,
and returns the response as
ResponseEntity. |
URI |
postForLocation(String url,
Object request,
Map<String,?> urlVariables)
Create a new resource by POSTing the given object to the URI template, and returns the value of the
Location header. |
URI |
postForLocation(String url,
Object request,
Object... urlVariables)
Create a new resource by POSTing the given object to the URI template, and returns the value of the
Location header. |
URI |
postForLocation(URI url,
Object request)
Create a new resource by POSTing the given object to the URL, and returns the value of the
Location header. |
<T> T |
postForObject(String url,
Object request,
Class<T> responseType,
Map<String,?> uriVariables)
Create a new resource by POSTing the given object to the URI template,
and returns the representation found in the response.
|
<T> T |
postForObject(String url,
Object request,
Class<T> responseType,
Object... uriVariables)
Create a new resource by POSTing the given object to the URI template,
and returns the representation found in the response.
|
<T> T |
postForObject(URI url,
Object request,
Class<T> responseType)
Create a new resource by POSTing the given object to the URL,
and returns the representation found in the response.
|
void |
put(String url,
Object request,
Map<String,?> urlVariables)
Creates a new resource by PUTting the given object to URI template.
|
void |
put(String url,
Object request,
Object... urlVariables)
Create or update a resource by PUTting the given object to the URI.
|
void |
put(URI url,
Object request)
Creates a new resource by PUTting the given object to URL.
|
protected <T> ResponseExtractor<ResponseEntity<T>> |
responseEntityExtractor(Type responseType)
Returns a response extractor for
ResponseEntity. |
void |
setErrorHandler(ResponseErrorHandler errorHandler)
Set the error handler.
|
void |
setMessageConverters(List<HttpMessageConverter<?>> messageConverters)
Set the message body converters to use.
|
getInterceptors, getRequestFactory, setInterceptorscreateRequest, setRequestFactorypublic RestTemplate()
RestTemplate using default settings.
Default HttpMessageConverters are initialized.public RestTemplate(ClientHttpRequestFactory requestFactory)
RestTemplate based on the given ClientHttpRequestFactory.requestFactory - HTTP request factory to useSimpleClientHttpRequestFactory,
HttpComponentsClientHttpRequestFactorypublic RestTemplate(List<HttpMessageConverter<?>> messageConverters)
RestTemplate using the given list of
HttpMessageConverter to usemessageConverters - the list of HttpMessageConverter to usepublic void setMessageConverters(List<HttpMessageConverter<?>> messageConverters)
These converters are used to convert from and to HTTP requests and responses.
public List<HttpMessageConverter<?>> getMessageConverters()
public void setErrorHandler(ResponseErrorHandler errorHandler)
By default, RestTemplate uses a DefaultResponseErrorHandler.
public ResponseErrorHandler getErrorHandler()
public <T> T getForObject(String url, Class<T> responseType, Object... urlVariables) throws RestClientException
RestOperationsURI Template variables are expanded using the given URI variables, if any.
getForObject in interface RestOperationsurl - the URLresponseType - the type of the return valueurlVariables - the variables to expand the templateRestClientExceptionpublic <T> T getForObject(String url, Class<T> responseType, Map<String,?> urlVariables) throws RestClientException
RestOperationsURI Template variables are expanded using the given map.
getForObject in interface RestOperationsurl - the URLresponseType - the type of the return valueurlVariables - the map containing variables for the URI templateRestClientExceptionpublic <T> T getForObject(URI url, Class<T> responseType) throws RestClientException
RestOperationsgetForObject in interface RestOperationsurl - the URLresponseType - the type of the return valueRestClientExceptionpublic <T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Object... urlVariables) throws RestClientException
RestOperationsResponseEntity.
URI Template variables are expanded using the given URI variables, if any.
getForEntity in interface RestOperationsurl - the URLresponseType - the type of the return valueurlVariables - the variables to expand the templateRestClientExceptionpublic <T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Map<String,?> urlVariables) throws RestClientException
RestOperationsResponseEntity.
URI Template variables are expanded using the given map.
getForEntity in interface RestOperationsurl - the URLresponseType - the type of the return valueurlVariables - the map containing variables for the URI templateRestClientExceptionpublic <T> ResponseEntity<T> getForEntity(URI url, Class<T> responseType) throws RestClientException
RestOperationsResponseEntity.getForEntity in interface RestOperationsurl - the URLresponseType - the type of the return valueRestClientExceptionpublic HttpHeaders headForHeaders(String url, Object... urlVariables) throws RestClientException
RestOperationsURI Template variables are expanded using the given URI variables, if any.
headForHeaders in interface RestOperationsurl - the URLurlVariables - the variables to expand the templateRestClientExceptionpublic HttpHeaders headForHeaders(String url, Map<String,?> urlVariables) throws RestClientException
RestOperationsURI Template variables are expanded using the given map.
headForHeaders in interface RestOperationsurl - the URLurlVariables - the map containing variables for the URI templateRestClientExceptionpublic HttpHeaders headForHeaders(URI url) throws RestClientException
RestOperationsheadForHeaders in interface RestOperationsurl - the URLRestClientExceptionpublic URI postForLocation(String url, Object request, Object... urlVariables) throws RestClientException
RestOperationsLocation header. This header typically indicates where the new resource is stored.
URI Template variables are expanded using the given URI variables, if any.
The request parameter can be a HttpEntity in order to
add additional HTTP headers to the request.
postForLocation in interface RestOperationsurl - the URLrequest - the Object to be POSTed, may be nullurlVariables - the variables to expand the templateLocation headerRestClientExceptionHttpEntitypublic URI postForLocation(String url, Object request, Map<String,?> urlVariables) throws RestClientException
RestOperationsLocation header. This header typically indicates where the new resource is stored.
URI Template variables are expanded using the given map.
The request parameter can be a HttpEntity in order to
add additional HTTP headers to the request.
postForLocation in interface RestOperationsurl - the URLrequest - the Object to be POSTed, may be nullurlVariables - the variables to expand the templateLocation headerRestClientExceptionHttpEntitypublic URI postForLocation(URI url, Object request) throws RestClientException
RestOperationsLocation header. This header typically indicates where the new resource is stored.
The request parameter can be a HttpEntity in order to
add additional HTTP headers to the request.
postForLocation in interface RestOperationsurl - the URLrequest - the Object to be POSTed, may be nullLocation headerRestClientExceptionHttpEntitypublic <T> T postForObject(String url, Object request, Class<T> responseType, Object... uriVariables) throws RestClientException
RestOperationsURI Template variables are expanded using the given URI variables, if any.
The request parameter can be a HttpEntity in order to
add additional HTTP headers to the request.
postForObject in interface RestOperationsurl - the URLrequest - the Object to be POSTed, may be nullresponseType - the type of the return valueuriVariables - the variables to expand the templateRestClientExceptionHttpEntitypublic <T> T postForObject(String url, Object request, Class<T> responseType, Map<String,?> uriVariables) throws RestClientException
RestOperationsURI Template variables are expanded using the given map.
The request parameter can be a HttpEntity in order to
add additional HTTP headers to the request.
postForObject in interface RestOperationsurl - the URLrequest - the Object to be POSTed, may be nullresponseType - the type of the return valueuriVariables - the variables to expand the templateRestClientExceptionHttpEntitypublic <T> T postForObject(URI url, Object request, Class<T> responseType) throws RestClientException
RestOperationsThe request parameter can be a HttpEntity in order to
add additional HTTP headers to the request.
postForObject in interface RestOperationsurl - the URLrequest - the Object to be POSTed, may be nullresponseType - the type of the return valueRestClientExceptionHttpEntitypublic <T> ResponseEntity<T> postForEntity(String url, Object request, Class<T> responseType, Object... uriVariables) throws RestClientException
RestOperationsResponseEntity.
URI Template variables are expanded using the given URI variables, if any.
The request parameter can be a HttpEntity in order to
add additional HTTP headers to the request.
postForEntity in interface RestOperationsurl - the URLrequest - the Object to be POSTed, may be nulluriVariables - the variables to expand the templateRestClientExceptionHttpEntitypublic <T> ResponseEntity<T> postForEntity(String url, Object request, Class<T> responseType, Map<String,?> uriVariables) throws RestClientException
RestOperationsHttpEntity.
URI Template variables are expanded using the given map.
The request parameter can be a HttpEntity in order to
add additional HTTP headers to the request.
postForEntity in interface RestOperationsurl - the URLrequest - the Object to be POSTed, may be nulluriVariables - the variables to expand the templateRestClientExceptionHttpEntitypublic <T> ResponseEntity<T> postForEntity(URI url, Object request, Class<T> responseType) throws RestClientException
RestOperationsResponseEntity.
The request parameter can be a HttpEntity in order to
add additional HTTP headers to the request.
postForEntity in interface RestOperationsurl - the URLrequest - the Object to be POSTed, may be nullRestClientExceptionHttpEntitypublic void put(String url, Object request, Object... urlVariables) throws RestClientException
RestOperationsURI Template variables are expanded using the given URI variables, if any.
The request parameter can be a HttpEntity in order to
add additional HTTP headers to the request.
put in interface RestOperationsurl - the URLrequest - the Object to be PUT, may be nullurlVariables - the variables to expand the templateRestClientExceptionHttpEntitypublic void put(String url, Object request, Map<String,?> urlVariables) throws RestClientException
RestOperationsURI Template variables are expanded using the given map.
The request parameter can be a HttpEntity in order to
add additional HTTP headers to the request.
put in interface RestOperationsurl - the URLrequest - the Object to be PUT, may be nullurlVariables - the variables to expand the templateRestClientExceptionHttpEntitypublic void put(URI url, Object request) throws RestClientException
RestOperationsThe request parameter can be a HttpEntity in order to
add additional HTTP headers to the request.
put in interface RestOperationsurl - the URLrequest - the Object to be PUT, may be nullRestClientExceptionHttpEntitypublic void delete(String url, Object... urlVariables) throws RestClientException
RestOperationsURI Template variables are expanded using the given URI variables, if any.
delete in interface RestOperationsurl - the URLurlVariables - the variables to expand in the templateRestClientExceptionpublic void delete(String url, Map<String,?> urlVariables) throws RestClientException
RestOperationsURI Template variables are expanded using the given map.
delete in interface RestOperationsurl - the URLurlVariables - the variables to expand the templateRestClientExceptionpublic void delete(URI url) throws RestClientException
RestOperationsdelete in interface RestOperationsurl - the URLRestClientExceptionpublic Set<HttpMethod> optionsForAllow(String url, Object... urlVariables) throws RestClientException
RestOperationsURI Template variables are expanded using the given URI variables, if any.
optionsForAllow in interface RestOperationsurl - the URLurlVariables - the variables to expand in the templateRestClientExceptionpublic Set<HttpMethod> optionsForAllow(String url, Map<String,?> urlVariables) throws RestClientException
RestOperationsURI Template variables are expanded using the given map.
optionsForAllow in interface RestOperationsurl - the URLurlVariables - the variables to expand in the templateRestClientExceptionpublic Set<HttpMethod> optionsForAllow(URI url) throws RestClientException
RestOperationsoptionsForAllow in interface RestOperationsurl - the URLRestClientExceptionpublic <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType, Object... uriVariables) throws RestClientException
RestOperationsResponseEntity.
URI Template variables are expanded using the given URI variables, if any.
exchange in interface RestOperationsurl - the URLmethod - the HTTP method (GET, POST, etc)requestEntity - the entity (headers and/or body) to write to the request, may be nullresponseType - the type of the return valueuriVariables - the variables to expand in the templateRestClientExceptionpublic <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType, Map<String,?> uriVariables) throws RestClientException
RestOperationsResponseEntity.
URI Template variables are expanded using the given URI variables, if any.
exchange in interface RestOperationsurl - the URLmethod - the HTTP method (GET, POST, etc)requestEntity - the entity (headers and/or body) to write to the request, may be nullresponseType - the type of the return valueuriVariables - the variables to expand in the templateRestClientExceptionpublic <T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity, Class<T> responseType) throws RestClientException
RestOperationsResponseEntity.exchange in interface RestOperationsurl - the URLmethod - the HTTP method (GET, POST, etc)requestEntity - the entity (headers and/or body) to write to the request, may be nullresponseType - the type of the return valueRestClientExceptionpublic <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType, Object... uriVariables) throws RestClientException
RestOperationsResponseEntity.
The given ParameterizedTypeReference is used to pass generic type information:
ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {};
ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
exchange in interface RestOperationsurl - the URLmethod - the HTTP method (GET, POST, etc)requestEntity - the entity (headers and/or body) to write to the
request, may be nullresponseType - the type of the return valueuriVariables - the variables to expand in the templateRestClientExceptionpublic <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType, Map<String,?> uriVariables) throws RestClientException
RestOperationsResponseEntity.
The given ParameterizedTypeReference is used to pass generic type information:
ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {};
ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
exchange in interface RestOperationsurl - the URLmethod - the HTTP method (GET, POST, etc)requestEntity - the entity (headers and/or body) to write to the request, may be nullresponseType - the type of the return valueuriVariables - the variables to expand in the templateRestClientExceptionpublic <T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType) throws RestClientException
RestOperationsResponseEntity.
The given ParameterizedTypeReference is used to pass generic type information:
ParameterizedTypeReference<List<MyBean>> myBean = new ParameterizedTypeReference<List<MyBean>>() {};
ResponseEntity<List<MyBean>> response = template.exchange("http://example.com",HttpMethod.GET, null, myBean);
exchange in interface RestOperationsurl - the URLmethod - the HTTP method (GET, POST, etc)requestEntity - the entity (headers and/or body) to write to the request, may be nullresponseType - the type of the return valueRestClientExceptionpublic <T> T execute(String url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor, Object... urlVariables) throws RestClientException
RestOperationsRequestCallback, and reading the response with a ResponseExtractor.
URI Template variables are expanded using the given URI variables, if any.
execute in interface RestOperationsurl - the URLmethod - the HTTP method (GET, POST, etc)requestCallback - object that prepares the requestresponseExtractor - object that extracts the return value from the responseurlVariables - the variables to expand in the templateResponseExtractorRestClientExceptionpublic <T> T execute(String url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor, Map<String,?> urlVariables) throws RestClientException
RestOperationsRequestCallback, and reading the response with a ResponseExtractor.
URI Template variables are expanded using the given URI variables map.
execute in interface RestOperationsurl - the URLmethod - the HTTP method (GET, POST, etc)requestCallback - object that prepares the requestresponseExtractor - object that extracts the return value from the responseurlVariables - the variables to expand in the templateResponseExtractorRestClientExceptionpublic <T> T execute(URI url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor) throws RestClientException
RestOperationsRequestCallback, and reading the response with a ResponseExtractor.execute in interface RestOperationsurl - the URLmethod - the HTTP method (GET, POST, etc)requestCallback - object that prepares the requestresponseExtractor - object that extracts the return value from the responseResponseExtractorRestClientExceptionprotected <T> T doExecute(URI url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor) throws RestClientException
The ClientHttpRequest is processed using the RequestCallback;
the response with the ResponseExtractor.
url - the fully-expanded URL to connect tomethod - the HTTP method to execute (GET, POST, etc.)requestCallback - object that prepares the request (can be null)responseExtractor - object that extracts the return value from the response (can be null)ResponseExtractorRestClientExceptionprotected <T> RequestCallback acceptHeaderRequestCallback(Class<T> responseType)
Accept
headers based on the given response type and configured
message converters.protected <T> RequestCallback httpEntityCallback(Object requestBody)
protected <T> RequestCallback httpEntityCallback(Object requestBody, Type responseType)
protected <T> ResponseExtractor<ResponseEntity<T>> responseEntityExtractor(Type responseType)
ResponseEntity.protected ResponseExtractor<HttpHeaders> headersExtractor()
HttpHeaders.