@Component public class HttpClientOxmTemplate<T> extends AbstractHttpClientTemplate<T> implements InitializingBean
HttpClient
and
also uses Spring Web Services OXM framework to marshall/unmarshall
XML from requests and responses.Modifier and Type | Field and Description |
---|---|
protected Marshaller |
marshaller |
protected Unmarshaller |
unmarshaller |
authenticationPreemptive, client, connectionManager, defaultUri, lCredentials
Constructor and Description |
---|
HttpClientOxmTemplate()
Constructor.
|
HttpClientOxmTemplate(String defaultUri)
Constructor.
|
HttpClientOxmTemplate(String defaultUri,
Marshaller marshaller,
Unmarshaller unmarshaller)
Constructor.
|
HttpClientOxmTemplate(String defaultUri,
Marshaller marshaller,
Unmarshaller unmarshaller,
boolean init)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Implementation of
InitializingBean
that initializes the HttpClient if it is null
and also sets the connection manager to MultiThreadedHttpConnectionManager
if it is null while initializing the HttpClient . |
void |
executePostMethod(String uri,
T requestPayload,
Map<String,String> hParams,
ResponseCallback<?> callback)
Execute post method.
|
void |
executePostMethod(T requestPayload)
Execute post method.
|
void |
executePostMethod(T requestPayload,
Map<String,String> hParams)
Execute post method.
|
void |
executePostMethod(T requestPayload,
Map<String,String> hParams,
ResponseCallback<?> callback)
Execute post method.
|
void |
executePostMethod(T requestPayload,
ResponseCallback<?> callback)
Execute post method.
|
Marshaller |
getMarshaller()
Gets marshaller.
|
Unmarshaller |
getUnmarshaller()
Gets unmarshaller.
|
protected void |
processHttpMethod(org.apache.commons.httpclient.HttpMethod httpMethod,
ResponseCallback callback)
Processes
HttpMethod by executing the method,
validating the response, and calling the callback. |
void |
setMarshaller(Marshaller marshaller)
Sets marshaller.
|
void |
setUnmarshaller(Unmarshaller unmarshaller)
Sets unmarshaller.
|
destroy, executeGetMethod, executeGetMethod, executeGetMethod, executeGetMethod, executeGetMethod, executeGetMethod, executePostMethod, executePostMethod, executePostMethod, executePostMethod, executePostMethod, getClient, getConnectionManager, getCredentials, getDefaultUri, isAuthenticationPreemptive, processHttpMethodParams, setAuthenticationPreemptive, setClient, setConnectionManager, setCredentials, setDefaultUri, validateResponse
protected Marshaller marshaller
protected Unmarshaller unmarshaller
public HttpClientOxmTemplate()
public HttpClientOxmTemplate(String defaultUri)
defaultUri
- Default uri.public HttpClientOxmTemplate(String defaultUri, Marshaller marshaller, Unmarshaller unmarshaller)
defaultUri
- Default uri.marshaller
- Marshaller to use for marshalling requests.unmarshaller
- Unmarshaller to use for unmarshalling requests.public HttpClientOxmTemplate(String defaultUri, Marshaller marshaller, Unmarshaller unmarshaller, boolean init)
defaultUri
- Default uri.marshaller
- Marshaller to use for marshalling requests.unmarshaller
- Unmarshaller to use for unmarshalling requests.init
- Whether or not to initialize the bean.public Marshaller getMarshaller()
public void setMarshaller(Marshaller marshaller)
public Unmarshaller getUnmarshaller()
public void setUnmarshaller(Unmarshaller unmarshaller)
public void afterPropertiesSet() throws Exception
InitializingBean
that initializes the HttpClient
if it is null
and also sets the connection manager to MultiThreadedHttpConnectionManager
if it is null
while initializing the HttpClient
.afterPropertiesSet
in interface InitializingBean
afterPropertiesSet
in class AbstractHttpClientTemplate<T>
Exception
public void executePostMethod(T requestPayload)
requestPayload
- Request data to post after marshalling.
The Marshaller
should be able to
process this instance.public void executePostMethod(T requestPayload, ResponseCallback<?> callback)
requestPayload
- Request data to post after marshalling.
The Marshaller
should be able to
process this instance.callback
- Callback with HTTP method's response.public void executePostMethod(T requestPayload, Map<String,String> hParams)
requestPayload
- Request data to post after marshalling.
The Marshaller
should be able to
process this instance.hParams
- Parameters for the HTTP post.public void executePostMethod(T requestPayload, Map<String,String> hParams, ResponseCallback<?> callback)
requestPayload
- Request data to post after marshalling.
The Marshaller
should be able to
process this instance.hParams
- Parameters for the HTTP post.callback
- Callback with HTTP method's response.public void executePostMethod(String uri, T requestPayload, Map<String,String> hParams, ResponseCallback<?> callback)
executePostMethod
in class AbstractHttpClientTemplate<T>
uri
- URI to use when processing this HTTP request instead
of using the default URI.requestPayload
- Request data to post after marshalling.
The Marshaller
should be able to
process this instance.hParams
- Parameters for the HTTP post.callback
- Callback with HTTP method's response.protected void processHttpMethod(org.apache.commons.httpclient.HttpMethod httpMethod, ResponseCallback callback)
HttpMethod
by executing the method,
validating the response, and calling the callback.processHttpMethod
in class AbstractHttpClientTemplate<T>
httpMethod
- HttpMethod
to process.callback
- Callback with HTTP method's response.Copyright © 2008-2015 Spring by Example. All Rights Reserved.