Business scenario: there may be communication (method call) between two systems. In this case, httpinvoker can be used to implement a lightweight solution
It is divided into server and client. The client calls the interface provided by the server;
Client configuration:
<bean id="OpenApi4SoaService" class="cn.com.agree.open.mvc.service.impl.openapi.OpenApi4SoaServiceImpl"/> <bean id="httpServiceServer" class="org.springframework.remoting.httpinvoker.HttpInvokerServiceExporter"> <property name="service"> <ref bean="OpenApi4SoaService"/> </property> <property name="serviceInterface" value="cn.com.agree.open.mvc.service.api.openapi.OpenApi4SoaService"/> </bean>
Server configuration:
<description>http invoker Client agent configuration</description> <context:property-placeholder location="classpath:../config/application.properties"/> <bean id="httpService" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"> <property name="serviceUrl"> <value>${soa.httpinvoker.server.url}</value> <!-- <value>http://10.128.81.131:8090/esb-soa/httpService</value> --> </property> <property name="serviceInterface" value="cn.com.agree.soa.web.service.soa.OpenService"></property> </bean> <!-- 2010-10-24 New governance platform synchronization interface --> <bean id="httpServiceNew" class="org.springframework.remoting.httpinvoker.HttpInvokerProxyFactoryBean"> <property name="serviceUrl"> <value>http://192.9.200.237:8090/aweb_soa/httpService</value> </property> <property name="serviceInterface" value="awb.aweb_soa.httpService.service.GovernmentService"></property> </bean>
There can be multiple calls to each other.
web.xml configuration:
<servlet> <servlet-name>httpServiceServer</servlet-name> <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class> <init-param> <param-name>contextConfigLocation</param-name> <param-value>/WEB-INF/config/httpinvoker-server-config.xml</param-value> </init-param> <load-on-startup>2</load-on-startup> </servlet> <servlet-mapping> <servlet-name>httpServiceServer</servlet-name> <url-pattern>/httpServiceServer</url-pattern> </servlet-mapping>
Then, the server provides a jar package to the client, which contains the class of the interface that the client needs to call. Right click export in eclipse and select JAR file.
Above
See https://blog.csdn.net/zstu_cc/article/details/54743920 for implementation principle