Book Image


Book Image


Overview of this book

Table of Contents (19 chapters)
Spring Cookbook
About the Author
About the Reviewers

Creating a Hessian service

Hessian is a remote method invocation technology; here, a client executes a method located on a server-the Hessian service. It uses HTTP, so it can go over proxies and firewalls. It also has implementations in multiple languages (PHP, Python, Ruby, and so on). So, for example, the client can use Java and the server can use PHP.

In this recipe, we will add a Hessian service to an existing Spring web application. It will expose the methods of a Java class.

Getting ready

The server will expose the methods of the UserService interface:

public interface UserService {
  public abstract List<User> findAll();
  public abstract void addUser(User user);

The UserService interface is implemented by UserServiceImpl:

public class UserServiceImpl implements UserService {
  private List<User> userList = new LinkedList<User>();

  public UserServiceImpl() {
    User user1 = new User("Merlin", 777);
    User user2 = new User("Arthur",...