The Basics

The page deals with the basic task of locating services.

Locating a data service

When accessing a data resource using OGSA-DAI, the first task is to locate a specific data service that has the capabilities or the data content that you require. In our examples, we assume that this has already been done via some registry and that you now have an explicit URL for such a data service. This data service then provides access to the required data resource(s). It does not matter what the data service type is - both OGSA-DAI WSRF and OGSA-DAI WS-I flavours are supported by the same GenericServiceFetcher.

For simplicity we assume that the data service is available at a local URL, e.g. http://localhost:8080/wsrf/services/ogsadai/DataService or http://localhost:8080/axis/services/ogsadai/DataService. We use this URL to contact the DataService object using the GenericServiceFetcher.

String handle = "http://localhost:8080/wsrf/services/ogsadai/DataService";
DataService service = GenericServiceFetcher.getInstance().getDataService(handle, null);

Note that you can connect to both OGSA-DAI WS-I and OGSA-DAI WSRF data services with the above code.

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]);

Locating a data service with a given resource

When the data resource ID is known before connecting to the service you can set it directly when fetching the service:

In this example, we locate a service at http://localhost:8080/axis/services/ogsadai/DataService and a data resource with resource ID MySQLResource.

String handle = "http://localhost:8080/axis/services/ogsadai/DataService";
String id = "MySQLResource";
DataService service = GenericServiceFetcher.getInstance().getDataService(handle, id);

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

See OGSA-DAI/examples/src/uk/org/ogsadai/examples/clienttoolkit/LocatingADataService.java for an example solution.