Class 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
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:
-
DispatcherServlet
MessageDispatcher
WebServiceMessageReceiverHandlerAdapter
- Serialized Form
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
Well-known name for theWebServiceMessageFactory
bean in the bean factory for this namespace.static final String
Well-known name for theWebServiceMessageReceiver
object in the bean factory for this namespace.static final String
Well-known name for theWebServiceMessageReceiverHandlerAdapter
object in the bean factory for this namespace.static final String
Well-known name for theWsdlDefinitionHandlerAdapter
object in the bean factory for this namespace.static final String
Well-known name for theXsdSchemaHandlerAdapter
object in the bean factory for this namespace.Fields inherited from class org.springframework.web.servlet.FrameworkServlet
DEFAULT_CONTEXT_CLASS, DEFAULT_NAMESPACE_SUFFIX, SERVLET_CONTEXT_PREFIX
Fields inherited from class org.springframework.web.servlet.HttpServletBean
logger
Fields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD
-
Constructor Summary
ConstructorDescriptionPublic constructor, necessary for some Web application servers.MessageDispatcherServlet
(org.springframework.web.context.WebApplicationContext webApplicationContext) Constructor to support programmatic configuration of the Servlet with the specified web application context. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
doService
(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse) protected long
getLastModified
(jakarta.servlet.http.HttpServletRequest httpServletRequest) Returns the bean name used to lookup aWebServiceMessageFactory
.protected WebServiceMessageReceiver
Returns theWebServiceMessageReceiver
used by this servlet.Returns the bean name used to lookup aWebServiceMessageReceiver
.Returns the bean name used to lookup aWebServiceMessageReceiverHandlerAdapter
.protected WsdlDefinition
getWsdlDefinition
(jakarta.servlet.http.HttpServletRequest request) Determines theWsdlDefinition
for a given request, ornull
if none is found.Returns the bean name used to lookup aWsdlDefinitionHandlerAdapter
.protected XsdSchema
getXsdSchema
(jakarta.servlet.http.HttpServletRequest request) Determines theXsdSchema
for a given request, ornull
if none is found.Returns the bean name used to lookup aXsdSchemaHandlerAdapter
.protected void
initStrategies
(org.springframework.context.ApplicationContext context) Initialize the strategy objects that this servlet uses.boolean
Indicates whether relative address locations in the XSD are to be transformed using the request URI of the incomingHttpServletRequest
.boolean
Indicates whether relative address locations in the WSDL are to be transformed using the request URI of the incomingHttpServletRequest
.protected void
onRefresh
(org.springframework.context.ApplicationContext context) This implementation callsinitStrategies(org.springframework.context.ApplicationContext)
.void
setMessageFactoryBeanName
(String messageFactoryBeanName) Sets the bean name used to lookup aWebServiceMessageFactory
.void
setMessageReceiverBeanName
(String messageReceiverBeanName) Sets the bean name used to lookup aWebServiceMessageReceiver
.void
setMessageReceiverHandlerAdapterBeanName
(String messageReceiverHandlerAdapterBeanName) Sets the bean name used to lookup aWebServiceMessageReceiverHandlerAdapter
.void
setTransformSchemaLocations
(boolean transformSchemaLocations) Sets whether relative address locations in the XSD are to be transformed using the request URI of the incomingHttpServletRequest
.void
setTransformWsdlLocations
(boolean transformWsdlLocations) Sets whether relative address locations in the WSDL are to be transformed using the request URI of the incomingHttpServletRequest
.void
setWsdlDefinitionHandlerAdapterBeanName
(String wsdlDefinitionHandlerAdapterBeanName) Sets the bean name used to lookup aWsdlDefinitionHandlerAdapter
.void
setXsdSchemaHandlerAdapterBeanName
(String xsdSchemaHandlerAdapterBeanName) Sets the bean name used to lookup aXsdSchemaHandlerAdapter
.Methods inherited from class org.springframework.web.servlet.FrameworkServlet
applyInitializers, buildLocaleContext, buildRequestAttributes, configureAndRefreshWebApplicationContext, createWebApplicationContext, createWebApplicationContext, destroy, doDelete, doGet, doOptions, doPost, doPut, doTrace, findWebApplicationContext, getContextAttribute, getContextClass, getContextConfigLocation, getContextId, getNamespace, getServletContextAttributeName, getUsernameForRequest, getWebApplicationContext, initFrameworkServlet, initServletBean, initWebApplicationContext, isEnableLoggingRequestDetails, onApplicationEvent, postProcessWebApplicationContext, processRequest, refresh, service, setApplicationContext, setContextAttribute, setContextClass, setContextConfigLocation, setContextId, setContextInitializerClasses, setContextInitializers, setDispatchOptionsRequest, setDispatchTraceRequest, setEnableLoggingRequestDetails, setNamespace, setPublishContext, setPublishEvents, setThreadContextInheritable
Methods inherited from class org.springframework.web.servlet.HttpServletBean
addRequiredProperty, createEnvironment, getEnvironment, getServletName, init, initBeanWrapper, setEnvironment
Methods inherited from class jakarta.servlet.http.HttpServlet
doHead, init, service
Methods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, log, log
-
Field Details
-
DEFAULT_MESSAGE_FACTORY_BEAN_NAME
Well-known name for theWebServiceMessageFactory
bean in the bean factory for this namespace.- See Also:
-
DEFAULT_MESSAGE_RECEIVER_BEAN_NAME
Well-known name for theWebServiceMessageReceiver
object in the bean factory for this namespace.- See Also:
-
DEFAULT_MESSAGE_RECEIVER_HANDLER_ADAPTER_BEAN_NAME
Well-known name for theWebServiceMessageReceiverHandlerAdapter
object in the bean factory for this namespace.- See Also:
-
DEFAULT_WSDL_DEFINITION_HANDLER_ADAPTER_BEAN_NAME
Well-known name for theWsdlDefinitionHandlerAdapter
object in the bean factory for this namespace.- See Also:
-
DEFAULT_XSD_SCHEMA_HANDLER_ADAPTER_BEAN_NAME
Well-known name for theXsdSchemaHandlerAdapter
object in the bean factory for this namespace.- See Also:
-
-
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 theServletContext#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
andServletConfig
objects will be delegated to the application contextFrameworkServlet.postProcessWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext)
will be called- Any
ApplicationContextInitializer
s specified through the "contextInitializerClasses" init-param or through theFrameworkServlet.setContextInitializers(org.springframework.context.ApplicationContextInitializer<?>...)
property will be applied. refresh()
will be called if the context implementsConfigurableWebApplicationContext
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
Returns the bean name used to lookup aWebServiceMessageFactory
. -
setMessageFactoryBeanName
Sets the bean name used to lookup aWebServiceMessageFactory
. Defaults toDEFAULT_MESSAGE_FACTORY_BEAN_NAME
. -
getMessageReceiverBeanName
Returns the bean name used to lookup aWebServiceMessageReceiver
. -
setMessageReceiverBeanName
Sets the bean name used to lookup aWebServiceMessageReceiver
. Defaults toDEFAULT_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 incomingHttpServletRequest
. -
setTransformWsdlLocations
public void setTransformWsdlLocations(boolean transformWsdlLocations) Sets whether relative address locations in the WSDL are to be transformed using the request URI of the incomingHttpServletRequest
. Defaults tofalse
. -
isTransformSchemaLocations
public boolean isTransformSchemaLocations()Indicates whether relative address locations in the XSD are to be transformed using the request URI of the incomingHttpServletRequest
. -
setTransformSchemaLocations
public void setTransformSchemaLocations(boolean transformSchemaLocations) Sets whether relative address locations in the XSD are to be transformed using the request URI of the incomingHttpServletRequest
. Defaults tofalse
. -
getMessageReceiverHandlerAdapterBeanName
Returns the bean name used to lookup aWebServiceMessageReceiverHandlerAdapter
. -
setMessageReceiverHandlerAdapterBeanName
Sets the bean name used to lookup aWebServiceMessageReceiverHandlerAdapter
. Defaults toDEFAULT_MESSAGE_RECEIVER_HANDLER_ADAPTER_BEAN_NAME
. -
getWsdlDefinitionHandlerAdapterBeanName
Returns the bean name used to lookup aWsdlDefinitionHandlerAdapter
. -
setWsdlDefinitionHandlerAdapterBeanName
Sets the bean name used to lookup aWsdlDefinitionHandlerAdapter
. Defaults toDEFAULT_WSDL_DEFINITION_HANDLER_ADAPTER_BEAN_NAME
. -
getXsdSchemaHandlerAdapterBeanName
Returns the bean name used to lookup aXsdSchemaHandlerAdapter
. -
setXsdSchemaHandlerAdapterBeanName
Sets the bean name used to lookup aXsdSchemaHandlerAdapter
. Defaults toDEFAULT_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 classorg.springframework.web.servlet.FrameworkServlet
- Throws:
Exception
-
onRefresh
protected void onRefresh(org.springframework.context.ApplicationContext context) This implementation callsinitStrategies(org.springframework.context.ApplicationContext)
.- Overrides:
onRefresh
in classorg.springframework.web.servlet.FrameworkServlet
-
getLastModified
protected long getLastModified(jakarta.servlet.http.HttpServletRequest httpServletRequest) - Overrides:
getLastModified
in classjakarta.servlet.http.HttpServlet
-
getMessageReceiver
Returns theWebServiceMessageReceiver
used by this servlet. -
getWsdlDefinition
Determines theWsdlDefinition
for a given request, ornull
if none is found.Default implementation checks whether the request method is
GET
, whether the request uri ends with".wsdl"
, and if there is aWsdlDefinition
with the same name as the filename in the request uri.- Parameters:
request
- theHttpServletRequest
- Returns:
- a definition, or
null
-
getXsdSchema
Determines theXsdSchema
for a given request, ornull
if none is found.Default implementation checks whether the request method is
GET
, whether the request uri ends with".xsd"
, and if there is aXsdSchema
with the same name as the filename in the request uri.- Parameters:
request
- theHttpServletRequest
- 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.
-