public interface RestOperations
RestTemplate
. Not often used directly, but a useful
option to enhance testability, as it can easily be mocked or stubbed.RestTemplate
,
AsyncRestOperations
Modifier and Type | Method and Description |
---|---|
void |
delete(java.lang.String url,
java.util.Map<java.lang.String,?> uriVariables)
Delete the resources at the specified URI.
|
void |
delete(java.lang.String url,
java.lang.Object... uriVariables)
Delete the resources at the specified URI.
|
void |
delete(java.net.URI url)
Delete the resources at the specified URL.
|
<T> ResponseEntity<T> |
exchange(RequestEntity<?> requestEntity,
java.lang.Class<T> responseType)
Execute the request specified in the given
RequestEntity and return
the response as ResponseEntity . |
<T> ResponseEntity<T> |
exchange(RequestEntity<?> requestEntity,
ParameterizedTypeReference<T> responseType)
Execute the request specified in the given
RequestEntity and return
the response as ResponseEntity . |
<T> ResponseEntity<T> |
exchange(java.lang.String url,
HttpMethod method,
HttpEntity<?> requestEntity,
java.lang.Class<T> responseType,
java.util.Map<java.lang.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(java.lang.String url,
HttpMethod method,
HttpEntity<?> requestEntity,
java.lang.Class<T> responseType,
java.lang.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(java.lang.String url,
HttpMethod method,
HttpEntity<?> requestEntity,
ParameterizedTypeReference<T> responseType,
java.util.Map<java.lang.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(java.lang.String url,
HttpMethod method,
HttpEntity<?> requestEntity,
ParameterizedTypeReference<T> responseType,
java.lang.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(java.net.URI url,
HttpMethod method,
HttpEntity<?> requestEntity,
java.lang.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(java.net.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(java.lang.String url,
HttpMethod method,
RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor,
java.util.Map<java.lang.String,?> uriVariables)
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(java.lang.String url,
HttpMethod method,
RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor,
java.lang.Object... uriVariables)
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(java.net.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 . |
<T> ResponseEntity<T> |
getForEntity(java.lang.String url,
java.lang.Class<T> responseType,
java.util.Map<java.lang.String,?> uriVariables)
Retrieve a representation by doing a GET on the URI template.
|
<T> ResponseEntity<T> |
getForEntity(java.lang.String url,
java.lang.Class<T> responseType,
java.lang.Object... uriVariables)
Retrieve an entity by doing a GET on the specified URL.
|
<T> ResponseEntity<T> |
getForEntity(java.net.URI url,
java.lang.Class<T> responseType)
Retrieve a representation by doing a GET on the URL .
|
<T> T |
getForObject(java.lang.String url,
java.lang.Class<T> responseType,
java.util.Map<java.lang.String,?> uriVariables)
Retrieve a representation by doing a GET on the URI template.
|
<T> T |
getForObject(java.lang.String url,
java.lang.Class<T> responseType,
java.lang.Object... uriVariables)
Retrieve a representation by doing a GET on the specified URL.
|
<T> T |
getForObject(java.net.URI url,
java.lang.Class<T> responseType)
Retrieve a representation by doing a GET on the URL .
|
HttpHeaders |
headForHeaders(java.lang.String url,
java.util.Map<java.lang.String,?> uriVariables)
Retrieve all headers of the resource specified by the URI template.
|
HttpHeaders |
headForHeaders(java.lang.String url,
java.lang.Object... uriVariables)
Retrieve all headers of the resource specified by the URI template.
|
HttpHeaders |
headForHeaders(java.net.URI url)
Retrieve all headers of the resource specified by the URL.
|
java.util.Set<HttpMethod> |
optionsForAllow(java.lang.String url,
java.util.Map<java.lang.String,?> uriVariables)
Return the value of the Allow header for the given URI.
|
java.util.Set<HttpMethod> |
optionsForAllow(java.lang.String url,
java.lang.Object... uriVariables)
Return the value of the Allow header for the given URI.
|
java.util.Set<HttpMethod> |
optionsForAllow(java.net.URI url)
Return the value of the Allow header for the given URL.
|
<T> T |
patchForObject(java.lang.String url,
java.lang.Object request,
java.lang.Class<T> responseType,
java.util.Map<java.lang.String,?> uriVariables)
Update a resource by PATCHing the given object to the URI template,
and return the representation found in the response.
|
<T> T |
patchForObject(java.lang.String url,
java.lang.Object request,
java.lang.Class<T> responseType,
java.lang.Object... uriVariables)
Update a resource by PATCHing the given object to the URI template,
and return the representation found in the response.
|
<T> T |
patchForObject(java.net.URI url,
java.lang.Object request,
java.lang.Class<T> responseType)
Update a resource by PATCHing the given object to the URL,
and return the representation found in the response.
|
<T> ResponseEntity<T> |
postForEntity(java.lang.String url,
java.lang.Object request,
java.lang.Class<T> responseType,
java.util.Map<java.lang.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(java.lang.String url,
java.lang.Object request,
java.lang.Class<T> responseType,
java.lang.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(java.net.URI url,
java.lang.Object request,
java.lang.Class<T> responseType)
Create a new resource by POSTing the given object to the URL,
and returns the response as
ResponseEntity . |
java.net.URI |
postForLocation(java.lang.String url,
java.lang.Object request,
java.util.Map<java.lang.String,?> uriVariables)
Create a new resource by POSTing the given object to the URI template, and returns the value of
the
Location header. |
java.net.URI |
postForLocation(java.lang.String url,
java.lang.Object request,
java.lang.Object... uriVariables)
Create a new resource by POSTing the given object to the URI template, and returns the value of
the
Location header. |
java.net.URI |
postForLocation(java.net.URI url,
java.lang.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(java.lang.String url,
java.lang.Object request,
java.lang.Class<T> responseType,
java.util.Map<java.lang.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(java.lang.String url,
java.lang.Object request,
java.lang.Class<T> responseType,
java.lang.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(java.net.URI url,
java.lang.Object request,
java.lang.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(java.lang.String url,
java.lang.Object request,
java.util.Map<java.lang.String,?> uriVariables)
Creates a new resource by PUTting the given object to URI template.
|
void |
put(java.lang.String url,
java.lang.Object request,
java.lang.Object... uriVariables)
Create or update a resource by PUTting the given object to the URI.
|
void |
put(java.net.URI url,
java.lang.Object request)
Creates a new resource by PUTting the given object to URL.
|
@Nullable <T> T getForObject(java.lang.String url, java.lang.Class<T> responseType, java.lang.Object... uriVariables) throws RestClientException
URI Template variables are expanded using the given URI variables, if any.
url
- the URLresponseType
- the type of the return valueuriVariables
- the variables to expand the templateRestClientException
@Nullable <T> T getForObject(java.lang.String url, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
URI Template variables are expanded using the given map.
url
- the URLresponseType
- the type of the return valueuriVariables
- the map containing variables for the URI templateRestClientException
@Nullable <T> T getForObject(java.net.URI url, java.lang.Class<T> responseType) throws RestClientException
url
- the URLresponseType
- the type of the return valueRestClientException
<T> ResponseEntity<T> getForEntity(java.lang.String url, java.lang.Class<T> responseType, java.lang.Object... uriVariables) throws RestClientException
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
url
- the URLresponseType
- the type of the return valueuriVariables
- the variables to expand the templateRestClientException
<T> ResponseEntity<T> getForEntity(java.lang.String url, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
ResponseEntity
.
URI Template variables are expanded using the given map.
url
- the URLresponseType
- the type of the return valueuriVariables
- the map containing variables for the URI templateRestClientException
<T> ResponseEntity<T> getForEntity(java.net.URI url, java.lang.Class<T> responseType) throws RestClientException
ResponseEntity
.url
- the URLresponseType
- the type of the return valueRestClientException
HttpHeaders headForHeaders(java.lang.String url, java.lang.Object... uriVariables) throws RestClientException
URI Template variables are expanded using the given URI variables, if any.
url
- the URLuriVariables
- the variables to expand the templateRestClientException
HttpHeaders headForHeaders(java.lang.String url, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
URI Template variables are expanded using the given map.
url
- the URLuriVariables
- the map containing variables for the URI templateRestClientException
HttpHeaders headForHeaders(java.net.URI url) throws RestClientException
url
- the URLRestClientException
@Nullable java.net.URI postForLocation(java.lang.String url, @Nullable java.lang.Object request, java.lang.Object... uriVariables) throws RestClientException
Location
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.
The body of the entity, or request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the MultiValueMap
can be any Object representing the body of the part,
or an HttpEntity
representing a part with body
and headers. The MultiValueMap
can be built conveniently using
MultipartBodyBuilder
.
url
- the URLrequest
- the Object to be POSTed (may be null
)uriVariables
- the variables to expand the templateLocation
headerRestClientException
HttpEntity
@Nullable java.net.URI postForLocation(java.lang.String url, @Nullable java.lang.Object request, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
Location
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
The body of the entity, or request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the MultiValueMap
can be any Object representing the body of the part,
or an HttpEntity
representing a part with body
and headers. The MultiValueMap
can be built conveniently using
MultipartBodyBuilder
.
url
- the URLrequest
- the Object to be POSTed (may be null
)uriVariables
- the variables to expand the templateLocation
headerRestClientException
HttpEntity
@Nullable java.net.URI postForLocation(java.net.URI url, @Nullable java.lang.Object request) throws RestClientException
Location
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.
The body of the entity, or request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the MultiValueMap
can be any Object representing the body of the part,
or an HttpEntity
representing a part with body
and headers. The MultiValueMap
can be built conveniently using
MultipartBodyBuilder
.
url
- the URLrequest
- the Object to be POSTed (may be null
)Location
headerRestClientException
HttpEntity
@Nullable <T> T postForObject(java.lang.String url, @Nullable java.lang.Object request, java.lang.Class<T> responseType, java.lang.Object... uriVariables) throws RestClientException
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.
The body of the entity, or request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the MultiValueMap
can be any Object representing the body of the part,
or an HttpEntity
representing a part with body
and headers. The MultiValueMap
can be built conveniently using
MultipartBodyBuilder
.
url
- the URLrequest
- the Object to be POSTed (may be null
)responseType
- the type of the return valueuriVariables
- the variables to expand the templateRestClientException
HttpEntity
@Nullable <T> T postForObject(java.lang.String url, @Nullable java.lang.Object request, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
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.
The body of the entity, or request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the MultiValueMap
can be any Object representing the body of the part,
or an HttpEntity
representing a part with body
and headers. The MultiValueMap
can be built conveniently using
MultipartBodyBuilder
.
url
- the URLrequest
- the Object to be POSTed (may be null
)responseType
- the type of the return valueuriVariables
- the variables to expand the templateRestClientException
HttpEntity
@Nullable <T> T postForObject(java.net.URI url, @Nullable java.lang.Object request, java.lang.Class<T> responseType) throws RestClientException
The request
parameter can be a HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the MultiValueMap
can be any Object representing the body of the part,
or an HttpEntity
representing a part with body
and headers. The MultiValueMap
can be built conveniently using
MultipartBodyBuilder
.
url
- the URLrequest
- the Object to be POSTed (may be null
)responseType
- the type of the return valueRestClientException
HttpEntity
<T> ResponseEntity<T> postForEntity(java.lang.String url, @Nullable java.lang.Object request, java.lang.Class<T> responseType, java.lang.Object... uriVariables) throws RestClientException
ResponseEntity
.
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.
The body of the entity, or request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the MultiValueMap
can be any Object representing the body of the part,
or an HttpEntity
representing a part with body
and headers. The MultiValueMap
can be built conveniently using
MultipartBodyBuilder
.
url
- the URLrequest
- the Object to be POSTed (may be null
)uriVariables
- the variables to expand the templateRestClientException
HttpEntity
<T> ResponseEntity<T> postForEntity(java.lang.String url, @Nullable java.lang.Object request, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
HttpEntity
.
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.
The body of the entity, or request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the MultiValueMap
can be any Object representing the body of the part,
or an HttpEntity
representing a part with body
and headers. The MultiValueMap
can be built conveniently using
MultipartBodyBuilder
.
url
- the URLrequest
- the Object to be POSTed (may be null
)uriVariables
- the variables to expand the templateRestClientException
HttpEntity
<T> ResponseEntity<T> postForEntity(java.net.URI url, @Nullable java.lang.Object request, java.lang.Class<T> responseType) throws RestClientException
ResponseEntity
.
The request
parameter can be a HttpEntity
in order to
add additional HTTP headers to the request.
The body of the entity, or request
itself, can be a
MultiValueMap
to create a multipart request.
The values in the MultiValueMap
can be any Object representing the body of the part,
or an HttpEntity
representing a part with body
and headers. The MultiValueMap
can be built conveniently using
MultipartBodyBuilder
.
url
- the URLrequest
- the Object to be POSTed (may be null
)RestClientException
HttpEntity
void put(java.lang.String url, @Nullable java.lang.Object request, java.lang.Object... uriVariables) throws RestClientException
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.
url
- the URLrequest
- the Object to be PUT (may be null
)uriVariables
- the variables to expand the templateRestClientException
HttpEntity
void put(java.lang.String url, @Nullable java.lang.Object request, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
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.
url
- the URLrequest
- the Object to be PUT (may be null
)uriVariables
- the variables to expand the templateRestClientException
HttpEntity
void put(java.net.URI url, @Nullable java.lang.Object request) throws RestClientException
The request
parameter can be a HttpEntity
in order to
add additional HTTP headers to the request.
url
- the URLrequest
- the Object to be PUT (may be null
)RestClientException
HttpEntity
@Nullable <T> T patchForObject(java.lang.String url, @Nullable java.lang.Object request, java.lang.Class<T> responseType, java.lang.Object... uriVariables) throws RestClientException
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.
NOTE: The standard JDK HTTP library does not support HTTP PATCH. You need to use the Apache HttpComponents or OkHttp request factory.
url
- the URLrequest
- the object to be PATCHed (may be null
)responseType
- the type of the return valueuriVariables
- the variables to expand the templateRestClientException
HttpEntity
,
InterceptingHttpAccessor.setRequestFactory(org.springframework.http.client.ClientHttpRequestFactory)
,
HttpComponentsAsyncClientHttpRequestFactory
,
OkHttp3ClientHttpRequestFactory
@Nullable <T> T patchForObject(java.lang.String url, @Nullable java.lang.Object request, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
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.
NOTE: The standard JDK HTTP library does not support HTTP PATCH. You need to use the Apache HttpComponents or OkHttp request factory.
url
- the URLrequest
- the object to be PATCHed (may be null
)responseType
- the type of the return valueuriVariables
- the variables to expand the templateRestClientException
HttpEntity
,
InterceptingHttpAccessor.setRequestFactory(org.springframework.http.client.ClientHttpRequestFactory)
,
HttpComponentsAsyncClientHttpRequestFactory
,
OkHttp3ClientHttpRequestFactory
@Nullable <T> T patchForObject(java.net.URI url, @Nullable java.lang.Object request, java.lang.Class<T> responseType) throws RestClientException
The request
parameter can be a HttpEntity
in order to
add additional HTTP headers to the request.
NOTE: The standard JDK HTTP library does not support HTTP PATCH. You need to use the Apache HttpComponents or OkHttp request factory.
url
- the URLrequest
- the object to be PATCHed (may be null
)responseType
- the type of the return valueRestClientException
HttpEntity
,
InterceptingHttpAccessor.setRequestFactory(org.springframework.http.client.ClientHttpRequestFactory)
,
HttpComponentsAsyncClientHttpRequestFactory
,
OkHttp3ClientHttpRequestFactory
void delete(java.lang.String url, java.lang.Object... uriVariables) throws RestClientException
URI Template variables are expanded using the given URI variables, if any.
url
- the URLuriVariables
- the variables to expand in the templateRestClientException
void delete(java.lang.String url, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
URI Template variables are expanded using the given map.
url
- the URLuriVariables
- the variables to expand the templateRestClientException
void delete(java.net.URI url) throws RestClientException
url
- the URLRestClientException
java.util.Set<HttpMethod> optionsForAllow(java.lang.String url, java.lang.Object... uriVariables) throws RestClientException
URI Template variables are expanded using the given URI variables, if any.
url
- the URLuriVariables
- the variables to expand in the templateRestClientException
java.util.Set<HttpMethod> optionsForAllow(java.lang.String url, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
URI Template variables are expanded using the given map.
url
- the URLuriVariables
- the variables to expand in the templateRestClientException
java.util.Set<HttpMethod> optionsForAllow(java.net.URI url) throws RestClientException
url
- the URLRestClientException
<T> ResponseEntity<T> exchange(java.lang.String url, HttpMethod method, @Nullable HttpEntity<?> requestEntity, java.lang.Class<T> responseType, java.lang.Object... uriVariables) throws RestClientException
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
url
- the URLmethod
- the HTTP method (GET, POST, etc)requestEntity
- the entity (headers and/or body) to write to the request
may be null
)responseType
- the type of the return valueuriVariables
- the variables to expand in the templateRestClientException
<T> ResponseEntity<T> exchange(java.lang.String url, HttpMethod method, @Nullable HttpEntity<?> requestEntity, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
url
- the URLmethod
- the HTTP method (GET, POST, etc)requestEntity
- the entity (headers and/or body) to write to the request
(may be null
)responseType
- the type of the return valueuriVariables
- the variables to expand in the templateRestClientException
<T> ResponseEntity<T> exchange(java.net.URI url, HttpMethod method, @Nullable HttpEntity<?> requestEntity, java.lang.Class<T> responseType) throws RestClientException
ResponseEntity
.url
- the URLmethod
- the HTTP method (GET, POST, etc)requestEntity
- the entity (headers and/or body) to write to the request
(may be null
)responseType
- the type of the return valueRestClientException
<T> ResponseEntity<T> exchange(java.lang.String url, HttpMethod method, @Nullable HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType, java.lang.Object... uriVariables) throws RestClientException
ResponseEntity
.
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);
url
- the URLmethod
- the HTTP method (GET, POST, etc)requestEntity
- the entity (headers and/or body) to write to the
request (may be null
)responseType
- the type of the return valueuriVariables
- the variables to expand in the templateRestClientException
<T> ResponseEntity<T> exchange(java.lang.String url, HttpMethod method, @Nullable HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
ResponseEntity
.
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);
url
- the URLmethod
- the HTTP method (GET, POST, etc)requestEntity
- the entity (headers and/or body) to write to the request
(may be null
)responseType
- the type of the return valueuriVariables
- the variables to expand in the templateRestClientException
<T> ResponseEntity<T> exchange(java.net.URI url, HttpMethod method, @Nullable HttpEntity<?> requestEntity, ParameterizedTypeReference<T> responseType) throws RestClientException
ResponseEntity
.
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);
url
- the URLmethod
- the HTTP method (GET, POST, etc)requestEntity
- the entity (headers and/or body) to write to the request
(may be null
)responseType
- the type of the return valueRestClientException
<T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, java.lang.Class<T> responseType) throws RestClientException
RequestEntity
and return
the response as ResponseEntity
. Typically used in combination
with the static builder methods on RequestEntity
, for instance:
MyRequest body = ... RequestEntity request = RequestEntity .post(new URI("http://example.com/foo")) .accept(MediaType.APPLICATION_JSON) .body(body); ResponseEntity<MyResponse> response = template.exchange(request, MyResponse.class);
requestEntity
- the entity to write to the requestresponseType
- the type of the return valueRestClientException
<T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, ParameterizedTypeReference<T> responseType) throws RestClientException
RequestEntity
and return
the response as ResponseEntity
. The given
ParameterizedTypeReference
is used to pass generic type information:
MyRequest body = ... RequestEntity request = RequestEntity .post(new URI("http://example.com/foo")) .accept(MediaType.APPLICATION_JSON) .body(body); ParameterizedTypeReference<List<MyResponse>> myBean = new ParameterizedTypeReference<List<MyResponse>>() {}; ResponseEntity<List<MyResponse>> response = template.exchange(request, myBean);
requestEntity
- the entity to write to the requestresponseType
- the type of the return valueRestClientException
@Nullable <T> T execute(java.lang.String url, HttpMethod method, @Nullable RequestCallback requestCallback, @Nullable ResponseExtractor<T> responseExtractor, java.lang.Object... uriVariables) throws RestClientException
RequestCallback
, and reading the response with a ResponseExtractor
.
URI Template variables are expanded using the given URI variables, if any.
url
- the URLmethod
- the HTTP method (GET, POST, etc)requestCallback
- object that prepares the requestresponseExtractor
- object that extracts the return value from the responseuriVariables
- the variables to expand in the templateResponseExtractor
RestClientException
@Nullable <T> T execute(java.lang.String url, HttpMethod method, @Nullable RequestCallback requestCallback, @Nullable ResponseExtractor<T> responseExtractor, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
RequestCallback
, and reading the response with a ResponseExtractor
.
URI Template variables are expanded using the given URI variables map.
url
- the URLmethod
- the HTTP method (GET, POST, etc)requestCallback
- object that prepares the requestresponseExtractor
- object that extracts the return value from the responseuriVariables
- the variables to expand in the templateResponseExtractor
RestClientException
@Nullable <T> T execute(java.net.URI url, HttpMethod method, @Nullable RequestCallback requestCallback, @Nullable ResponseExtractor<T> responseExtractor) throws RestClientException
RequestCallback
, and reading the response with a ResponseExtractor
.url
- the URLmethod
- the HTTP method (GET, POST, etc)requestCallback
- object that prepares the requestresponseExtractor
- object that extracts the return value from the responseResponseExtractor
RestClientException