The Client Toolkit Tutorial
Introduction
  These pages introduce the OGSA-DAI Client Toolkit, a Java API
  that provides the basic building blocks for OGSA-DAI client
  development. Using these APIs, a developer can construct
  anything from a basic query client to a complex distributed data
  integration client with relative ease. The Client Toolkit
  minimises the specialist knowledge required to interact with OGSA-DAI
  services and provides some protection from future changes to the
  data service interfaces. It also operates transparently with OGSA-DAI
  data services compliant with both WS-I and WSRF.
  The main concept of the Client Toolkit is that of an
  activity. An activity dictates an action that is to be performed by
  a data service resource. OGSA-DAI provides many different types of
  activity to perform operations such as SQL queries, XSL transformations
  and FTP data delivery. The Client Toolkit provides a simple
  mechanism for assembling requests describing multiple activities,
  then submitting the request to data service resources for processing.
  The steps involved in a typical interaction are summarised below:
  - Locate a data service resource
 
  - Construct a number of activities
 
  - Chain them together and assemble an activity request
 
  - Send the activity request to the data service resource for processing
 
  - Interpret the results of the activities
 
The remainder of these pages consists of practical examples with
sample code. Starting with a basic query, the examples become
progressively more complex, ending up with a distributed query data
integration scenario.
Examples for using security on OGSA-DAI WSRF are contained in the section
WSRF (GT4) examples 
at the bottom of this page.
A list of prerequisites 
that should be satisfied before following the examples is below.
Prerequisites
- 
We assume that OGSA-DAI services are running on http://localhost:8080/.
 
- 
MySQL and eXist test databases have been set up with the OGSA-DAI example
data - how to set up these databases is described on these pages.
 
- 
The MySQL database can be accessed via:
- An OGSA-DAI WSRF service located at
http://localhost:8080/wsrf/services/ogsadai/DataService and
resource ID MySQLResource or
 
- An OGSA-DAI WSI service located at
http://localhost:8080/axis/services/ogsadai/DataService with
resource ID MySQLResource.
 
 
- 
The eXist database can be accessed via:
- An OGSA-DAI WSRF service located at
http://localhost:8080/wsrf/services/ogsadai/DataService and
resource ID ExistResource or
 
- An OGSA-DAI WSI service located at
http://localhost:8080/axis/services/ogsadai/DataService with
resource ID ExistResource.
 
 
How to Compile and Run the Examples
We provide an ANT file build-examples.xml 
which allows you to build and run the examples:
- 
Running the following compiles all the classes within OGSA-DAI/examples/src to
OGSA-DAI/build/examples:
$ ant -f build-examples.xml compileExamples
 
- 
Running the following compiles all the classes within OGSA-DAI/examples/src and JARs these into
OGSA-DAI/lib/ogsadai-examples.jar:
$ ant -f build-examples.xml jarExamples
 
- 
Running the following runs an example:
$ ant -f build-examples.xml runClient -Ddai.class=your.Class
So, for example to run the simple example you'd use: 
ant -f build-examples.xml runClient \
  -Ddai.class=uk.org.ogsadai.examples.clienttoolkit.SimpleExample
 
For Advanced Users - the CLASSPATH
If you are an advanced user and like using the CLASSPATH then you need to ensure you have
the following in your CLASSPATH:
- OGSA-DAI/build/examples
 
- Every JAR in OGSA-DAI/lib/
 
- Every JAR in OGSA-DAI/thirdparty/
 
- CLASSPATH
 
- 
If communicating with OGSA-DAI WSRF services (whether using OGSA-DAI
WSRF or OGSA-DAI WSI) you will also need to ensure that the file
client-config.wsdd is in a directory that is in the CLASSPATH:
- In OGSA-DAI WSRF this file is in OGSA-DAI (the root directory of the distribution).
 
- In OGSA-DAI WSI this file is in OGSA-DAI/skeletons.
 
 
Examples
The following pages contain:
- A Simple Example
 
- The Basics
- Locating a data service
 
- Listing data resources and setting the resource ID
 
 
- Performing Queries
- Performing a basic SQL query
 
- Performing a sequence of queries
 
- Performing a parameterised SQL query repeatedly
 
- Performing an XPath Query on a XML database
 
 
- Processing Results
- Obtaining activity output from an SQL Query
 
- Obtaining activity output from an XPath Query
 
 
- Updates and Bulk Load
- Updating an XML Database
 
- Updating a Relational Database
 
- Bulk loading Data into a Table
 
 
- Control Flow
- Request Components
 
- Flow Control
 
- Sequence Control
 
 
- Obtaining Meta Data
- The Version of a Service
 
- Listing Data Resources
 
- Supported Activities and Activity Meta Data
 
- Product Information of a Data Resource
 
- Accessing Data Service and Resource Properties
 
 
- Transforming Data
- XSL Transformations
 
- ZIP and GZIP Compression
 
 
- 
  Using Sessions
  
    - 
      Joining an implicit session
    
 
    - 
      Creating a new session
    
 
    - 
      Joining an existing session
    
 
	- 
    Terminating a session
	
 
  
 
- 
  Asynchronous Requests
  
    - Processing an asynchronous request
 
    - Monitoring the request status
 
    - Polling the request status
 
  
  
 
- 
  Asynchronous Delivery
  
    - Delivering data to and from a URL
 
    - Delivering data to and from a File
 
    - Delivering data to and from a GridFTP location
 
    - Pulling data from a session stream to a client
 
	- Pushing data from a client to a session stream
 
	- Pulling data between data service resources
 
		- Pushing data between data service resources
 
  
 
- Data Integration
 
See the full list of Client
Toolkit Examples.
WSRF (GT4) Platform-Specific Examples
These are examples that are only applicable for the WSRF (GT4) version of OGSA-DAI.