public class MessageDispatcherServlet
extends org.springframework.web.servlet.FrameworkServlet
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.
DispatcherServlet
,
MessageDispatcher
,
WebServiceMessageReceiverHandlerAdapter
,
Serialized FormModifier and Type | Field and Description |
---|---|
static String |
DEFAULT_MESSAGE_FACTORY_BEAN_NAME
Well-known name for the
WebServiceMessageFactory bean in the bean factory for this namespace. |
static String |
DEFAULT_MESSAGE_RECEIVER_BEAN_NAME
Well-known name for the
WebServiceMessageReceiver object in the bean factory for this namespace. |
static String |
DEFAULT_MESSAGE_RECEIVER_HANDLER_ADAPTER_BEAN_NAME
Well-known name for the
WebServiceMessageReceiverHandlerAdapter object in the bean factory for this
namespace. |
static String |
DEFAULT_WSDL_DEFINITION_HANDLER_ADAPTER_BEAN_NAME
Well-known name for the
WsdlDefinitionHandlerAdapter object in the bean factory for this namespace. |
static String |
DEFAULT_XSD_SCHEMA_HANDLER_ADAPTER_BEAN_NAME
Well-known name for the
XsdSchemaHandlerAdapter object in the bean factory for this namespace. |
Constructor and Description |
---|
MessageDispatcherServlet()
Public 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.
|
Modifier and Type | Method and Description |
---|---|
protected void |
doService(javax.servlet.http.HttpServletRequest httpServletRequest,
javax.servlet.http.HttpServletResponse httpServletResponse) |
protected long |
getLastModified(javax.servlet.http.HttpServletRequest httpServletRequest) |
String |
getMessageFactoryBeanName()
Returns the bean name used to lookup a
WebServiceMessageFactory . |
protected WebServiceMessageReceiver |
getMessageReceiver()
Returns the
WebServiceMessageReceiver used by this servlet. |
String |
getMessageReceiverBeanName()
Returns the bean name used to lookup a
WebServiceMessageReceiver . |
String |
getMessageReceiverHandlerAdapterBeanName()
Returns the bean name used to lookup a
WebServiceMessageReceiverHandlerAdapter . |
protected WsdlDefinition |
getWsdlDefinition(javax.servlet.http.HttpServletRequest request)
Determines the
WsdlDefinition for a given request, or null if none is found. |
String |
getWsdlDefinitionHandlerAdapterBeanName()
Returns the bean name used to lookup a
WsdlDefinitionHandlerAdapter . |
protected XsdSchema |
getXsdSchema(javax.servlet.http.HttpServletRequest request)
Determines the
XsdSchema for a given request, or null if none is found. |
String |
getXsdSchemaHandlerAdapterBeanName()
Returns the bean name used to lookup a
XsdSchemaHandlerAdapter . |
protected void |
initStrategies(org.springframework.context.ApplicationContext context)
Initialize the strategy objects that this servlet uses.
|
boolean |
isTransformSchemaLocations()
Indicates whether relative address locations in the XSD are to be transformed using the request URI of the
incoming
HttpServletRequest . |
boolean |
isTransformWsdlLocations()
Indicates whether relative address locations in the WSDL are to be transformed using the request URI of the
incoming
HttpServletRequest . |
protected void |
onRefresh(org.springframework.context.ApplicationContext context)
This implementation calls
initStrategies(org.springframework.context.ApplicationContext) . |
void |
setMessageFactoryBeanName(String messageFactoryBeanName)
Sets the bean name used to lookup a
WebServiceMessageFactory . |
void |
setMessageReceiverBeanName(String messageReceiverBeanName)
Sets the bean name used to lookup a
WebServiceMessageReceiver . |
void |
setMessageReceiverHandlerAdapterBeanName(String messageReceiverHandlerAdapterBeanName)
Sets the bean name used to lookup a
WebServiceMessageReceiverHandlerAdapter . |
void |
setTransformSchemaLocations(boolean transformSchemaLocations)
Sets whether relative address locations in the XSD are to be transformed using the request URI of the incoming
HttpServletRequest . |
void |
setTransformWsdlLocations(boolean transformWsdlLocations)
Sets whether relative address locations in the WSDL are to be transformed using the request URI of the incoming
HttpServletRequest . |
void |
setWsdlDefinitionHandlerAdapterBeanName(String wsdlDefinitionHandlerAdapterBeanName)
Sets the bean name used to lookup a
WsdlDefinitionHandlerAdapter . |
void |
setXsdSchemaHandlerAdapterBeanName(String xsdSchemaHandlerAdapterBeanName)
Sets the bean name used to lookup a
XsdSchemaHandlerAdapter . |
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, onApplicationEvent, postProcessWebApplicationContext, processRequest, refresh, service, setApplicationContext, setContextAttribute, setContextClass, setContextConfigLocation, setContextId, setContextInitializerClasses, setContextInitializers, setDispatchOptionsRequest, setDispatchTraceRequest, setNamespace, setPublishContext, setPublishEvents, setThreadContextInheritable
addRequiredProperty, createEnvironment, getEnvironment, getServletContext, getServletName, init, initBeanWrapper, setEnvironment
public static final String DEFAULT_MESSAGE_FACTORY_BEAN_NAME
WebServiceMessageFactory
bean in the bean factory for this namespace.public static final String DEFAULT_MESSAGE_RECEIVER_BEAN_NAME
WebServiceMessageReceiver
object in the bean factory for this namespace.public static final String DEFAULT_MESSAGE_RECEIVER_HANDLER_ADAPTER_BEAN_NAME
WebServiceMessageReceiverHandlerAdapter
object in the bean factory for this
namespace.public static final String DEFAULT_WSDL_DEFINITION_HANDLER_ADAPTER_BEAN_NAME
WsdlDefinitionHandlerAdapter
object in the bean factory for this namespace.public static final String DEFAULT_XSD_SCHEMA_HANDLER_ADAPTER_BEAN_NAME
XsdSchemaHandlerAdapter
object in the bean factory for this namespace.public MessageDispatcherServlet()
public MessageDispatcherServlet(org.springframework.web.context.WebApplicationContext webApplicationContext)
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:
ServletContext
and ServletConfig
objects will be delegated to
the application contextFrameworkServlet.postProcessWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext)
will be calledApplicationContextInitializer
s 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
See WebApplicationInitializer
for usage examples.
webApplicationContext
- the context to useFrameworkServlet.FrameworkServlet(WebApplicationContext)
,
WebApplicationInitializer
,
FrameworkServlet.initWebApplicationContext()
,
FrameworkServlet.configureAndRefreshWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext)
public String getMessageFactoryBeanName()
WebServiceMessageFactory
.public void setMessageFactoryBeanName(String messageFactoryBeanName)
WebServiceMessageFactory
. Defaults to DEFAULT_MESSAGE_FACTORY_BEAN_NAME
.public String getMessageReceiverBeanName()
WebServiceMessageReceiver
.public void setMessageReceiverBeanName(String messageReceiverBeanName)
WebServiceMessageReceiver
. Defaults to DEFAULT_MESSAGE_RECEIVER_BEAN_NAME
.public boolean isTransformWsdlLocations()
HttpServletRequest
.public void setTransformWsdlLocations(boolean transformWsdlLocations)
HttpServletRequest
. Defaults to false
.public boolean isTransformSchemaLocations()
HttpServletRequest
.public void setTransformSchemaLocations(boolean transformSchemaLocations)
HttpServletRequest
. Defaults to false
.public String getMessageReceiverHandlerAdapterBeanName()
WebServiceMessageReceiverHandlerAdapter
.public void setMessageReceiverHandlerAdapterBeanName(String messageReceiverHandlerAdapterBeanName)
WebServiceMessageReceiverHandlerAdapter
. Defaults to DEFAULT_MESSAGE_RECEIVER_HANDLER_ADAPTER_BEAN_NAME
.public String getWsdlDefinitionHandlerAdapterBeanName()
WsdlDefinitionHandlerAdapter
.public void setWsdlDefinitionHandlerAdapterBeanName(String wsdlDefinitionHandlerAdapterBeanName)
WsdlDefinitionHandlerAdapter
. Defaults to DEFAULT_WSDL_DEFINITION_HANDLER_ADAPTER_BEAN_NAME
.public String getXsdSchemaHandlerAdapterBeanName()
XsdSchemaHandlerAdapter
.public void setXsdSchemaHandlerAdapterBeanName(String xsdSchemaHandlerAdapterBeanName)
XsdSchemaHandlerAdapter
. Defaults to DEFAULT_XSD_SCHEMA_HANDLER_ADAPTER_BEAN_NAME
.protected void doService(javax.servlet.http.HttpServletRequest httpServletRequest, javax.servlet.http.HttpServletResponse httpServletResponse) throws Exception
doService
in class org.springframework.web.servlet.FrameworkServlet
Exception
protected void onRefresh(org.springframework.context.ApplicationContext context)
initStrategies(org.springframework.context.ApplicationContext)
.onRefresh
in class org.springframework.web.servlet.FrameworkServlet
protected long getLastModified(javax.servlet.http.HttpServletRequest httpServletRequest)
getLastModified
in class javax.servlet.http.HttpServlet
protected WebServiceMessageReceiver getMessageReceiver()
WebServiceMessageReceiver
used by this servlet.protected WsdlDefinition getWsdlDefinition(javax.servlet.http.HttpServletRequest request)
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.
request
- the HttpServletRequest
null
protected XsdSchema getXsdSchema(javax.servlet.http.HttpServletRequest request)
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.
request
- the HttpServletRequest
null
protected void initStrategies(org.springframework.context.ApplicationContext context)
May be overridden in subclasses in order to initialize further strategy objects.
Copyright © 2020 Pivotal Software. All rights reserved.