Results 1 to 4 of 4

Thread: How does Spring inject the messageFactory

  1. #1
    Join Date
    Jul 2007
    Location
    Mauritius
    Posts
    127

    Default 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. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,624

    Default

    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.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Jul 2007
    Location
    Mauritius
    Posts
    127

    Default

    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

  4. #4
    Join Date
    Jan 2013
    Posts
    1

    Default

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •