Hessian协议测试远程服务方法

在开发中使用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

posted @ 2019-10-28 20:30  孤城青衫落  阅读(319)  评论(0)    收藏  举报