Web Service to Grid Service
The Globus Toolkit 3.0 (GTK3.0) provides a number of tools that can be
used to convert an existing implementation of a Web Service into a Grid
Service. For this purpose only a JAR of all the classes implementing the
Web Service is required. In addition to the implementation code, an
antfile must be created to use the tools provided in GTK3.0.
As an illustration, we shall use calculator.jar
and build.xml. calculator.jar
consists of the following classes:
- Calculator - An interface
that declares the operations provided by the service.
- CalculatorImpl -
Implementation of the Calculator interface.
The conversion of an existing Web Service to a Grid Service can be done
as follows:
Step 1: Generate Grid Service Code
Existing Java code of a Web Service can be exposed as a Grid Service by
compiling and archiving it into a JAR file. This JAR file is run through
the createBottomUpGridService
tool in GTK3.0 to automatically generate the stubs, the service
locators, the deployment descriptor fragment, and an operation provider
that delegates its calls into the existing Java code.
For example, in build.xml
we have the target named createBottomUpGridService
which in turn calls the createBottomUpGridService
tool within build-tools.xml
in GTK3.0. Then the command
[purshah@danube
mytry]$ ant createBottomUpGridService
is used which generates the output shown in build_output1.txt.
Step 2: Create a Grid Service Archive (GAR)
A gar
target is available within build-tools.xml
in GTK3.0 to archive all generated components into an archive file that
serves as the unit of deployment.
For example, in build.xml,
we have a target named bottomUpGar
which in turn calls the gar
tool within GTK3.0. Then the command
[purshah@danube
mytry]$ ant bottomUpGar
is used and the corresponding output is shown in build_output2.txt.
Step 3: Deploy the Service
The deploy target provided in
GTK3.0 (not in the build.xml
that we have written) is used to deploy the GAR that is generated in
the previous step into a Grid Service hosting environment.
In <gtk3.0> the
following command line call must be made: ant
deploy -Dgar.name=<path
to GAR created in previous step>
For example, in order to deploy our Grid Service, the following command
is used
[purshah@danube
test_install_dir]$ ant deploy
-Dgar.name=/home/purshah/test_install_dir/mytry/calculator/CalculatorService.gar
and the corresponding output is shown in build_output3.txt.
Step 4: Check the new Grid Service
In order to check the new Grid Service, start the container using ant
startContainer in <gtk3.0>.
It should list the Grid Service that was deployed in the previous step.
Step 5: Creating a Client
In order to create a client for this Grid Service, steps to be followed
are similar to the steps taken to create a client for the sample Grid
Services in GTK3.0. These steps are described here.
For example, a CalcAdder client for the Calculator Service
is created. The use of this client is shown below:
[purshah@danube
client]$ java org.globus.ogsa.client.CreateService
http://localhost:8080/ogsa/services/services/DefaultNamespace/CalculatorImplProviderFactoryService
calc1
Termination
Time: infinity
Created service
with reference:
<definitions
name="CalculatorImpl" targetNamespace="http://DefaultNamespace/service"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:calculatorimplbinding="http://DefaultNamespace/bindings"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"><import
location="http://156.56.104.61:8080/schema/services/CalculatorImpl_bindings.wsdl"
namespace="http://DefaultNamespace/bindings"/><service
name="CalculatorImplService"
xmlns:gsdl="http://ogsa.globus.org/"><gsdl:instanceOf
handle="http://156.56.104.61:8080/ogsa/services/services/DefaultNamespace/CalculatorImplProviderFactoryService/calc1"
xmlns=""/><gsdl:instanceOf
handle="http://156.56.104.61:8080/ogsa/services/instance"
xmlns=""/><port
binding="calculatorimplbinding:CalculatorImplSOAPBinding"
name="CalculatorImplPort"><soap:address
location="http://156.56.104.61:8080/ogsa/services/services/DefaultNamespace/CalculatorImplProviderFactoryService/calc1"/></port></service></definitions>
[purshah@danube
calculator]$ java client.CalcAdder
http://localhost:8080/ogsa/services/services/DefaultNamespace/CalculatorImplProviderFactoryService/calc1
1 2
Sum:3
[purshah@danube
calculator]$ java client.CalcAdder
http://localhost:8080/ogsa/services/services/DefaultNamespace/CalculatorImplProviderFactoryService/calc1
1 4
Sum:5
For additional details on the use of tools within Globus Toolkit 3.0 to
create Grid Services please refer this guide.