The Globus Toolkit 4 Programmer’s
Tutorial
Borja Sotomayor
University of Chicago
Department of Computer Science
The Globus Toolkit 4 Programmer’s Tutorial
by Borja Sotomayor
Copyright © 2004, 2005 Borja Sotomayor
This tutorial is available for use and redistribution under the terms of the Apache Public License (http://www.apache.org/licenses/LICENSE-2.0)
Revision History
Revision 0.2.1 26 Nov 2005 Revised by: Borja Sotomayor
Added placeholder chapters for Information Services, Execution Management, and Data Management, to emphasize that the tutorial will eventually include material on these subjects (also: to emphasize that GT4 is not only about Web services programming). Tutorial includes a PDF version again. Thanks to Andreas Dinges for pointing out another (better) way of generating the PDF from the DocBook sources. Switched from the Globus Toolkit Public License to the Apache Public License. Note that this is not a big change since (a) the previous license (GTPL) was practically identical to the APL, and (b) the toolkit itself (starting with version 4.0.1) is licensed with the APL. A few typos corrected.
Revision 0.2 15 Oct 2005 Revised by: Borja Sotomayor
Added security chapters. The first two security chapters are very similar to the ones found in The GT3 Programmer’s Tutorial (an introduction to fundamental security concepts and an introduction to GSI). The third security chapter explains how to write a basic secure service. More security chapters will be included later on. Updated to GSBT (http://gsbt.sourceforge.net/) 0.2.5 which fixes a bug when using the -d and -s arguments. A lot of typos corrected (10^6 thanks to everyone who’s reported typos and bugs since the last release)
Revision 0.1.1 19 Jun 2005 Revised by: Borja Sotomayor
Updated to GSBT (http://gsbt.sourceforge.net/) 0.2.4 which fixes an important bug in the Python build script. Several typos corrected.
Revision 0.1 13 May 2005 Revised by: Borja Sotomayor
First stable release of the tutorial. The examples have been tested with GT4.0. The tutorial includes a Python build script which can be used by Windows users to run the examples. Please note that this build script has not been thoroughly tested under Windows yet. Feedback from Windows users will be very welcome. Several typos corrected.
Revision 0.0.7.1 21 Apr 2005 Revised by: Borja Sotomayor
Fixed buildfile + script so it won’t fail if it does not find an "etc" directory. A few typos corrected.
Revision 0.0.7 13 Apr 2005 Revised by: Borja Sotomayor
Examples have been tested with GT3.9.5. The tutorial examples now implement the singleton or the factory/instance pattern correctly when necessary (see Changelog entry for version 0.0.6). Split the first chapter into three chapters that gradually build from a very simple singleton resource service, to a multiple resource factory/instance service. New chapters: Resource properties, lifecycle management, and notifications. The tutorial now uses the globus-build-service script (from the Globus Service Build Tools (http://gsbt.sourceforge.net/) project). Several typos corrected.
Revision 0.0.6 08 Feb 2005 Revised by: Borja Sotomayor
The tutorial now includes (in the Additional Examples appendix) two examples (a Singleton and a Factory example) that more accurately reflect how ’real’ WSRF services should be designed. These two examples will eventually replace the example used in the first chapter of the tutorial, which implements the factory pattern poorly. If you’re going to reuse code from the tutorial, make sure you use the Singleton and Factory examples found in the Additional Examples appendix. Many thanks to Frank Siebenlist and Sam Meder for pointing out the flaw in the original example and helping out with the new examples. Several typos corrected.
Revision 0.0.5 29 Dec 2004 Revised by: Borja Sotomayor
First ’readable’ version of the First WSRF Web Service chapter (instead of just a collection of notes). Added "How to...write a WSDL description of your WSRF stateful Web service" appendix (before this version it was simply the same appendix as the GT3 Tutorial) Made some minor modifications to the example (both the service code and the client code). Also added another more complete client which is more effective at demonstrating the statefulness of the service. Minor modifications to the Key Concepts to make terminology a bit more consistent throughout the chapter.
Revision 0.0.4 23 Dec 2004 Revised by: Borja Sotomayor
First ’readable’ version of the Key Concepts chapter (instead of just a collection of notes).
Revision 0.0.3 19 Dec 2004 Revised by: Borja Sotomayor
Examples work with GT3.9.4 Polished source code of example (uses ReflectionResourceProperty to make code a bit clearer -- Thanks to Sam Meder for suggesting this) Included an "Additional examples" appendix (currently only includes one additional example) Polished source code of build script. It is now easier to extend the script so it will accept new parameters (e.g. it now accepts a "--debug" parameter that is passed on to Ant to produce debug information). Added some random notes to the Key Concepts section. However, at this point it is still in the ’bare bones’ stage. Several bug and typo fixes.
Revision 0.0.2 13 Nov 2004 Revised by: Borja Sotomayor
Polished source code of example. Included new (easier to use) build script, based on Scott Gose’s improvements (http://www-unix.mcs.anl.gov/~gose/tutorial/). Added the bare bones of the Key Concepts chapter. At this point, it is little more that some recycled chunks from the GT3 Tutorial with a couple of WSRF notes. Added some appendices.
Revision 0.0.1 06 Nov 2004 Revised by: Borja Sotomayor
Very first version of the GT4 Tutorial.
Table of Contents
Introduction..............................................................................................................................................??
GT4 Prerequisite Documents...........................................................................................................??
Audience ..........................................................................................................................................??
Assumptions.....................................................................................................................................??
Related Documents ..........................................................................................................................??
Document Conventions....................................................................................................................??
Code........................................................................................................................................??
Inlined code ............................................................................................................................??
Shell commands......................................................................................................................??
Notes.......................................................................................................................................??
About the author & acknowledgments.............................................................................................??
Acknowledgments..................................................................................................................??
I. Getting Started .....................................................................................................................................??
1. Key Concepts ...............................................................................................................................??
OGSA, WSRF, and GT4.........................................................................................................??
A short introduction to Web Services.....................................................................................??
A Typical Web Service Invocation................................................................................??
Web Services Architecture............................................................................................??
Web Services Addressing .............................................................................................??
How does this work in practice?...................................................................................??
A Typical Web Service Invocation (redux) .........................................................??
The server side, up close...............................................................................................??
WSRF: The Web Services Resource Framework...................................................................??
WSRF: It’s all about state.............................................................................................??
The resource approach to statefulness ..........................................................................??
The WSRF specification ...............................................................................................??
WS-ResourceProperties ......................................................................................??
WS-ResourceLifetime.........................................................................................??
WS-ServiceGroup ...............................................................................................??
WS-BaseFaults....................................................................................................??
Related specifications....................................................................................................??
WS-Notification ..................................................................................................??
WS-Addressing ...................................................................................................??
The Globus Toolkit 4..............................................................................................................??
Architecture...................................................................................................................??
GT4 Components..........................................................................................................??
Common Runtime ...............................................................................................??
Security................................................................................................................??
Data management................................................................................................??
Information services............................................................................................??
Execution management .......................................................................................??
Where to learn Java & XML ..................................................................................................??
2. Installation....................................................................................................................................??
iii
II. GT4 Java WS Core.............................................................................................................................??
3. Writing Your First Stateful Web Service in 5 Simple Steps ........................................................??
Step 1: Defining the interface in WSDL.................................................................................??
The WSDL code ...........................................................................................................??
WSRF and Globus-specific features of WSDL ............................................................??
Namespace mappings....................................................................................................??
Step 2: Implementing the service in Java ...............................................................................??
The QNames interface ..................................................................................................??
The service implementation..........................................................................................??
Step 3: Configuring the deployment in WSDD (and JNDI)...................................................??
The WSDD deployment descriptor...............................................................................??
The ’service name’ ..............................................................................................??
className............................................................................................................??
The WSDL file ....................................................................................................??
The operation providers.......................................................................................??
Load on startup....................................................................................................??
The common parameters.....................................................................................??
The JNDI deployment file.............................................................................................??
Step 4: Create a GAR file with Ant........................................................................................??
Ant.................................................................................................................................??
The globus-build-service script and buildfile .....................................................??
Creating the MathService GAR....................................................................................??
Step 5: Deploy the service into a Web Services container .....................................................??
A simple client........................................................................................................................??
4. Singleton resources ......................................................................................................................??
Splitting up the implementation .............................................................................................??
The resource, the home, and the service.......................................................................??
The WSDL file..............................................................................................................??
The QNames interface ..................................................................................................??
The resource resource ...................................................................................................??
The service implementation..........................................................................................??
The resource home........................................................................................................??
Build, deploy, and try it out... with the same client................................................................??
5. Multiple resources........................................................................................................................??
The WS-Resource factory pattern ..........................................................................................??
Implementing the WS-Resource factory pattern in GT4........................................................??
The factory service .................................................................................................................??
The instance service ...............................................................................................................??
The resource ...........................................................................................................................??
The resource home .................................................................................................................??
Build and deploy.....................................................................................................................??
The deployment descriptor ...........................................................................................??
The JNDI deployment file.............................................................................................??
Build and deploy...........................................................................................................??
A simple client........................................................................................................................??
A slightly less simple client....................................................................................................??
The creating client.........................................................................................................??
The adding client...........................................................................................................??
iv
6. Resource Properties......................................................................................................................??
A closer look at resource properties.......................................................................................??
Standard interfaces........................................................................................................??
GetResourceProperty ..........................................................................................??
GetMultipleResourceProperties ..........................................................................??
SetResourceProperties.........................................................................................??
QueryResourceProperties....................................................................................??
Accessing resource properties the right way..........................................................................??
The WSDL file..............................................................................................................??
The Java files.................................................................................................................??
The deployment files.....................................................................................................??
Build and deploy...........................................................................................................??
Client code ....................................................................................................................??
Invoking getResourceProperty.....................................................................??
Invoking SetResourceProperties to update.................................................??
Invoking GetMultipleResourceProperties ...............................................??
7. Lifecycle Management.................................................................................................................??
Immediate destruction ............................................................................................................??
Scheduled destruction.............................................................................................................??
The WSDL file..............................................................................................................??
The resource implementation........................................................................................??
Deployment...................................................................................................................??
The client ......................................................................................................................??
8. Notifications.................................................................................................................................??
What are notifications?...........................................................................................................??
WS-Notifications....................................................................................................................??
WS-Topics.....................................................................................................................??
WS-BaseNotification ....................................................................................................??
WS-BrokeredNotification .............................................................................................??
Notifications in GT4...............................................................................................................??
Notifying changes in a resource property...............................................................................??
The WSDL file..............................................................................................................??
The resource implementation........................................................................................??
SimpleResourceProperty .............................................................................??
Publishing our RPs as topics with ResourcePropertyTopic.........................??
The service implementation..........................................................................................??
Deployment Descriptor.................................................................................................??
Compile and deploy......................................................................................................??
Client code ....................................................................................................................??
Listener client......................................................................................................??
Adding client.......................................................................................................??
Compile and run..................................................................................................??
III. GT4 Security......................................................................................................................................??
9. Fundamental Security Concepts...................................................................................................??
What is a secure communication?..........................................................................................??
The Three Pillars of a Secure Communication.............................................................??
Privacy.................................................................................................................??
v