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
Modifier and TypeClassDescriptionstatic class
HttpClientHttpRequestInterceptor
implementation that removesContent-Length
andTransfer-Encoding
headers from the request. -
Field Summary
Fields inherited from class org.springframework.ws.transport.http.AbstractHttpWebServiceMessageSender
logger
-
Constructor Summary
ConstructorDescriptionCreate a new instance of theHttpClientMessageSender
with a defaultHttpClient
that uses a defaultPoolingHttpClientConnectionManager
.HttpComponents5MessageSender
(org.apache.hc.client5.http.classic.HttpClient httpClient) Create a new instance of theHttpComponents5MessageSender
with the givenHttpClient
instance. -
Method Summary
Modifier and TypeMethodDescriptionvoid
createConnection
(URI uri) Create a newWebServiceConnection
to the specified URI.protected org.apache.hc.core5.http.protocol.HttpContext
createContext
(URI uri) Template method that allows for creation of anHttpContext
for the given uri.void
destroy()
org.apache.hc.client5.http.classic.HttpClient
Returns theHttpClient
used by this message sender.void
setAuthScope
(org.apache.hc.client5.http.auth.AuthScope authScope) void
setConnectionTimeout
(Duration timeout) void
setCredentials
(org.apache.hc.client5.http.auth.Credentials credentials) void
setHttpClient
(org.apache.hc.client5.http.classic.HttpClient httpClient) Set theHttpClient
used by this message sender.void
setMaxConnectionsPerHost
(Map<String, String> maxConnectionsPerHost) void
setMaxTotalConnections
(int maxTotalConnections) void
setReadTimeout
(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 theHttpClientMessageSender
with a defaultHttpClient
that uses a defaultPoolingHttpClientConnectionManager
. -
HttpComponents5MessageSender
public HttpComponents5MessageSender(org.apache.hc.client5.http.classic.HttpClient httpClient) Create a new instance of theHttpComponents5MessageSender
with the givenHttpClient
instance.This constructor does not change the given
HttpClient
in 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 theHttpClient
used by this message sender. -
setHttpClient
public void setHttpClient(org.apache.hc.client5.http.classic.HttpClient httpClient) Set theHttpClient
used by this message sender. -
setConnectionTimeout
-
setReadTimeout
-
setMaxTotalConnections
public void setMaxTotalConnections(int maxTotalConnections) -
setMaxConnectionsPerHost
-
afterPropertiesSet
- Specified by:
afterPropertiesSet
in interfaceorg.springframework.beans.factory.InitializingBean
- Throws:
Exception
-
createConnection
Description copied from interface:WebServiceMessageSender
Create a newWebServiceConnection
to the specified URI.- Specified by:
createConnection
in 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 anHttpContext
for the given uri. Default implementation returnsnull
.- Parameters:
uri
- the URI to create the context for- Returns:
- the context, or
null
-
destroy
- Specified by:
destroy
in interfaceorg.springframework.beans.factory.DisposableBean
- Throws:
Exception
-