Spring MVC: RESTful web services + BlazeDS integration possible in the same web application?

I have a Spring MVC web application that provides RESTful web services through a controller class (annotated using @Controller) that has methods mapped to specific request types and signatures via @RequestMapping annotations.

I tried to integrate the BlazeDS service destination into the mix: 1) adding the HttpFlexSession listener to web.xml, 2) adding the flex-message-broker and flex: remoting-destination declarations to my Spring application context configuration file, and 3) adding the general / WEB -INF /flex/services-config.xml.

The above integration steps of BlazeDS seem to have closed my RESTful web services, as it seems that requests are no longer routed to controller methods.

Is it possible to do this, i.e. to have one web application that 1) serves HTTP requests through request matching methods, and also 2) calls remote object method calls (i.e. from the Flex client) through the BlazeDS service? If so, can someone tell me what could be what I'm doing wrong?

Thanks in advance for your help.

+3
source share
1 answer

Yes, it is possible, but it requires a little extra setup.

Essentially, you need to create two separate dispatchers, each of which has a different path.

<context-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<servlet>
    <name>flex</name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet>
    <name>spring-mvc</name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
    <servlet-name>flex</servlet-name>
    <url-pattern>/messagebroker/*</url-pattern>
 </servlet-mapping>
<servlet-mapping>
    <servlet-name>spring-mvc</servlet-name>
    <url-pattern>/app/*</url-pattern>
 </servlet-mapping>

http://yourapp/app/somewhere Spring MVC http://yourapp/messagebroker BlazeDS.

, Spring :

  • ( applicationContext.xml )
  • Spring MVC ( spring-mvc-servlet.xml )
  • Flex ( flex-servlet.xml )

Spring/BlazeDS .

+4

Source: https://habr.com/ru/post/1772145/


All Articles