Globus Toolkit 4: Programming Java Services

Chapter 6: Writing Your First Stateful Web Service in 5 Simple Steps

Overview

MathService

In this chapter we are going to write and deploy a simple stateful web service that uses WSRF to keep state information. Our first web service is an extremely simple Math Web Service, which we'll refer to as MathService. It will allow users to perform the following operations:

  • Addition

  • Subtraction.

Furthermore, MathService will have the following resource properties (RPs for short):

  • Value (integer)

  • Last operation performed (string).

We will also add a "Get Value" operation to access the Value RP. In Chapter 10 we will see a better way of accessing resource properties, without having to add get/set operations.

MathService's internal logic is very simple. Once a new resource is created, the "value" RP is initialized to zero, and the "last operation" RP is initialized to "NONE". The addition and subtraction operations expect only one integer parameter. This parameter is added/subtracted to the "value" RP, and the "last operation" RP is changed to "ADDITION" or "SUBTRACTION" accordingly. Also, the addition and subtraction operations don't return anything.

Finally, this first example will be limited to having one single resource. In the following chapters we will see how we can write a service that has several resources associated to it, as seen in Section 4.2.

High-tech stuff, huh? Don't worry if this seems a bit lackluster. Since this is going to be our first stateful web service, it's better to start with a small didactic service which we'll gradually improve by adding more complex resource properties,...

UNLIMITED FREE
ACCESS
TO THE WORLD'S BEST IDEAS

SUBMIT
Already a GlobalSpec user? Log in.

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.

Customize Your GlobalSpec Experience

Category: Capacitance Meters
Finish!
Privacy Policy

This is embarrasing...

An error occurred while processing the form. Please try again in a few minutes.