Class HttpSenderBase

All Implemented Interfaces:
CanUseSharedResource<HttpSession>, HasPhysicalDestination, IConfigurable, IConfigurationAware, INamedObject, IScopeProvider, ISender, ISenderWithParameters, IWithParameters, HasKeystore, HasTruststore, ConfigurableLifecycle, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle
Direct Known Subclasses:

public abstract class HttpSenderBase extends HttpSessionBase implements HasPhysicalDestination, ISenderWithParameters, CanUseSharedResource<HttpSession>
Sender for the HTTP protocol using GET, POST, PUT or DELETE using httpclient 4+

Expected message format:

GET methods expect a message looking like this


POST AND PUT methods expect a message similar as GET, or looking like this

Niels Meijer
Any parameters present are appended to the request (when method is GET as request-parameters, when method POST as body part) except the headersParams list, which are added as HTTP headers, and the urlParam header
  • Field Details


      public static final String MESSAGE_ID_HEADER
      See Also:

      public static final String CORRELATION_ID_HEADER
      See Also:
    • urlParameter

      protected IParameter urlParameter
    • staticUri

      protected URI staticUri
    • requestOrBodyParamsSet

      protected Set<String> requestOrBodyParamsSet
    • headerParamsSet

      protected Set<String> headerParamsSet
    • parametersToSkipWhenEmptySet

      protected Set<String> parametersToSkipWhenEmptySet
    • paramList

      protected ParameterList paramList
  • Constructor Details

    • HttpSenderBase

      public HttpSenderBase()
  • Method Details

    • addParameter

      public void addParameter(IParameter p)
      Specified by:
      addParameter in interface IWithParameters
    • getParameterList

      public ParameterList getParameterList()
      return the Parameters
      Specified by:
      getParameterList in interface IWithParameters
    • configure

      public void configure() throws ConfigurationException
      Description copied from interface: ConfigurableLifecycle
      Configure this component.

      In the case of a container, this will propagate the start signal to all components that apply.

      Specified by:
      configure in interface ConfigurableLifecycle
      Specified by:
      configure in interface IConfigurable
      Specified by:
      configure in interface ISender
      configure in class HttpSessionBase
      ConfigurationException - in case it was not able to configure the component.
    • open

      public void open() throws SenderException
      Description copied from interface: ISender
      This method will be called to start the sender. After this method is called the sendMessage method may be called. Purpose of this method is to reduce creating connections to databases etc. in the sendMessage() method.
      Specified by:
      open in interface ISender
    • getObjectType

      public Class<HttpSession> getObjectType()
      Description copied from interface: CanUseSharedResource
      Used to validate the expected type so now unexpected ClassCastExceptions can occur. May be NULL in which case this check will be skipped and the SharedResource will be returned regardless.
      Specified by:
      getObjectType in interface CanUseSharedResource<HttpSession>
    • start

      public void start()
      Specified by:
      start in interface org.springframework.context.Lifecycle
      start in class HttpSessionBase
    • close

      public void close()
      Description copied from interface: ISender
      Stop/close the sender and deallocate resources.
      Specified by:
      close in interface ISender
    • appendParameters

      protected boolean appendParameters(boolean parametersAppended, StringBuilder path, ParameterValueList parameters) throws SenderException
    • getLogPrefix

      protected String getLogPrefix()
      Returns the true name of the class and not XsltPipe$$EnhancerBySpringCGLIB$$563e6b5d. ClassUtils.nameOf(Object) makes sure the original class will be used.
      className + name of the ISender
    • getMethod

      protected abstract org.apache.http.client.methods.HttpRequestBase getMethod(URI uri, Message message, ParameterValueList parameters, PipeLineSession session) throws SenderException
      Custom implementation to create a HttpRequest object.
      uri - endpoint to send the message to
      message - to be sent
      parameters - ParameterValueList that contains all the senders parameters
      session - PipeLineSession to retrieve or store data from, or NULL when not set
      a HttpRequest object
    • extractResult

      protected abstract Message extractResult(HttpResponseHandler responseHandler, PipeLineSession session) throws SenderException, IOException
      Custom implementation to extract the response and format it to a String result.
      It is important that the response will be read or will be closed.
      responseHandler - HttpResponseHandler that contains the response information
      session - PipeLineSession which may be null
      a string that will be passed to the pipeline
    • validateResponseCode

      protected boolean validateResponseCode(int statusCode)
    • sendMessage

      public SenderResult sendMessage(Message message, PipeLineSession session) throws SenderException, TimeoutException
      Description copied from interface: ISender
      Send a message to some destination (as configured in the Sender object). This method may only be called after the configure() method is called.

      The following table shows the difference between synchronous and a-synchronous senders:

      ISender.isSynchronous() returnstruefalse
      return value of sendMessage() isthe reply-messagethe messageId of the message sent
      the correlationID specified with sendMessage()may be ignoredis sent with the message
      a {link TimeOutException}may be thrown if a timeout occurs waiting for a replyshould not be expected

      Multiple objects may try to call this method at the same time, from different threads. Implementations of this method should therefore be thread-safe, or synchronized.

      Specified by:
      sendMessage in interface ISender
    • getPhysicalDestinationName

      public String getPhysicalDestinationName()
      Specified by:
      getPhysicalDestinationName in interface HasPhysicalDestination
    • setUrl

      public void setUrl(String string)
      URL or base of URL to be used
    • setUrlParam

      public void setUrlParam(String urlParam)
      Parameter that is used to obtain URL; overrides url-attribute.
      Default value
    • setMethodType

      public void setMethodType(HttpSenderBase.HttpMethod method)
      The HTTP Method used to execute the request
      Default value
    • setContentType

      public void setContentType(String string)
      Content-Type (superset of mimetype + charset) of the request, for POST, PUT and PATCH methods
      Default value
      text/html, when postType=RAW
    • setCharSet

      public void setCharSet(String string)
      Charset of the request. Typically only used on PUT and POST requests.
      Default value
    • setCertificate

      @Deprecated(forRemoval=true, since="7.7.0") @ConfigurationWarning("Please use attribute keystore instead") public void setCertificate(String string)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setCertificateType

      @Deprecated(forRemoval=true, since="7.7.0") @ConfigurationWarning("has been replaced with keystoreType") public void setCertificateType(KeystoreType value)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setCertificateAuthAlias

      @Deprecated(forRemoval=true, since="7.7.0") @ConfigurationWarning("Please use attribute keystoreAuthAlias instead") public void setCertificateAuthAlias(String string)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setCertificatePassword

      @Deprecated(forRemoval=true, since="7.7.0") @ConfigurationWarning("Please use attribute keystorePassword instead") public void setCertificatePassword(String string)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • setHeadersParams

      public void setHeadersParams(String headersParams)
      Comma separated list of parameter names which should be set as HTTP headers
    • setParametersToSkipWhenEmpty

      public void setParametersToSkipWhenEmpty(String parametersToSkipWhenEmpty)
      Comma separated list of parameter names that should not be added as request or body parameter, or as HTTP header, if they are empty. Set to '*' for this behaviour for all parameters
    • setXhtml

      public void setXhtml(boolean xHtml)
      If true, the HTML response is transformed to XHTML
      Default value
    • setStyleSheetName

      public void setStyleSheetName(String stylesheetName)
      (Only used when xHtml=true) stylesheet to apply to the HTML response
    • setResultStatusCodeSessionKey

      public void setResultStatusCodeSessionKey(String resultStatusCodeSessionKey)
      If set, the status code of the HTTP response is put in the specified sessionKey and the (error or okay) response message is returned. Setting this property has a side effect. If a 4xx or 5xx result code is returned and if the configuration does not implement the specific forward for the returned HTTP result code, then the success forward is followed instead of the exception forward.
    • getDomain

      public String getDomain()
      Specified by:
      getDomain in interface HasPhysicalDestination
    • setSharedResourceRef

      public void setSharedResourceRef(String sharedResourceRef)
      Specified by:
      setSharedResourceRef in interface CanUseSharedResource<HttpSession>
    • getUrl

      public String getUrl()
    • getUrlParam

      public String getUrlParam()
    • getHttpMethod

      public HttpSenderBase.HttpMethod getHttpMethod()
    • getCharSet

      public String getCharSet()
    • getFullContentType

      public org.apache.http.entity.ContentType getFullContentType()
    • getContentType

      public String getContentType()
    • getHeadersParams

      public String getHeadersParams()
    • isXhtml

      public boolean isXhtml()
    • getStyleSheetName

      public String getStyleSheetName()
    • getResultStatusCodeSessionKey

      public String getResultStatusCodeSessionKey()
    • getParametersToSkipWhenEmpty

      public String getParametersToSkipWhenEmpty()