Writing a Basic Client


Using BasicAPI

The developers at Caucho have provided a simple Hessian Web service written as an EJB at their primary Web site. This BasicAPI Hessian Web service is designed to let new developers access a service when writing a client. You will use the BasicAPI Web service when you build your first client in the next section. The location of the service is www.caucho.com/hessian/test/basic. The URL can be broken down in the following manner (you should use this format when writing your own services):

  • www.caucho.com/hessian. The first part identifies an EJB container on the specified site. If the Hessian Web service is hosted by Resin-EE, then hessian represents the servlet prefix.

  • test. The container specification is followed by the path of the request or the home interface. Because EJB containers can contain any number of beans, all requests must specify the right EJB home.

  • basic. The last part of the URL is the actual object to use.

Once the Hessian protocol has established a connection, you can use methods on the BasicAPI Web service. The current methods available are listed in Table 9.1.

Table 9.1: Hessian Protocol Methods

SIGNATURE

DESCRIPTION

HESSIAN COMMAND

Object echo(Object value)

Returns or echoes the method parameter back to the caller

void fault()

Causes an application fault to occur

String hello()

Returns a String object with the value "Hello, World"

c x01 x00 m x00 x05 hello z

r x01 x00 S x00 x0c Hello, world z

void nullCall()

No operation

c x01 x00 m x00 x08 nullCall z

r x01 x00 N z

int subtract(int, int)

Returns the result of subtracting the second parameter from the first

c x01 x00 m x00 x03 sub

I x00 x00 x00 x07

I x00 x00 x00 x03 z

r x01 x00 I x00 x00 x00 x04 z

The important parts of the table are the signature and description of each service method. Later in the chapter, we'll discuss the command Hessian uses to represent the method call.




Mastering Resin
Mastering Resin
ISBN: 0471431036
EAN: 2147483647
Year: 2002
Pages: 180

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net