为了大家学习方便拿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>
本文档介绍了如何将Spring与Hessian集成,特别是在升级Hessian从3.2.0到4.0.7时需要注意的事项。在bean配置中,为避免集合与自定义POJO的数据格式错误,需要在3.2.0版本中设置'hessian2Reply'为false。然而,这个属性在4.0.7版本不再支持,不移除会导致处理集合数据时出错。服务端配置遵循Spring文档,确保正确暴露Hessian服务。
233

被折叠的 条评论
为什么被折叠?



