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, EventListener, Servlet, ServletConfig, ApplicationListener

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.
 
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.
 
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  void initFrameworkServlet()
           
 boolean isTransformWsdlLocations()
          Indicates whether relative address locations in the WSDL are to be transformed using the request URI of the incoming HttpServletRequest.
 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 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.
 
Methods inherited from class org.springframework.web.servlet.FrameworkServlet
createWebApplicationContext, destroy, doDelete, doGet, doPost, doPut, getContextClass, getContextConfigLocation, getNamespace, getServletContextAttributeName, getUsernameForRequest, getWebApplicationContext, initServletBean, initWebApplicationContext, isPublishContext, isPublishEvents, onApplicationEvent, onRefresh, postProcessWebApplicationContext, processRequest, refresh, setContextClass, setContextConfigLocation, setNamespace, setPublishContext, setPublishEvents
 
Methods inherited from class org.springframework.web.servlet.HttpServletBean
addRequiredProperty, getServletContext, getServletName, init, initBeanWrapper
 
Methods inherited from class javax.servlet.http.HttpServlet
doHead, doOptions, doTrace, service, 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
Constructor Detail

MessageDispatcherServlet

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

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.


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.


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.


doService

protected void doService(HttpServletRequest httpServletRequest,
                         HttpServletResponse httpServletResponse)
                  throws Exception
Specified by:
doService in class FrameworkServlet
Throws:
Exception

initFrameworkServlet

protected void initFrameworkServlet()
                             throws ServletException,
                                    BeansException
Overrides:
initFrameworkServlet in class FrameworkServlet
Throws:
ServletException
BeansException

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

Spring Web Services Framework

Copyright � 2005-2008 The Spring Web Services Framework. All Rights Reserved.