注意: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跨项目调用另一项目方法
关键词: