![]() | ![]() | ![]() |
| ||||||||||||||||||||||||||||||||
![]() | |||||||||||||||||||||||||||||||||||
![]() | ![]() | ||||||||||||||||||||||||||||||||||
![]() |
Find this tutorial in: /usr/local/resin/webapps/resin-doc/protocols/tutorial/hessian-add
Try the Tutorial The addition example creates a Hessian web services with a servlet and uses that web service from a JSP client and a Python client.
Hessian is a lightweight binary RPC protocol. Transferring binary objects like files, images, or mp3s can avoid the protocol overhead that XML-based protocols require. Since it's simple, its performance should be usable for almost all sites. Hessian is designed to be self-describing, eliminating the requirement for external IDLs or WSDL files. Because it is as small as possible and language-independent, non-Java Hessian implementations are can easily develop comprehensive test suites. This tutorial only requires the open source Java implementation of the Hessian client and server. It can be downloaded from http://www.caucho.com/hessian/ for non-Resin clients and servers. Because Resin's EJB implementation uses Hessian as its primary remote procedure call protocol, EJB developers can easily expose services to clients from other languages. Because EJB clients and servers are written without knowledge of the underlying protocol, even if you intend to deploy with another protocol, like RMI/IIOP, you can develop using Resin's Hessian. The Hessian 1.0 spec describes the full Hessian protocol.
A Hessian call is just an HTTP POST to a URL. The arguments are serialized into the Hessian binary format and passed to the server. Most applications will never need to look at the Hessian protocol, but it's simple enough that a basic example can help show what's happening underneath the API.
The call does not need to specify the service name because the service is uniquely specified by the URL. The following Addition example shows how to create a basic server so you can test Hessian.
Using Hessian generally uses three components:
The remote interface is used by the Hessian proxy factory to create a proxy stub implementing the service's interface.
Resin's Hessian provides a simple way of creating a server. Just extend HessianServlet with your remote methods. The Hessian call will just be a POST to that servlet. HessianServlet will introspect the service and expose the methods.
The Java interface describes the remote API. This example has an addition method, .Resin's proxy client implementation uses the remote interface to expose the API to the proxy stub. Strictly speaking, though, the Java remote interface is not required for Hessian. A non-Java client will not use the Java interface, except possibly as documentation.
RPC clients follow the following steps in using a remote object:
The Hessian site has a basic Python library for Hessian.
|