Class MessageDispatcher

java.lang.Object
org.springframework.ws.server.MessageDispatcher
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware, WebServiceMessageReceiver
Direct Known Subclasses:
SoapMessageDispatcher

public class MessageDispatcher extends Object implements WebServiceMessageReceiver, org.springframework.beans.factory.BeanNameAware, org.springframework.context.ApplicationContextAware
Central dispatcher for use within Spring-WS, dispatching Web service messages to registered endpoints.

This dispatcher is quite similar to Spring MVCs DispatcherServlet. Just like its counterpart, this dispatcher is very flexible. This class is SOAP agnostic; in typical SOAP Web Services, the SoapMessageDispatcher subclass is used.

Since:
1.0.0
Author:
Arjen Poutsma
See Also:
  • Field Details

    • logger

      protected final org.apache.commons.logging.Log logger
      Logger available to subclasses.
    • ENDPOINT_NOT_FOUND_LOG_CATEGORY

      public static final String ENDPOINT_NOT_FOUND_LOG_CATEGORY
      Log category to use when no mapped endpoint is found for a request.
      See Also:
    • endpointNotFoundLogger

      protected static final org.apache.commons.logging.Log endpointNotFoundLogger
      Additional logger to use when no mapped endpoint is found for a request.
    • MESSAGE_TRACING_LOG_CATEGORY

      public static final String MESSAGE_TRACING_LOG_CATEGORY
      Log category to use for message tracing.
      See Also:
    • sentMessageTracingLogger

      protected static final org.apache.commons.logging.Log sentMessageTracingLogger
      Additional logger to use for sent message tracing.
    • receivedMessageTracingLogger

      protected static final org.apache.commons.logging.Log receivedMessageTracingLogger
      Additional logger to use for received message tracing.
  • Constructor Details

    • MessageDispatcher

      public MessageDispatcher()
      Initializes a new instance of the MessageDispatcher.
  • Method Details

    • getEndpointAdapters

      public List<EndpointAdapter> getEndpointAdapters()
      Returns the EndpointAdapters to use by this MessageDispatcher.
    • setEndpointAdapters

      public void setEndpointAdapters(List<EndpointAdapter> endpointAdapters)
      Sets the EndpointAdapters to use by this MessageDispatcher.
    • getEndpointExceptionResolvers

      public List<EndpointExceptionResolver> getEndpointExceptionResolvers()
      Returns the EndpointExceptionResolvers to use by this MessageDispatcher.
    • setEndpointExceptionResolvers

      public void setEndpointExceptionResolvers(List<EndpointExceptionResolver> endpointExceptionResolvers)
      Sets the EndpointExceptionResolvers to use by this MessageDispatcher.
    • getEndpointMappings

      public List<EndpointMapping> getEndpointMappings()
      Returns the EndpointMappings to use by this MessageDispatcher.
    • setEndpointMappings

      public void setEndpointMappings(List<EndpointMapping> endpointMappings)
      Sets the EndpointMappings to use by this MessageDispatcher.
    • setBeanName

      public final void setBeanName(String beanName)
      Specified by:
      setBeanName in interface org.springframework.beans.factory.BeanNameAware
    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
      Throws:
      org.springframework.beans.BeansException
    • receive

      public void receive(MessageContext messageContext) throws Exception
      Description copied from interface: WebServiceMessageReceiver
      Receives the given message context. The given message context can be used to create a response.
      Specified by:
      receive in interface WebServiceMessageReceiver
      Parameters:
      messageContext - the message context to be received
      Throws:
      Exception
    • dispatch

      protected final void dispatch(MessageContext messageContext) throws Exception
      Dispatches the request in the given MessageContext according to the configuration.
      Parameters:
      messageContext - the message context
      Throws:
      NoEndpointFoundException - thrown when an endpoint cannot be resolved for the incoming message
      Exception
    • getEndpoint

      protected EndpointInvocationChain getEndpoint(MessageContext messageContext) throws Exception
      Returns the endpoint for this request. All endpoint mappings are tried, in order.
      Returns:
      the EndpointInvocationChain, or null if no endpoint could be found.
      Throws:
      Exception
    • getEndpointAdapter

      protected EndpointAdapter getEndpointAdapter(Object endpoint)
      Returns the EndpointAdapter for the given endpoint.
      Parameters:
      endpoint - the endpoint to find an adapter for
      Returns:
      the adapter
    • handleRequest

      protected boolean handleRequest(EndpointInvocationChain mappedEndpoint, MessageContext messageContext)
      Callback for pre-processing of given invocation chain and message context. Gets called before invocation of handleRequest on the interceptors.

      Default implementation does nothing, and returns true.

      Parameters:
      mappedEndpoint - the mapped EndpointInvocationChain
      messageContext - the message context
      Returns:
      true if processing should continue; false otherwise
    • processEndpointException

      protected void processEndpointException(MessageContext messageContext, Object endpoint, Exception ex) throws Exception
      Determine an error SOAPMessage response via the registered EndpointExceptionResolvers. Most likely, the response contains a SOAPFault. If no suitable resolver was found, the exception is rethrown.
      Parameters:
      messageContext - current SOAPMessage request
      endpoint - the executed endpoint, or null if none chosen at the time of the exception
      ex - the exception that got thrown during handler execution
      Throws:
      Exception - if no suitable resolver is found