Spring Web Services Framework

org.springframework.ws.transport.http
Class MessageDispatcherServlet

java.lang.Object
  extended by javax.servlet.GenericServlet
      extended by javax.servlet.http.HttpServlet
          extended by org.springframework.web.servlet.HttpServletBean
              extended by org.springframework.web.servlet.FrameworkServlet
                  extended by org.springframework.ws.transport.http.MessageDispatcherServlet
All Implemented Interfaces:
Serializable, Servlet, ServletConfig, Aware, EnvironmentAware, org.springframework.core.env.EnvironmentCapable

public class MessageDispatcherServlet
extends 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:
DispatcherServlet, MessageDispatcher, WebServiceMessageReceiverHandlerAdapter, Serialized Form

Field Summary
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.
 
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
 
Constructor Summary
MessageDispatcherServlet()
          Public constructor, necessary for some Web application servers.
MessageDispatcherServlet(WebApplicationContext webApplicationContext)
          Constructor to support programmatic configuration of the Servlet with the specified web application context.
 
Method Summary
protected  void doService(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
           
protected  long getLastModified(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(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(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(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(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.
 
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, onApplicationEvent, postProcessWebApplicationContext, processRequest, refresh, service, setContextAttribute, setContextClass, setContextConfigLocation, setContextId, setContextInitializerClasses, setContextInitializers, setDispatchOptionsRequest, setDispatchTraceRequest, setNamespace, setPublishContext, setPublishEvents, setThreadContextInheritable
 
Methods inherited from class org.springframework.web.servlet.HttpServletBean
addRequiredProperty, createEnvironment, getEnvironment, getServletContext, getServletName, init, initBeanWrapper, setEnvironment
 
Methods inherited from class javax.servlet.http.HttpServlet
doHead, service
 
Methods inherited from class javax.servlet.GenericServlet
getInitParameter, getInitParameterNames, getServletConfig, getServletInfo, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MESSAGE_FACTORY_BEAN_NAME

public static final String DEFAULT_MESSAGE_FACTORY_BEAN_NAME
Well-known name for the WebServiceMessageFactory bean in the bean factory for this namespace.

See Also:
Constant Field Values

DEFAULT_MESSAGE_RECEIVER_BEAN_NAME

public static final String DEFAULT_MESSAGE_RECEIVER_BEAN_NAME
Well-known name for the WebServiceMessageReceiver object in the bean factory for this namespace.

See Also:
Constant Field Values

DEFAULT_MESSAGE_RECEIVER_HANDLER_ADAPTER_BEAN_NAME

public static final String DEFAULT_MESSAGE_RECEIVER_HANDLER_ADAPTER_BEAN_NAME
Well-known name for the WebServiceMessageReceiverHandlerAdapter object in the bean factory for this namespace.

See Also:
Constant Field Values

DEFAULT_WSDL_DEFINITION_HANDLER_ADAPTER_BEAN_NAME

public static final String DEFAULT_WSDL_DEFINITION_HANDLER_ADAPTER_BEAN_NAME
Well-known name for the WsdlDefinitionHandlerAdapter object in the bean factory for this namespace.

See Also:
Constant Field Values

DEFAULT_XSD_SCHEMA_HANDLER_ADAPTER_BEAN_NAME

public static final String DEFAULT_XSD_SCHEMA_HANDLER_ADAPTER_BEAN_NAME
Well-known name for the XsdSchemaHandlerAdapter object in the bean factory for this namespace.

See Also:
Constant Field Values
Constructor Detail

MessageDispatcherServlet

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


MessageDispatcherServlet

public MessageDispatcherServlet(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:

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 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.FrameworkServlet(WebApplicationContext), WebApplicationInitializer, FrameworkServlet.initWebApplicationContext(), FrameworkServlet.configureAndRefreshWebApplicationContext(org.springframework.web.context.ConfigurableWebApplicationContext)
Method Detail

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)
Sets the bean name used to lookup a WebServiceMessageReceiverHandlerAdapter. Defaults to DEFAULT_MESSAGE_RECEIVER_HANDLER_ADAPTER_BEAN_NAME.


getWsdlDefinitionHandlerAdapterBeanName

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


setWsdlDefinitionHandlerAdapterBeanName

public void setWsdlDefinitionHandlerAdapterBeanName(String wsdlDefinitionHandlerAdapterBeanName)
Sets the bean name used to lookup a WsdlDefinitionHandlerAdapter. Defaults to DEFAULT_WSDL_DEFINITION_HANDLER_ADAPTER_BEAN_NAME.


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(HttpServletRequest httpServletRequest,
                         HttpServletResponse httpServletResponse)
                  throws Exception
Specified by:
doService in class FrameworkServlet
Throws:
Exception

onRefresh

protected void onRefresh(ApplicationContext context)
This implementation calls initStrategies(org.springframework.context.ApplicationContext).

Overrides:
onRefresh in class FrameworkServlet

getLastModified

protected long getLastModified(HttpServletRequest httpServletRequest)
Overrides:
getLastModified in class HttpServlet

getMessageReceiver

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


getWsdlDefinition

protected WsdlDefinition getWsdlDefinition(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(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(ApplicationContext context)
Initialize the strategy objects that this servlet uses.

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


Spring Web Services Framework

Copyright © 2005-2013 The Spring Web Services Framework. All Rights Reserved.