hessian与spring集成,hessian3.2.0升级4.0.7注意事项

来源:互联网 发布:s5支持电信4g网络吗 编辑:程序博客网 时间:2024/05/29 14:29

 

    为了大家学习方便拿spring提到的例子进一步完善来说明

   

    这个bean调用服务端,接收返回的数据,我这里只简单用来测试一下。

    <beanid="simpleObject"class="com.rahwind.jjw.hessianservice.SimpleObject">

       <propertyname="accountService"ref="accountService"/>

    </bean>

    <!—通过接口调用服务端实现-->

    <beanid="accountService"

       class="org.springframework.remoting.caucho.HessianProxyFactoryBean">

       <propertyname="serviceUrl"

           value="http://localhost:8080/springHessianServer/remoting/AccountService"/>

       <propertyname="serviceInterface"value="example.AccountService"/>

    </bean>

 

注意hessian3.2接收集合与自定义pojo时可能会出错数据格式错误

解决方法在accountService中添加属性

<propertyname="hessian2Reply" value="false" />

另外,升级到4.0.7时不支持这个属性,如何不去掉会返回集合数据时会出错。

 

 

服务端按spring文档配置即可

    <beanid="accountService"class="example.AccountServiceImpl">

       <!-- any additionalproperties, maybe a DAO? -->

    </bean>

    <beanname="/AccountService"

       class="org.springframework.remoting.caucho.HessianServiceExporter">

       <propertyname="service"ref="accountService"/>

       <propertyname="serviceInterface"value="example.AccountService"/>

    </bean>