Class HttpRequestHandlingMessagingGateway

java.lang.Object
org.springframework.integration.context.IntegrationObjectSupport
org.springframework.integration.endpoint.AbstractEndpoint
org.springframework.integration.gateway.MessagingGatewaySupport
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, org.springframework.integration.context.ComponentSourceAware, org.springframework.integration.context.ExpressionCapable, org.springframework.integration.context.OrderlyShutdownCapable, org.springframework.integration.IntegrationPattern, org.springframework.integration.support.context.NamedComponent, org.springframework.integration.support.management.IntegrationInboundManagement, org.springframework.integration.support.management.IntegrationManagement, org.springframework.integration.support.management.ManageableLifecycle, org.springframework.integration.support.management.ManageableSmartLifecycle, org.springframework.integration.support.management.TrackableComponent, org.springframework.web.HttpRequestHandler

public class HttpRequestHandlingMessagingGateway extends HttpRequestHandlingEndpointSupport implements org.springframework.web.HttpRequestHandler
Inbound Messaging Gateway that handles HTTP Requests. May be configured as a bean in the Application Context and delegated to from a simple HttpRequestHandlerServlet in web.xml where the servlet and bean both have the same name. If the BaseHttpInboundEndpoint.isExpectReply() property is set to true, a response can generated from a reply Message. Otherwise, the gateway will play the role of a unidirectional Channel Adapter with a simple status-based response (e.g. 200 OK).

The default supported request methods are GET and POST, but the list of values can be configured with the RequestMapping.getMethods() property. The payload generated from a GET request (or HEAD or OPTIONS if supported) will be a MultiValueMap containing the parameter values. For a request containing a body (e.g. a POST), the type of the payload is determined by the BaseHttpInboundEndpoint.setRequestPayloadTypeClass(Class) request payload type}.

If the HTTP request is a multipart and a "multipartResolver" bean has been defined in the context, then it will be converted by the MultipartAwareFormHttpMessageConverter as long as the default message converters have not been overwritten (although providing a customized instance of the Multipart-aware converter is also an option).

By default a number of HttpMessageConverters are already configured. The list can be overridden by calling the HttpRequestHandlingEndpointSupport.setMessageConverters(List) method.

Since:
2.0
  • Constructor Details

    • HttpRequestHandlingMessagingGateway

      public HttpRequestHandlingMessagingGateway()
    • HttpRequestHandlingMessagingGateway

      public HttpRequestHandlingMessagingGateway(boolean expectReply)
  • Method Details

    • setConvertExceptions

      public void setConvertExceptions(boolean convertExceptions)
      Flag to determine if conversion and writing out of message handling exceptions should be attempted (default false, in which case they will simply be re-thrown). If the flag is true and no message converter can convert the exception a new exception will be thrown.
      Parameters:
      convertExceptions - the flag to set
    • handleRequest

      public final void handleRequest(jakarta.servlet.http.HttpServletRequest servletRequest, jakarta.servlet.http.HttpServletResponse servletResponse) throws IOException
      Handles the HTTP request by generating a Message and sending it to the request channel. If this gateway's 'expectReply' property is true, it will also generate a response from the reply Message once received. That response will be written by the HttpMessageConverters.
      Specified by:
      handleRequest in interface org.springframework.web.HttpRequestHandler
      Throws:
      IOException