Examples

Invoking a Remote Hessian Service

This demonstrates how to invoke the following Java interface

public interface TestService {

   int add(int a, int b);

}
            

which is deployed as a Hessian servlet in a servlet container. The following Erlang code shows how to invoke the service:

-define(Url, "http://localhost:2345/").
-define(Mime, "x-application/hessian").

Call = hessian:encode_call("add", [2,3] ),
{ok, {{Version, ReplyCode, ReasonPhrase}, Headers, Response}} =
      http:request(post, {?Url, [], ?Mime , Call}, [], []),
Result = hessian:decode( Response )
            

The value of the Result variable will be 5.