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:
-
DispatcherServletMessageDispatcherWebServiceMessageReceiverHandlerAdapter- Serialized Form
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringWell-known name for theWebServiceMessageFactorybean in the bean factory for this namespace.static final StringWell-known name for theWebServiceMessageReceiverobject in the bean factory for this namespace.static final StringWell-known name for theWebServiceMessageReceiverHandlerAdapterobject in the bean factory for this namespace.static final StringWell-known name for theWsdlDefinitionHandlerAdapterobject in the bean factory for this namespace.static final StringWell-known name for theXsdSchemaHandlerAdapterobject in the bean factory for this namespace.Fields inherited from class org.springframework.web.servlet.FrameworkServlet
DEFAULT_CONTEXT_CLASS, DEFAULT_NAMESPACE_SUFFIX, SERVLET_CONTEXT_PREFIXFields inherited from class org.springframework.web.servlet.HttpServletBean
loggerFields inherited from class jakarta.servlet.http.HttpServlet
LEGACY_DO_HEAD -
Constructor Summary
ConstructorsConstructorDescriptionPublic 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 voiddoService(jakarta.servlet.http.HttpServletRequest httpServletRequest, jakarta.servlet.http.HttpServletResponse httpServletResponse) protected longgetLastModified(jakarta.servlet.http.HttpServletRequest httpServletRequest) Returns the bean name used to lookup aWebServiceMessageFactory.protected WebServiceMessageReceiverReturns theWebServiceMessageReceiverused by this servlet.Returns the bean name used to lookup aWebServiceMessageReceiver.Returns the bean name used to lookup aWebServiceMessageReceiverHandlerAdapter.protected WsdlDefinitiongetWsdlDefinition(jakarta.servlet.http.HttpServletRequest request) Determines theWsdlDefinitionfor a given request, ornullif none is found.Returns the bean name used to lookup aWsdlDefinitionHandlerAdapter.protected XsdSchemagetXsdSchema(jakarta.servlet.http.HttpServletRequest request) Determines theXsdSchemafor a given request, ornullif none is found.Returns the bean name used to lookup aXsdSchemaHandlerAdapter.protected voidinitStrategies(org.springframework.context.ApplicationContext context) Initialize the strategy objects that this servlet uses.booleanIndicates whether relative address locations in the XSD are to be transformed using the request URI of the incomingHttpServletRequest.booleanIndicates whether relative address locations in the WSDL are to be transformed using the request URI of the incomingHttpServletRequest.protected voidonRefresh(org.springframework.context.ApplicationContext context) This implementation callsinitStrategies(org.springframework.context.ApplicationContext).voidsetMessageFactoryBeanName(String messageFactoryBeanName) Sets the bean name used to lookup aWebServiceMessageFactory.voidsetMessageReceiverBeanName(String messageReceiverBeanName) Sets the bean name used to lookup aWebServiceMessageReceiver.voidsetMessageReceiverHandlerAdapterBeanName(String messageReceiverHandlerAdapterBeanName) Sets the bean name used to lookup aWebServiceMessageReceiverHandlerAdapter.voidsetTransformSchemaLocations(boolean transformSchemaLocations) Sets whether relative address locations in the XSD are to be transformed using the request URI of the incomingHttpServletRequest.voidsetTransformWsdlLocations(boolean transformWsdlLocations) Sets whether relative address locations in the WSDL are to be transformed using the request URI of the incomingHttpServletRequest.voidsetWsdlDefinitionHandlerAdapterBeanName(String wsdlDefinitionHandlerAdapterBeanName) Sets the bean name used to lookup aWsdlDefinitionHandlerAdapter.voidsetXsdSchemaHandlerAdapterBeanName(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, setThreadContextInheritableMethods inherited from class org.springframework.web.servlet.HttpServletBean
addRequiredProperty, createEnvironment, getEnvironment, getServletName, init, initBeanWrapper, setEnvironmentMethods inherited from class jakarta.servlet.http.HttpServlet
doHead, init, serviceMethods inherited from class jakarta.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, log, log
-
Field Details
-
DEFAULT_MESSAGE_FACTORY_BEAN_NAME
Well-known name for theWebServiceMessageFactorybean in the bean factory for this namespace.- See Also:
-
DEFAULT_MESSAGE_RECEIVER_BEAN_NAME
Well-known name for theWebServiceMessageReceiverobject in the bean factory for this namespace.- See Also:
-
DEFAULT_MESSAGE_RECEIVER_HANDLER_ADAPTER_BEAN_NAME
Well-known name for theWebServiceMessageReceiverHandlerAdapterobject in the bean factory for this namespace.- See Also:
-
DEFAULT_WSDL_DEFINITION_HANDLER_ADAPTER_BEAN_NAME
Well-known name for theWsdlDefinitionHandlerAdapterobject in the bean factory for this namespace.- See Also:
-
DEFAULT_XSD_SCHEMA_HANDLER_ADAPTER_BEAN_NAME
Well-known name for theXsdSchemaHandlerAdapterobject 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#addServletAPI.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
ServletContextandServletConfigobjects will be delegated to the application contextFrameworkServlet.postProcessWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext)will be called- Any
ApplicationContextInitializers 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
WebApplicationInitializerfor usage examples.- Parameters:
webApplicationContext- the context to use- See Also:
-
FrameworkServlet(WebApplicationContext)WebApplicationInitializerFrameworkServlet.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:
doServicein classorg.springframework.web.servlet.FrameworkServlet- Throws:
Exception
-
onRefresh
protected void onRefresh(org.springframework.context.ApplicationContext context) This implementation callsinitStrategies(org.springframework.context.ApplicationContext).- Overrides:
onRefreshin classorg.springframework.web.servlet.FrameworkServlet
-
getLastModified
protected long getLastModified(jakarta.servlet.http.HttpServletRequest httpServletRequest) - Overrides:
getLastModifiedin classjakarta.servlet.http.HttpServlet
-
getMessageReceiver
Returns theWebServiceMessageReceiverused by this servlet. -
getWsdlDefinition
Determines theWsdlDefinitionfor a given request, ornullif none is found.Default implementation checks whether the request method is
GET, whether the request uri ends with".wsdl", and if there is aWsdlDefinitionwith the same name as the filename in the request uri.- Parameters:
request- theHttpServletRequest- Returns:
- a definition, or
null
-
getXsdSchema
Determines theXsdSchemafor a given request, ornullif none is found.Default implementation checks whether the request method is
GET, whether the request uri ends with".xsd", and if there is aXsdSchemawith 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.
-