What is MessageDispatcherServlet in Spring Web Service? Just Remember these 10 points.

1) MessageDispatcherServlet  is a Servlet for simplified dispatching of Web service messages. This servlet automatically detects EndpointAdapters, EndpointMappings, and EndpointExceptionResolvers by type.
2) Servlet for simplified dispatching of Web service messages. This servlet automatically detects EndpointAdapters, EndpointMappings, and EndpointExceptionResolvers by type.
Message Dispatcher Flow in Spring WebService
Message Dispatcher Flow in Spring WebService
3) 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.
4) MessageDispatcherServlet intercepts all the requests from the client, looks for a configuration file in the class-path,   it then finds the appropriate Message/Payload Endpoint and dispatches the messages to it.It uses the EndpointMapping component to locate the right EndPoint.
5) To configure the Servlet use:
  1. <servlet>
  2. <servlet-name>message-dispatcher</servlet-name>
  3. <servlet-class>
  4. org.springframework.ws.transport.http.MessageDispatcherServlet
  5. </servlet-class>
  6. <load-on-startup>1</load-on-startup>
  7. </servlet>
  8. <servlet-mapping>
  9. <servlet-name>message-dispatcher</servlet-name>
  10. <url-pattern>/*</url-pattern>
  11. </servlet-mapping>
6) MessageDispatcherServlet finds the endpoint mapping in the confiuration file and maps the client request to the endpoint.
7) MessageDispatcherServlet uses the EndpointAdapter to connect with the Endpoint.
8) The message dispatcher operates on a message context, and not transport-specific input stream and output stream.
9) Prefer to use WebServiceMessageReceiverHandlerAdapter if your application uses mainly HTTP/S, and use MessageDispatcher if your application acts as a Service Bus.
10) The MessageDispatcherServlet will automatically detect any WsdlDefinition beans defined in it’s Spring container. All such WsdlDefinition beans that are detected will also be exposed via a WsdlDefinitionHandlerAdapter; this is a very convenient way to expose your WSDL to clients simply by just defining some beans.

Comments

Popular posts from this blog

Java Interview : Threads

Spring Framework Interview Notes : Part Two Wiring

Card Dealer In Java in Less than 5 minutes