Hessian协议测试远程服务方法

一曲冷凌霜 提交于 2019-12-02 16:41:05

在开发中使用Hessian协议本地junit测试可使用

com.caucho.hessian.client.HessianProxyFactory

中方法实现注册的server接口

在dao中定义方法test

1     @Override
2     public void test1() {
3         System.out.println("测试1");
4     }

在remote.xml中定义接口

1     <bean name="/ysbsLogCommonService" class="org.springframework.remoting.caucho.HessianServiceExporter">
2         <property name="service" ref="ysbsLogCommonBoImpl"/>
3         <property name="serviceInterface" value="heb.ysbs.bo.ILogCommonBo"/>
4     </bean>

在 junit中使用HessianProxyFactory工具类

1     String url="http://localhost:8080/——————/remoting/ysbsLogCommonService";
2     HessianProxyFactory hessianProxyFactory = new HessianProxyFactory();
3     
4     //@Test
5     public void test() throws MalformedURLException {
6         ILogCommonBo  proxy = (ILogCommonBo) hessianProxyFactory.create(ILogCommonBo.class, url);
7         proxy.test1();
8 
9     }

运行,console中打印 结果 测试1

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!