Basically there is a back-end application that is exposing both SOAP as well as RESTful services.
I have decided to use
Spring WS 1.5.8 for SOAP services, and
Spring MVC 3.0 for RESTful services as this is a new feature.
upon reading a bit about Spring WS (I am new to this!) we got to declare a "MessageDispatcherServlet" which is a front controller, in web.xml for Spring WS.
For Spring MVC we should declare a "DispatcherServlet" which is also a front controller, in web.xml.
for both servlets we have different servlet declarations in web.xml.
i.e. for Spring WS I have
<servlet>
<servlet-name>springsoap</servlet-name>
<servlet-class>org.springframework.ws.transport.http.MessageDispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springsoap</servlet-name>
<url-pattern>/soapservices/*</url-pattern>
</servlet-mapping>
for Spring MVC (RESTful) i have
<servlet>
<servlet-name>springmvc</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springmvc</servlet-name>
<url-pattern>/restservices/*</url-pattern>
</servlet-mapping>
Therefore i should use 2 config files ?? one named springmvc-servlet.xml and another springsoap-servlet.xml ?
Can this be done ?
The Security package ( spring-ws-security. jar ) provides a WS-Security implementation that integrates with the core Web service package. It allows you to add principal tokens, sign, and decrypt and encrypt SOAP messages.
Spring Boot is considered a module of the Spring framework for packaging the Spring-based application with sensible defaults. Spring MVC is considered to be the model view controller-based web framework under the Spring framework. For building a Spring-powered framework, default configurations are provided by it.
The MessageDispatcherServlet is a standard Servlet which conveniently extends from the standard Spring Web DispatcherServlet , and wraps a MessageDispatcher . As such, it combines the attributes of these into one: as a MessageDispatcher , it follows the same request handling flow as described in the previous section.
Spring Web Services (Spring-WS) is a product of the Spring community focused on creating document-driven Web services. Spring Web Services aims to facilitate contract-first SOAP service development, allowing for the creation of flexible web services using one of the many ways to manipulate XML payloads.
Yes, this is fine. You put the MVC-related stuff into one, and the WS stuff into another.
If they need to share services, then it's best to declare a shared context using ContextLoaderListener
in web.xml
, which defines a third context which should contain the shared beans (see docs for example of how to set this up).
It's also worth nothing that MessageDispatcherServlet
is just a convenient assembly of a standard DispatcherServlet
plus a few other components. You can just declare those components yourself and use a DispatcherServlet
, but that gets quite fiddly.
You can download an example at https://code.google.com/p/spring-ws-2-0-0-rc2-tutorial/downloads/detail?name=spring-ws.zip&can=2&q=
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With