Class HttpComponents5MessageSender
java.lang.Object
org.springframework.ws.transport.http.AbstractHttpWebServiceMessageSender
org.springframework.ws.transport.http.HttpComponents5MessageSender
- All Implemented Interfaces:
org.springframework.beans.factory.DisposableBean,org.springframework.beans.factory.InitializingBean,WebServiceMessageSender
public class HttpComponents5MessageSender
extends AbstractHttpWebServiceMessageSender
implements org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.DisposableBean
WebServiceMessageSender implementation that uses Apache
HttpClient to execute POST requests.
Allows to use a pre-configured HttpClient instance, potentially with authentication, HTTP connection pooling, etc.
Authentication can also be set by injecting a Credentials instance (such as the
UsernamePasswordCredentials).
- Since:
- 4.0.5
- Author:
- Alan Stewart, Barry Pitman, Arjen Poutsma, Greg Turnquist, Lars Uffmann
- See Also:
-
HttpClient
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classHttpClientHttpRequestInterceptorimplementation that removesContent-LengthandTransfer-Encodingheaders from the request. -
Field Summary
Fields inherited from class org.springframework.ws.transport.http.AbstractHttpWebServiceMessageSender
logger -
Constructor Summary
ConstructorsConstructorDescriptionCreate a new instance of theHttpClientMessageSenderwith a defaultHttpClientthat uses a defaultPoolingHttpClientConnectionManager.HttpComponents5MessageSender(org.apache.hc.client5.http.classic.HttpClient httpClient) Create a new instance of theHttpComponents5MessageSenderwith the givenHttpClientinstance. -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateConnection(URI uri) Create a newWebServiceConnectionto the specified URI.protected org.apache.hc.core5.http.protocol.HttpContextcreateContext(URI uri) Template method that allows for creation of anHttpContextfor the given uri.voiddestroy()org.apache.hc.client5.http.classic.HttpClientReturns theHttpClientused by this message sender.voidsetAuthScope(org.apache.hc.client5.http.auth.AuthScope authScope) voidsetConnectionTimeout(Duration timeout) voidsetCredentials(org.apache.hc.client5.http.auth.Credentials credentials) voidsetHttpClient(org.apache.hc.client5.http.classic.HttpClient httpClient) Set theHttpClientused by this message sender.voidsetMaxConnectionsPerHost(Map<String, String> maxConnectionsPerHost) voidsetMaxTotalConnections(int maxTotalConnections) voidsetReadTimeout(Duration timeout) Methods inherited from class org.springframework.ws.transport.http.AbstractHttpWebServiceMessageSender
isAcceptGzipEncoding, setAcceptGzipEncoding, supports
-
Constructor Details
-
HttpComponents5MessageSender
public HttpComponents5MessageSender()Create a new instance of theHttpClientMessageSenderwith a defaultHttpClientthat uses a defaultPoolingHttpClientConnectionManager. -
HttpComponents5MessageSender
public HttpComponents5MessageSender(org.apache.hc.client5.http.classic.HttpClient httpClient) Create a new instance of theHttpComponents5MessageSenderwith the givenHttpClientinstance.This constructor does not change the given
HttpClientin any way. As such, it does not set timeouts, nor does it add theHttpComponents5MessageSender.RemoveSoapHeadersInterceptor.- Parameters:
httpClient- the HttpClient instance to use for this sender
-
-
Method Details
-
setAuthScope
public void setAuthScope(org.apache.hc.client5.http.auth.AuthScope authScope) -
setCredentials
public void setCredentials(org.apache.hc.client5.http.auth.Credentials credentials) -
getHttpClient
public org.apache.hc.client5.http.classic.HttpClient getHttpClient()Returns theHttpClientused by this message sender. -
setHttpClient
public void setHttpClient(org.apache.hc.client5.http.classic.HttpClient httpClient) Set theHttpClientused by this message sender. -
setConnectionTimeout
-
setReadTimeout
-
setMaxTotalConnections
public void setMaxTotalConnections(int maxTotalConnections) -
setMaxConnectionsPerHost
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
createConnection
Description copied from interface:WebServiceMessageSenderCreate a newWebServiceConnectionto the specified URI.- Specified by:
createConnectionin interfaceWebServiceMessageSender- Parameters:
uri- the URI to open a connection to- Returns:
- the new connection
- Throws:
IOException- in case of I/O errors
-
createContext
Template method that allows for creation of anHttpContextfor the given uri. Default implementation returnsnull.- Parameters:
uri- the URI to create the context for- Returns:
- the context, or
null
-
destroy
- Specified by:
destroyin interfaceorg.springframework.beans.factory.DisposableBean- Throws:
Exception
-