Powered by PmWiki
HessianPHP allows consuming and publishing web services using the Hessian binary protocol, originally Developer by Caucho in the Java language.
The goal of HessianPHP is to provide interoperability between PHP and other web platforms. Hessian uses HTTP POST requests to communicate between client and server.
Formal specifications for the Hessian protocol are available here and the user guide for the Java implementation here. and it is also included in the documentation of the excellent Java server Resin, also from Caucho.
Besides the reference implementation, there exist clients for C++, C# and Python. So far, services created with HessianPHP have been successfully tested against Java, C # and Python clients.
Design and development
The design of HessianPHP is heavily based on hessianlib.py, a client Python implementation of Hessian, because of similarities between the two languages.
HessianPHP was designed to be as non-intrusive as possible and to keep dependencies to the minimum by following simple design patterns.
Development took place in a Windows XP/AMD 64 box and I really want to test in Linux and other architectures.
This library was tested using this configurations:
The library's core is a set of two classes: HessianParser and HessianWriter. They are in charge of serialization and deserialization of native PHP types into Hessian types using reflection. They implement the protocol.
The HessianClient class acts a as proxy between the executing script and a remote Hessian service, remote calls are performed by making local calls to the proxy object that implements the PHP magic method __call(), defined in the overload extension. The real calls are performed in a class called HessianProxy, which holds information about the remote endpoint.
In order to establish communication, descendents of the class HttpConnection are used. The default class, SocketHttpConnection opens a socket to the remote server, performs an HTTP POST call to a url with the request embedded in the main body, retrieves the reply and returns the content and headers to be processed.
The HessianService class acts as a wrapper around a common PHP object, making it's public methods available remotely as a web service. HessianService utilizes PHP built-in stream mechanism (php://input, php://output) for both reading and writing to the connection.
There is also an auxiliary class called ByteUtils that handles representation of numbers as sequences of bytes.
The global configuration class is simply called Hessian, which consists in static methods that are used to set different options in the behavior of the library. Note that this class is likely to be deprecated in future versions in favor of a more dynamic configuration.
The new filter mechanism is located in the Filters.php file and it consists in three clases: FilterChain, that implements a chain of responsibility pattern; InterceptingFilter which is the base class for all filters and FilterContainer that is the base class of filter clients. You can also find several example filters in this class