Uploaded image for project: 'Spring Web Services'
  1. Spring Web Services
  2. SWS-124

Allow specifying names of message factory and message receiver in MessageDispatcherServlet


    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.0 M3
    • Fix Version/s: 1.0 RC2
    • Component/s: Core
    • Labels:


      Currently, MessageDispatcherServlet only uses standard bean names for message factory and message receiver.

      This is problematic since there is may be name collisions. Another problem is that if I want to use the same application context with two servlerts mapped on different URIs, there is no way I can tell them which message receivers they have to use.

      Both problems can be solved with separate application context per servlet, but this rather complicated.

      Why not allow these bean names to be configured, with pre-configured names set by default?

      I mean, we could add:

          private String messageReceiverBeanName = MESSAGE_RECEIVER_BEAN_NAME;
          public String getMessageReceiverBeanName() {
      		return messageReceiverBeanName;
          public void setMessageReceiverBeanName(String messageReceiverBeanName) {
      		this.messageReceiverBeanName = messageReceiverBeanName;

      And then:

          private void initMessageReceiver() {
              try {
                  messageReceiver = (WebServiceMessageReceiver) getWebApplicationContext()
                          .getBean(getMessageReceiverBeanName(), WebServiceMessageReceiver.class);
              catch (NoSuchBeanDefinitionException ex) {
                  messageReceiver = (WebServiceMessageReceiver) defaultStrategiesHelper
                          .getDefaultStrategy(WebServiceMessageReceiver.class, getWebApplicationContext());
                  if (messageReceiver instanceof BeanNameAware) {
                      ((BeanNameAware) messageReceiver).setBeanName(getServletName());
                  if (logger.isInfoEnabled()) {
                      logger.info("Unable to locate MessageDispatcher with name '" + getMessageReceiverBeanName() +
                              "': using default [" + messageReceiver + "]");

      The name will be MESSAGE_RECEIVER_BEAN_NAME (as usual) by default. But in case the someone need to access the bean with another name, it can be done as simple as:


      I will also attach the modified class I use in my project.
      Had to copy-paste instead of subclassing since all the init* methods are private, not protected...


        lexicore Aleksei Valikov added a comment -

        The modified servlet class.

        lexicore Aleksei Valikov added a comment - The modified servlet class.


          • Assignee:
            arjen.poutsma Arjen Poutsma
            lexicore Aleksei Valikov
          • Votes:
            0 Vote for this issue
            0 Start watching this issue


            • Created: