hessian c java_hessian 使用异常处理

版本:spring 3.2 +hessian4.0.37

异常一:hessian 只能使用post调用!

HTTP Status 405 - HessianServiceExporter only supports POST requests

type Status report

message HessianServiceExporter only supports POST requests

description The specified HTTP method is not allowed for the requested resource.

源码:com.caucho.hessian.server.HessianServlet

48bfcb3138846be998f083e40b8d03f1.png

异常二:既然不能使用get那就咋就不用了,使用google postman 选择post 异常又出现了

SEVERE: Servlet.service() for servlet [hessian] in context with path [/lespms] threw exception [Hessian skeleton invocation failed; nested exception is java.io.IOException: Expected 'H'/'C' (Hessian 2.0) or 'c' (Hessian 1.0) in hessian input at -1] with root cause

java.io.IOException: Expected 'H'/'C' (Hessian 2.0) or 'c' (Hessian 1.0) in hessian input at -1

求助度娘 google 都没有找到原因,有知道的大神指导一下小弟

后来看到源码:org.springframework.remoting.caucho.HessianExporter(spring-web 包下)

a4e8e3f477a06d5ba31d5ae6141b4074.png

这段代码应该是判断客户端调用hessian的版本的,看来也不是随便一个post就可以调用,写了一个demo 在程序里面调用,然后就ok 了。

String url = "http://localhost:8080/xxx/hessian/hello";

HessianProxyFactory factory = new HessianProxyFactory();

Hello api = (Hello) factory.create(Hello.class, url);

api.sayHello();

当然 客户端的调用也可以集成到spring。还有一点的就是hessian的安全问题。不知道大家是则么解决的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值