Book Image


Book Image


Overview of this book

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

Querying an existing Hessian service

In this recipe, we will configure a Spring web application, so that it will be able to execute a method on an existing Hessian service.

Getting ready

We will query the Hessian service of the previous Creating a Hessian service recipe.

We need the UserService interface, so that our application knows the methods available on the Hessian service:

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

User objects will be exchanged over the network, so we need the User class of the previous recipe as well:

public class User implements Serializable {    
  private String name;
  private int age;
  public User(String name, int age) { = name;
    this.age = age;

  // ... getters and setters

How to do it…

Here are the steps for using a Hessian service:

  1. In the Spring configuration, add a HessianProxyFactoryBean bean named userService. Define the Hessian service URL and the UserService...