The Basics

The page deals with basic tasks of locating services.

Locating a data service

When accessing a data resource over the Grid using OGSA-DAI, the first stage is generally to locate a specific data service. In our examples, we will use a known data service URL explicitly. Once located, a data service provides access to underlying data resources.

In our examples, we assume that a data service is available at http://192.167.2.4:8222/wsrf/services/ogsadai/DataService.

Use the above URL to contact a DataService object using the appropriate ServiceFetcher.

DataService service = WSRFServiceFetcher.getInstance().getDataService(handle);

Listing data resources and setting the resource ID

You can retrieve a list of the data resources that are exposed by a particular service.

ResourceID[] resources = service.getResourceIDs();

This returns an array of ResourceID objects representing the data resources that a data service can interact with. It is possible that the list is empty because the data service does not expose any data resources at the moment.

The name of a data resource can be accessed via the ResourceID.getName() method.

for (int i=0; i<resources.length; i++) {
    System.out.println(resources[i].getName());
}

Before you can execute an operation which acts on a specific data resource -- for example perform() or getProperty() operations -- you must tell the data service which resource to use. Any data resource ID from the list can be used as input for setting the data resource that the service will interact with.

service.setResourceID(resources[0]);

The data service is now ready to use. What you can do with a data service will be explored in the following pages.

See examples/tutorials/clienttoolkit/LocatingADataService.java for an example solution.