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
  • Constructor Details

    • HttpComponents5MessageSender

      public HttpComponents5MessageSender()
      Create a new instance of the HttpClientMessageSender with a default HttpClient that uses a default PoolingHttpClientConnectionManager.
    • HttpComponents5MessageSender

      public HttpComponents5MessageSender(org.apache.hc.client5.http.classic.HttpClient httpClient)
      Create a new instance of the HttpComponents5MessageSender with the given HttpClient instance.

      This constructor does not change the given HttpClient in any way. As such, it does not set timeouts, nor does it add the HttpComponents5MessageSender.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 the HttpClient used by this message sender.
    • setHttpClient

      public void setHttpClient(org.apache.hc.client5.http.classic.HttpClient httpClient)
      Set the HttpClient used by this message sender.
    • setConnectionTimeout

      public void setConnectionTimeout(Duration timeout)
    • setReadTimeout

      public void setReadTimeout(Duration timeout)
    • setMaxTotalConnections

      public void setMaxTotalConnections(int maxTotalConnections)
    • setMaxConnectionsPerHost

      public void setMaxConnectionsPerHost(Map<String,String> maxConnectionsPerHost)
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • createConnection

      public WebServiceConnection createConnection(URI uri) throws IOException
      Description copied from interface: WebServiceMessageSender
      Create a new WebServiceConnection to the specified URI.
      Specified by:
      createConnection in interface WebServiceMessageSender
      Parameters:
      uri - the URI to open a connection to
      Returns:
      the new connection
      Throws:
      IOException - in case of I/O errors
    • createContext

      protected org.apache.hc.core5.http.protocol.HttpContext createContext(URI uri)
      Template method that allows for creation of an HttpContext for the given uri. Default implementation returns null.
      Parameters:
      uri - the URI to create the context for
      Returns:
      the context, or null
    • destroy

      public void destroy() throws Exception
      Specified by:
      destroy in interface org.springframework.beans.factory.DisposableBean
      Throws:
      Exception