Announcement Announcement Module
Collapse
No announcement yet.
How does Spring inject the messageFactory Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How does Spring inject the messageFactory

    Hi guys,
    as part of another thread I raised, and because I have difficulty to create the message factory. I wanted to check how Spring is injecting the messageFactory.

    So my endpoint is as shown below

    Code:
    @PayloadRoot(namespace = NAMESPACE_URI, localPart = "findByCusIdRequest")
    	@ResponsePayload
    	@Transactional(readOnly=true)
    	public SearchCustomerResponse method1(@RequestPayload Element customerSearchOptions) 
    		throws JDOMException, JAXBException
    In my context file, I have not defined any message factory and only my beans are defined. Along with the following Spring ws elements

    Code:
       <sws:annotation-driven/>
    
        
        <sws:dynamic-wsdl id="cusSearchServiceInterface"  
        	portTypeName="CusSearchServicePort"                                                         
        	locationUri="http://server/context/customerSearchService/"                                                       
       		 targetNamespace="http://etc/definitions">      
       		                          
      		<sws:xsd location="/WEB-INF/cus-request.xsd"/>                                                  
    	</sws:dynamic-wsdl>

    So I followed the code and reached to MessageDispatcherServlet and saw that the message factory is being set as shown below, and there is a defaultStrategiesHelper being used.


    Code:
      private void initWebServiceMessageFactory(ApplicationContext context) {
            WebServiceMessageFactory messageFactory;
            try {
                messageFactory = context.getBean(getMessageFactoryBeanName(), WebServiceMessageFactory.class);
            }
            catch (NoSuchBeanDefinitionException ignored) {
                messageFactory = defaultStrategiesHelper
                        .getDefaultStrategy(WebServiceMessageFactory.class, context);
                if (logger.isDebugEnabled()) {
                    logger.debug("No WebServiceMessageFactory found in servlet '" + getServletName() + "': using default");
                }
            }
            messageReceiverHandlerAdapter.setMessageFactory(messageFactory);
        }

    Upon reaching the DefaultStrategiesHelper, things are not that clear and I wondering if somebody could shed some light.

    When and how are the properties of the DefaultStrategiesHelper set. And from there how are the various message factories chosen.

    Thanks
    Kris

  • #2
    They aren't set... They are read when the MessageDispatcherServlet is constructed (check the constructor). It will load a file called MessageDispatcherServlet.properties which contains the default settings.

    Comment


    • #3
      Thanks Maarten,

      it makes more sense now

      Code:
      # Default implementation classes for MessageDispatcherServlet's strategy interfaces.
      # Used as fallback when no matching beans are found in the DispatcherServlet context.
      # Not meant to be customized by application developers.
      
      org.springframework.ws.transport.WebServiceMessageReceiver=org.springframework.ws.soap.server.SoapMessageDispatcher
      
      org.springframework.ws.WebServiceMessageFactory=org.springframework.ws.soap.saaj.SaajSoapMessageFactory

      I would still appreciate some help/advice if you have some time for the unit testing issue that I have documented at this thread.


      Regards
      Kris

      Comment


      • #4
        Thanks, it was really helpful
        Last edited by adeloun3; Jan 5th, 2013, 02:40 AM.

        Comment

        Working...
        X