星空网 > 软件开发 > Java

使用hessian跨项目调用另一项目方法

注意:1.方法参数是对象,需要改对应序列化。

     2.调用接口路径服务器端跟客户端需保持一致。

1.hessian服务器端配置

    remote-servlet.

<?<beans xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">


<bean id="warnInfoService" />
<!-- hessionServiceExporter作用将一个常规 bean 导出成 Hessian 服务。 -->
<bean name="/logPersonHessian"
>
<property name="service">
<ref bean="warnInfoService" />
</property>
<property name="serviceInterface">
<value>com.cmsz.rc.services.WarnInfoService</value>
</property>
</bean>
</beans>

logPersonHessian:客户端配置时需要配置。

warnInfoService:让客户端调用的的接口

serviceInterface:要调用接口对应路径

2.客户端配置

  remote-client.

<?

<beans

xsi:schemaLocation="http://www.springframework.org/schema/beans

http://www.springframework.org/schema/beans/spring-beans-3.0.xsd

http://www.springframework.org/schema/context

http://www.springframework.org/schema/context/spring-context-3.0.xsd">

<!-- 在spring的配置文件中配置hession工厂代理类 -->

<bean id="myServiceClient"

>

<property name="serviceUrl">

<value>http://192.168.215.87:8080/RiskControl_TimingDetection/logPersonHessian

</value>

</property>

<property name="serviceInterface">

<value>com.cmsz.rc.services.WarnInfoService</value>

</property>

</bean>

</beans>

192.168.215.87:服务器端IP地址

8080:服务器端口号

logPersonHessian:服务器bean的名字

 

方法调用:

ApplicationContext context = new ClassPath TimeTaskHandleService iLogPerson = (TimeTaskHandleService) context.getBean("myServiceClient");

iLogPerson.方法();




原标题:使用hessian跨项目调用另一项目方法

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

跨境小贝:https://www.goluckyvip.com/tag/36913.html
跨境小波儿:https://www.goluckyvip.com/tag/36914.html
跨境小超哥:https://www.goluckyvip.com/tag/36915.html
跨境小当家:https://www.goluckyvip.com/tag/36916.html
跨境小队长:https://www.goluckyvip.com/tag/36917.html
跨境小二:https://www.goluckyvip.com/tag/36919.html
活动回顾 | 千亚麦佳携手MoonSees呈现精彩亚马逊运营管理课程:https://www.kjdsnews.com/a/1836386.html
生日景点免费 上海景点生日免费景点:https://www.vstour.cn/a/363173.html
相关文章
我的浏览记录
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流