|
Spring for Android | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.springframework.http.client.support.HttpAccessor
org.springframework.http.client.support.InterceptingHttpAccessor
org.springframework.web.client.RestTemplate
public class RestTemplate
The central class for client-side HTTP access. It simplifies communication with HTTP servers, and enforces RESTful principles. It handles HTTP connections, leaving application code to provide URLs (with possible template variables) and extract results.
The main entry points of this template are the methods named after the six main HTTP methods:
For each of these HTTP methods, there are three corresponding Java methods in the RestTemplate
. Two
variant 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. For performance purposes, no converters are registered when using the default
constructor. When you create a new RestTemplate instance, you can then select and customize which converters to
register. This is accomplished via the messageConverters
bean property. You can also
write your own converter and register it the same way.
Alternate constructors allow you to specify whether to include a default set of converters for the main mime types. These converters are listed in the following table, and are registered based on the corresponding rule.
Message Body Converter | Rule |
---|---|
ByteArrayHttpMessageConverter | Always included |
StringHttpMessageConverter | |
ResourceHttpMessageConverter | |
SourceHttpMessageConverter | Included on Android 2.2 (Froyo) or newer,
where Source is available. |
XmlAwareFormHttpMessageConverter | |
FormHttpMessageConverter | Included on Android 2.1 (Eclair) and older. |
SimpleXmlHttpMessageConverter | Included if the Simple XML serializer is present. |
MappingJacksonHttpMessageConverter | Included if the Jackson JSON processor is present. |
SyndFeedHttpMessageConverter | Included if the Android ROME Feed Reader is present. |
This template uses a HttpComponentsClientHttpRequestFactory
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
Constructor Summary | |
---|---|
RestTemplate()
Create a new instance of RestTemplate . |
|
RestTemplate(boolean includeDefaultConverters)
Create a new instance of RestTemplate . |
|
RestTemplate(boolean includeDefaultConverters,
ClientHttpRequestFactory requestFactory)
Create a new instance of RestTemplate based on the given ClientHttpRequestFactory . |
|
RestTemplate(ClientHttpRequestFactory requestFactory)
Create a new instance of RestTemplate based on the given ClientHttpRequestFactory . |
Method Summary | ||
---|---|---|
void |
delete(java.lang.String url,
java.util.Map<java.lang.String,?> urlVariables)
Delete the resources at the specified URI. |
|
void |
delete(java.lang.String url,
java.lang.Object... urlVariables)
Delete the resources at the specified URI. |
|
void |
delete(java.net.URI url)
Delete the resources at the specified URL. |
|
protected
|
doExecute(java.net.URI url,
HttpMethod method,
RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor)
Execute the given method on the provided URI. |
|
|
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 . |
|
|
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 . |
|
|
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 . |
|
|
execute(java.lang.String url,
HttpMethod method,
RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor,
java.util.Map<java.lang.String,?> urlVariables)
Execute the HTTP method to the given URI template, preparing the request with the RequestCallback , and reading the response with a ResponseExtractor . |
|
|
execute(java.lang.String url,
HttpMethod method,
RequestCallback requestCallback,
ResponseExtractor<T> responseExtractor,
java.lang.Object... urlVariables)
Execute the HTTP method to the given URI template, preparing the request with the RequestCallback , and reading the response with a ResponseExtractor . |
|
|
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 . |
|
ResponseErrorHandler |
getErrorHandler()
Return the error handler. |
|
|
getForEntity(java.lang.String url,
java.lang.Class<T> responseType,
java.util.Map<java.lang.String,?> urlVariables)
Retrieve a representation by doing a GET on the URI template. |
|
|
getForEntity(java.lang.String url,
java.lang.Class<T> responseType,
java.lang.Object... urlVariables)
Retrieve an entity by doing a GET on the specified URL. |
|
|
getForEntity(java.net.URI url,
java.lang.Class<T> responseType)
Retrieve a representation by doing a GET on the URL . |
|
|
getForObject(java.lang.String url,
java.lang.Class<T> responseType,
java.util.Map<java.lang.String,?> urlVariables)
Retrieve a representation by doing a GET on the URI template. |
|
|
getForObject(java.lang.String url,
java.lang.Class<T> responseType,
java.lang.Object... urlVariables)
Retrieve a representation by doing a GET on the specified URL. |
|
|
getForObject(java.net.URI url,
java.lang.Class<T> responseType)
Retrieve a representation by doing a GET on the URL . |
|
java.util.List<HttpMessageConverter<?>> |
getMessageConverters()
Returns the message body converters. |
|
HttpHeaders |
headForHeaders(java.lang.String url,
java.util.Map<java.lang.String,?> urlVariables)
Retrieve all headers of the resource specified by the URI template. |
|
HttpHeaders |
headForHeaders(java.lang.String url,
java.lang.Object... urlVariables)
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,?> urlVariables)
Return the value of the Allow header for the given URI. |
|
java.util.Set<HttpMethod> |
optionsForAllow(java.lang.String url,
java.lang.Object... urlVariables)
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. |
|
|
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 . |
|
|
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 . |
|
|
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,?> urlVariables)
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... urlVariables)
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. |
|
|
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. |
|
|
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. |
|
|
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,?> urlVariables)
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... urlVariables)
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. |
|
void |
setErrorHandler(ResponseErrorHandler errorHandler)
Set the error handler. |
|
void |
setMessageConverters(java.util.List<HttpMessageConverter<?>> messageConverters)
Set the message body converters to use. |
Methods inherited from class org.springframework.http.client.support.InterceptingHttpAccessor |
---|
getInterceptors, getRequestFactory, setInterceptors |
Methods inherited from class org.springframework.http.client.support.HttpAccessor |
---|
createRequest, setRequestFactory |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RestTemplate()
RestTemplate
.
For performance purposes, no message body converters are included when using this constructor.
You must register a converter via the messageConverters
property in order to
process HTTP messages.
HttpMessageConverter
public RestTemplate(boolean includeDefaultConverters)
RestTemplate
.
For performance purposes, no message body converters are registered when using the default constructor.
However, this constructor allows you to specify whether to include a default set of converters, which are listed
in the RestTemplate
javadoc.
includeDefaultConverters
- true to add the default set of message body convertersHttpMessageConverter
public RestTemplate(ClientHttpRequestFactory requestFactory)
RestTemplate
based on the given ClientHttpRequestFactory
.
For performance purposes, no message body converters are included when using this constructor.
You must register a converter via the messageConverters
property in order to
process HTTP messages.
requestFactory
- HTTP request factory to useSimpleClientHttpRequestFactory
,
HttpComponentsClientHttpRequestFactory
public RestTemplate(boolean includeDefaultConverters, ClientHttpRequestFactory requestFactory)
RestTemplate
based on the given ClientHttpRequestFactory
.
For performance purposes, no message body converters are registered when using the default constructor.
However, this constructor allows you to specify whether to include a default set of converters, which are listed
in the RestTemplate
javadoc.
includeDefaultConverters
- true to add the default set of message body convertersrequestFactory
- HTTP request factory to useHttpMessageConverter
,
SimpleClientHttpRequestFactory
,
HttpComponentsClientHttpRequestFactory
Method Detail |
---|
public void setMessageConverters(java.util.List<HttpMessageConverter<?>> messageConverters)
public java.util.List<HttpMessageConverter<?>> getMessageConverters()
public void setErrorHandler(ResponseErrorHandler errorHandler)
public ResponseErrorHandler getErrorHandler()
DefaultResponseErrorHandler
.
public <T> T getForObject(java.lang.String url, java.lang.Class<T> responseType, java.lang.Object... urlVariables) throws RestClientException
RestOperations
URI Template variables are expanded using the given URI variables, if any.
getForObject
in interface RestOperations
url
- the URLresponseType
- the type of the return valueurlVariables
- the variables to expand the template
RestClientException
public <T> T getForObject(java.lang.String url, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> urlVariables) throws RestClientException
RestOperations
URI Template variables are expanded using the given map.
getForObject
in interface RestOperations
url
- the URLresponseType
- the type of the return valueurlVariables
- the map containing variables for the URI template
RestClientException
public <T> T getForObject(java.net.URI url, java.lang.Class<T> responseType) throws RestClientException
RestOperations
getForObject
in interface RestOperations
url
- the URLresponseType
- the type of the return value
RestClientException
public <T> ResponseEntity<T> getForEntity(java.lang.String url, java.lang.Class<T> responseType, java.lang.Object... urlVariables) throws RestClientException
RestOperations
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
getForEntity
in interface RestOperations
url
- the URLresponseType
- the type of the return valueurlVariables
- the variables to expand the template
RestClientException
public <T> ResponseEntity<T> getForEntity(java.lang.String url, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> urlVariables) throws RestClientException
RestOperations
ResponseEntity
.
URI Template variables are expanded using the given map.
getForEntity
in interface RestOperations
url
- the URLresponseType
- the type of the return valueurlVariables
- the map containing variables for the URI template
RestClientException
public <T> ResponseEntity<T> getForEntity(java.net.URI url, java.lang.Class<T> responseType) throws RestClientException
RestOperations
ResponseEntity
.
getForEntity
in interface RestOperations
url
- the URLresponseType
- the type of the return value
RestClientException
public HttpHeaders headForHeaders(java.lang.String url, java.lang.Object... urlVariables) throws RestClientException
RestOperations
URI Template variables are expanded using the given URI variables, if any.
headForHeaders
in interface RestOperations
url
- the URLurlVariables
- the variables to expand the template
RestClientException
public HttpHeaders headForHeaders(java.lang.String url, java.util.Map<java.lang.String,?> urlVariables) throws RestClientException
RestOperations
URI Template variables are expanded using the given map.
headForHeaders
in interface RestOperations
url
- the URLurlVariables
- the map containing variables for the URI template
RestClientException
public HttpHeaders headForHeaders(java.net.URI url) throws RestClientException
RestOperations
headForHeaders
in interface RestOperations
url
- the URL
RestClientException
public java.net.URI postForLocation(java.lang.String url, java.lang.Object request, java.lang.Object... urlVariables) throws RestClientException
RestOperations
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.
postForLocation
in interface RestOperations
url
- the URLrequest
- the Object to be POSTed, may be null
urlVariables
- the variables to expand the template
Location
header
RestClientException
HttpEntity
public java.net.URI postForLocation(java.lang.String url, java.lang.Object request, java.util.Map<java.lang.String,?> urlVariables) throws RestClientException
RestOperations
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.
postForLocation
in interface RestOperations
url
- the URLrequest
- the Object to be POSTed, may be null
urlVariables
- the variables to expand the template
Location
header
RestClientException
HttpEntity
public java.net.URI postForLocation(java.net.URI url, java.lang.Object request) throws RestClientException
RestOperations
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.
postForLocation
in interface RestOperations
url
- the URLrequest
- the Object to be POSTed, may be null
Location
header
RestClientException
HttpEntity
public <T> T postForObject(java.lang.String url, java.lang.Object request, java.lang.Class<T> responseType, java.lang.Object... uriVariables) throws RestClientException
RestOperations
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.
postForObject
in interface RestOperations
url
- the URLrequest
- the Object to be POSTed, may be null
responseType
- the type of the return valueuriVariables
- the variables to expand the template
RestClientException
HttpEntity
public <T> T postForObject(java.lang.String url, java.lang.Object request, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
RestOperations
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.
postForObject
in interface RestOperations
url
- the URLrequest
- the Object to be POSTed, may be null
responseType
- the type of the return valueuriVariables
- the variables to expand the template
RestClientException
HttpEntity
public <T> T postForObject(java.net.URI url, java.lang.Object request, java.lang.Class<T> responseType) throws RestClientException
RestOperations
The request
parameter can be a HttpEntity
in order to
add additional HTTP headers to the request.
postForObject
in interface RestOperations
url
- the URLrequest
- the Object to be POSTed, may be null
responseType
- the type of the return value
RestClientException
HttpEntity
public <T> ResponseEntity<T> postForEntity(java.lang.String url, java.lang.Object request, java.lang.Class<T> responseType, java.lang.Object... uriVariables) throws RestClientException
RestOperations
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.
postForEntity
in interface RestOperations
url
- the URLrequest
- the Object to be POSTed, may be null
uriVariables
- the variables to expand the template
RestClientException
HttpEntity
public <T> ResponseEntity<T> postForEntity(java.lang.String url, java.lang.Object request, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
RestOperations
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.
postForEntity
in interface RestOperations
url
- the URLrequest
- the Object to be POSTed, may be null
uriVariables
- the variables to expand the template
RestClientException
HttpEntity
public <T> ResponseEntity<T> postForEntity(java.net.URI url, java.lang.Object request, java.lang.Class<T> responseType) throws RestClientException
RestOperations
ResponseEntity
.
The request
parameter can be a HttpEntity
in order to
add additional HTTP headers to the request.
postForEntity
in interface RestOperations
url
- the URLrequest
- the Object to be POSTed, may be null
RestClientException
HttpEntity
public void put(java.lang.String url, java.lang.Object request, java.lang.Object... urlVariables) throws RestClientException
RestOperations
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.
put
in interface RestOperations
url
- the URLrequest
- the Object to be PUT, may be null
urlVariables
- the variables to expand the template
RestClientException
HttpEntity
public void put(java.lang.String url, java.lang.Object request, java.util.Map<java.lang.String,?> urlVariables) throws RestClientException
RestOperations
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.
put
in interface RestOperations
url
- the URLrequest
- the Object to be PUT, may be null
urlVariables
- the variables to expand the template
RestClientException
HttpEntity
public void put(java.net.URI url, java.lang.Object request) throws RestClientException
RestOperations
The request
parameter can be a HttpEntity
in order to
add additional HTTP headers to the request.
put
in interface RestOperations
url
- the URLrequest
- the Object to be PUT, may be null
RestClientException
HttpEntity
public void delete(java.lang.String url, java.lang.Object... urlVariables) throws RestClientException
RestOperations
URI Template variables are expanded using the given URI variables, if any.
delete
in interface RestOperations
url
- the URLurlVariables
- the variables to expand in the template
RestClientException
public void delete(java.lang.String url, java.util.Map<java.lang.String,?> urlVariables) throws RestClientException
RestOperations
URI Template variables are expanded using the given map.
delete
in interface RestOperations
url
- the URLurlVariables
- the variables to expand the template
RestClientException
public void delete(java.net.URI url) throws RestClientException
RestOperations
delete
in interface RestOperations
url
- the URL
RestClientException
public java.util.Set<HttpMethod> optionsForAllow(java.lang.String url, java.lang.Object... urlVariables) throws RestClientException
RestOperations
URI Template variables are expanded using the given URI variables, if any.
optionsForAllow
in interface RestOperations
url
- the URLurlVariables
- the variables to expand in the template
RestClientException
public java.util.Set<HttpMethod> optionsForAllow(java.lang.String url, java.util.Map<java.lang.String,?> urlVariables) throws RestClientException
RestOperations
URI Template variables are expanded using the given map.
optionsForAllow
in interface RestOperations
url
- the URLurlVariables
- the variables to expand in the template
RestClientException
public java.util.Set<HttpMethod> optionsForAllow(java.net.URI url) throws RestClientException
RestOperations
optionsForAllow
in interface RestOperations
url
- the URL
RestClientException
public <T> ResponseEntity<T> exchange(java.lang.String url, HttpMethod method, HttpEntity<?> requestEntity, java.lang.Class<T> responseType, java.lang.Object... uriVariables) throws RestClientException
RestOperations
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
exchange
in interface RestOperations
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 template
RestClientException
public <T> ResponseEntity<T> exchange(java.lang.String url, HttpMethod method, HttpEntity<?> requestEntity, java.lang.Class<T> responseType, java.util.Map<java.lang.String,?> uriVariables) throws RestClientException
RestOperations
ResponseEntity
.
URI Template variables are expanded using the given URI variables, if any.
exchange
in interface RestOperations
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 template
RestClientException
public <T> ResponseEntity<T> exchange(java.net.URI url, HttpMethod method, HttpEntity<?> requestEntity, java.lang.Class<T> responseType) throws RestClientException
RestOperations
ResponseEntity
.
exchange
in interface RestOperations
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 value
RestClientException
public <T> T execute(java.lang.String url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor, java.lang.Object... urlVariables) throws RestClientException
RestOperations
RequestCallback
, and reading the response with a ResponseExtractor
.
URI Template variables are expanded using the given URI variables, if any.
execute
in interface RestOperations
url
- 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 template
ResponseExtractor
RestClientException
public <T> T execute(java.lang.String url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor, java.util.Map<java.lang.String,?> urlVariables) throws RestClientException
RestOperations
RequestCallback
, and reading the response with a ResponseExtractor
.
URI Template variables are expanded using the given URI variables map.
execute
in interface RestOperations
url
- 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 template
ResponseExtractor
RestClientException
public <T> T execute(java.net.URI url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor) throws RestClientException
RestOperations
RequestCallback
, and reading the response with a ResponseExtractor
.
execute
in interface RestOperations
url
- the URLmethod
- the HTTP method (GET, POST, etc)requestCallback
- object that prepares the requestresponseExtractor
- object that extracts the return value from the response
ResponseExtractor
RestClientException
protected <T> T doExecute(java.net.URI url, HttpMethod method, RequestCallback requestCallback, ResponseExtractor<T> responseExtractor) throws RestClientException
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
)
ResponseExtractor
RestClientException
|
Spring for Android | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES All Classes | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |