Class MessageDispatcherServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.springframework.web.servlet.HttpServletBean
org.springframework.web.servlet.FrameworkServlet
org.springframework.ws.transport.http.MessageDispatcherServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware, org.springframework.context.EnvironmentAware, org.springframework.core.env.EnvironmentCapable

public class MessageDispatcherServlet extends org.springframework.web.servlet.FrameworkServlet
Servlet for simplified dispatching of Web service messages.

This servlet is a convenient alternative to the standard Spring-MVC DispatcherServlet with separate WebServiceMessageReceiverHandlerAdapter, MessageDispatcher, and WsdlDefinitionHandlerAdapter instances.

This servlet automatically detects EndpointAdapters, EndpointMappings, and EndpointExceptionResolvers by type.

This servlet also automatically detects any WsdlDefinition defined in its application context. This WSDL is exposed under the bean name: for example, a WsdlDefinition bean named 'echo' will be exposed as echo.wsdl in this servlet's context: http://localhost:8080/spring-ws/echo.wsdl. When the transformWsdlLocations init-param is set to true in this servlet's configuration in web.xml, all location attributes in the WSDL definitions will reflect the URL of the incoming request.

Since:
1.0.0
Author:
Arjen Poutsma
See Also:
  • Field Details

  • Constructor Details

    • MessageDispatcherServlet

      public MessageDispatcherServlet()
      Public constructor, necessary for some Web application servers.
    • MessageDispatcherServlet

      public MessageDispatcherServlet(org.springframework.web.context.WebApplicationContext webApplicationContext)
      Constructor to support programmatic configuration of the Servlet with the specified web application context. This constructor is useful in Servlet 3.0+ environments where instance-based registration of servlets is possible through the ServletContext#addServlet API.

      Using this constructor indicates that the following properties / init-params will be ignored:

      • FrameworkServlet.setContextClass(Class) / 'contextClass'
      • FrameworkServlet.setContextConfigLocation(String) / 'contextConfigLocation'
      • FrameworkServlet.setContextAttribute(String) / 'contextAttribute'
      • FrameworkServlet.setNamespace(String) / 'namespace'

      The given web application context may or may not yet be refreshed. If it has not already been refreshed (the recommended approach), then the following will occur:

      • If the given context does not already have a parent, the root application context will be set as the parent.
      • If the given context has not already been assigned an id, one will be assigned to it
      • ServletContext and ServletConfig objects will be delegated to the application context
      • FrameworkServlet.postProcessWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext) will be called
      • Any ApplicationContextInitializers specified through the "contextInitializerClasses" init-param or through the FrameworkServlet.setContextInitializers(org.springframework.context.ApplicationContextInitializer<?>...) property will be applied.
      • refresh() will be called if the context implements ConfigurableWebApplicationContext
      If the context has already been refreshed, none of the above will occur, under the assumption that the user has performed these actions (or not) per their specific needs.

      See WebApplicationInitializer for usage examples.

      Parameters:
      webApplicationContext - the context to use
      See Also:
      • FrameworkServlet(WebApplicationContext)
      • WebApplicationInitializer
      • FrameworkServlet.initWebApplicationContext()
      • FrameworkServlet.configureAndRefreshWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext)
  • Method Details

    • getMessageFactoryBeanName

      public String getMessageFactoryBeanName()
      Returns the bean name used to lookup a WebServiceMessageFactory.
    • setMessageFactoryBeanName

      public void setMessageFactoryBeanName(String messageFactoryBeanName)
      Sets the bean name used to lookup a WebServiceMessageFactory. Defaults to DEFAULT_MESSAGE_FACTORY_BEAN_NAME.
    • getMessageReceiverBeanName

      public String getMessageReceiverBeanName()
      Returns the bean name used to lookup a WebServiceMessageReceiver.
    • setMessageReceiverBeanName

      public void setMessageReceiverBeanName(String messageReceiverBeanName)
      Sets the bean name used to lookup a WebServiceMessageReceiver. Defaults to DEFAULT_MESSAGE_RECEIVER_BEAN_NAME.
    • isTransformWsdlLocations

      public boolean isTransformWsdlLocations()
      Indicates whether relative address locations in the WSDL are to be transformed using the request URI of the incoming HttpServletRequest.
    • setTransformWsdlLocations

      public void setTransformWsdlLocations(boolean transformWsdlLocations)
      Sets whether relative address locations in the WSDL are to be transformed using the request URI of the incoming HttpServletRequest. Defaults to false.
    • isTransformSchemaLocations

      public boolean isTransformSchemaLocations()
      Indicates whether relative address locations in the XSD are to be transformed using the request URI of the incoming HttpServletRequest.
    • setTransformSchemaLocations

      public void setTransformSchemaLocations(boolean transformSchemaLocations)
      Sets whether relative address locations in the XSD are to be transformed using the request URI of the incoming HttpServletRequest. Defaults to false.
    • getMessageReceiverHandlerAdapterBeanName

      public String getMessageReceiverHandlerAdapterBeanName()
      Returns the bean name used to lookup a WebServiceMessageReceiverHandlerAdapter.
    • setMessageReceiverHandlerAdapterBeanName

      public void setMessageReceiverHandlerAdapterBeanName(String messageReceiverHandlerAdapterBeanName)
    • getWsdlDefinitionHandlerAdapterBeanName

      public String getWsdlDefinitionHandlerAdapterBeanName()
      Returns the bean name used to lookup a WsdlDefinitionHandlerAdapter.
    • setWsdlDefinitionHandlerAdapterBeanName

      public void setWsdlDefinitionHandlerAdapterBeanName(String wsdlDefinitionHandlerAdapterBeanName)
    • getXsdSchemaHandlerAdapterBeanName

      public String getXsdSchemaHandlerAdapterBeanName()
      Returns the bean name used to lookup a XsdSchemaHandlerAdapter.
    • setXsdSchemaHandlerAdapterBeanName

      public void setXsdSchemaHandlerAdapterBeanName(String xsdSchemaHandlerAdapterBeanName)
      Sets the bean name used to lookup a XsdSchemaHandlerAdapter. Defaults to DEFAULT_XSD_SCHEMA_HANDLER_ADAPTER_BEAN_NAME.
    • doService

      protected void doService(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse) throws Exception
      Specified by:
      doService in class org.springframework.web.servlet.FrameworkServlet
      Throws:
      Exception
    • onRefresh

      protected void onRefresh(org.springframework.context.ApplicationContext context)
      Overrides:
      onRefresh in class org.springframework.web.servlet.FrameworkServlet
    • getLastModified

      protected long getLastModified(jakarta.servlet.http.HttpServletRequest httpServletRequest)
      Overrides:
      getLastModified in class jakarta.servlet.http.HttpServlet
    • getMessageReceiver

      protected WebServiceMessageReceiver getMessageReceiver()
      Returns the WebServiceMessageReceiver used by this servlet.
    • getWsdlDefinition

      protected WsdlDefinition getWsdlDefinition(jakarta.servlet.http.HttpServletRequest request)
      Determines the WsdlDefinition for a given request, or null if none is found.

      Default implementation checks whether the request method is GET, whether the request uri ends with ".wsdl", and if there is a WsdlDefinition with the same name as the filename in the request uri.

      Parameters:
      request - the HttpServletRequest
      Returns:
      a definition, or null
    • getXsdSchema

      protected XsdSchema getXsdSchema(jakarta.servlet.http.HttpServletRequest request)
      Determines the XsdSchema for a given request, or null if none is found.

      Default implementation checks whether the request method is GET, whether the request uri ends with ".xsd", and if there is a XsdSchema with the same name as the filename in the request uri.

      Parameters:
      request - the HttpServletRequest
      Returns:
      a schema, or null
    • initStrategies

      protected void initStrategies(org.springframework.context.ApplicationContext context)
      Initialize the strategy objects that this servlet uses.

      May be overridden in subclasses in order to initialize further strategy objects.