版本: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
异常二:既然不能使用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 包下)
这段代码应该是判断客户端调用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的安全问题。不知道大家是则么解决的。