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 ?
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
inweb.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 standardDispatcherServlet
plus a few other components. You can just declare those components yourself and use aDispatcherServlet
, 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=