Java Reference
In-Depth Information
5-6. Exposing and Invoking Services Through HTTP
Problem
RMI and EJB communicate through their own protocol which may not pass through firewalls. Ideally,
you'd like to communicate over HTTP.
Solution
Hessian and Burlap are two simple lightweight remoting technologies developed by Caucho Technology
( http://www.caucho.com/ ). Th ey both communicate using proprietary messages over HTTP and have
their own serialization mechanism, but they are much simpler than web services. The only difference
between them is that Hessian communicates using binary messages while Burlap communicates using
XML messages. The message formats of both Hessian and Burlap are also supported on other platforms
besides Java, such as PHP, Python, C#, and Ruby. This allows your Java applications to communicate
with applications running on the other platforms.
In addition to the preceding two technologies, the Spring framework itself also offers a remoting
technology called HTTP Invoker . It also communicates over HTTP, but uses Java's object serialization
mechanism to serialize objects. Unlike Hessian and Burlap, HTTP Invoker requires both sides of a
service to be running on the Java platform and using the Spring framework. However, it can serialize all
kinds of Java objects, some of which may not be serialized by Hessian/Burlap's proprietary mechanism.
Spring's remoting facilities are consistent in exposing and invoking remote services with these
technologies. On the server side, you can create a service exporter such as HessianServiceExporter ,
BurlapServiceExporter , or HttpInvokerServiceExporter to export a Spring bean as a remote service whose
methods can be invoked remotely. It's just several lines of bean configurations without any programming.
On the client side, you can simply configure a proxy factory bean such as HessianProxyFactoryBean ,
BurlapProxyFactoryBean , or HttpInvokerProxyFactoryBean to create a proxy for a remote service. It allows
you to use the remote service as if it were a local bean. Again, it requires no additional programming at all.
How It Works
Exposing a Hessian Service
To expose a Hessian service with Spring, you have to create a web application using Spring MVC. First,
you create the following directory structure for your web application context.
Note To expose a Hessian or Burlap service, you have to copy hessian-3.2.1.jar (located in the lib/caucho
directory of the Spring installation) to the WEB-INF/lib directory.
 
Search WWH ::




Custom Search