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
- 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) Set the timeout until a connection is established.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) Sets the maximum number of connections per host for the underlying HttpClient.voidsetMaxTotalConnections(int maxTotalConnections) Sets the maximum number of connections allowed for the underlying HttpClient.voidsetReadTimeout(Duration timeout) Set the socket read timeout for the underlying HttpClient.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.This effectively disable any customization and 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 to use
-
setConnectionTimeout
Set the timeout until a connection is established. -
setReadTimeout
Set the socket read timeout for the underlying HttpClient. -
setMaxTotalConnections
public void setMaxTotalConnections(int maxTotalConnections) Sets the maximum number of connections allowed for the underlying HttpClient. -
setMaxConnectionsPerHost
Sets the maximum number of connections per host for the underlying HttpClient. -
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
-