Hessian—binary web service protocol

  • 2019 年 10 月 6 日
  • 筆記

在系统工程开发过程中,经常会用到远程接口调用,今天给Hessian,一套轻量级远程调用框架,相比WebService,Hessian更简单、快捷!

含义

The Hessian binary web service protocol makes web services usable without requiring a large framework, and without learning yet another alphabet soup of protocols. Because it is a binary protocol, it is well-suited to sending binary data without any need to extend the protocol with attachments.

上面是官网给的Hessian的定义,基于二进制消息能够扩展到其他非java的语言中。同时是基于Http协议传输的,对于数据包比较大的情况下比较友好,他的参数和返回值都需要实现Serializble接口。

hessian的执行流程

Hessian有着不同语言的版本,今天介绍下Hessian在springmvc中的工作流程。

Hessian通过servlet提供远程服务,需要将匹配某个模式的请求映射到Hessian服务,Spring的DispatcherServlet可以完成该功能,DispatcherServlcet将匹配模式的请求转发到Hessian服务。Hessian的server端提供一个servlet基类,用来处理发送过来的请求,而Hessian这个RPC完全使用动态代理来实现,推荐采用面向接口编程,因此,Hessian服务建议通过接口暴露。