Information Services Access Using WS/SOAP

From TeraGrid Wiki

Jump to: navigation, search

Overview

The MDS Index Service publishes the aggregated data that it maintains as a single resource property (commonly referred to as an "index"). This data can be queried using the QueryResourceProperties request (defined in the WS-ResourceProperties specification), which performs an XPath query against the index and returns the results of that query.

Information within MDS can also be accessed via the WS-ResourceProperties GetResourceProperty and GetMultipleResourceProperties requests and via the subscription/notification mechanism described in the WS-BaseNotification specification (links to these specs can be found in the Globus WS Core Developer's Guide). However, all these mechanisms return the entire index; only the QueryResourceProperties request allows the user to specify a query.

Command-line Interface

The wsrf-query command is used to perform queries against an index. For example, this command will return the number of GLUE computing elements in the index:

   wsrf-query -s https://info.teragrid.org:8443/wsrf/services/DefaultIndexService" count(//glue:ComputingElement)"

The wsrf-get-property and wsrf-get-properties commands can be used to get an index in its entirety. For example, either of these commands could be used to get the entire contents of the index server running on the default port on the local host:

    wsrf-get-property -s https://info.teragrid.org:8443/wsrf/services/DefaultIndexService \
        "{http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ServiceGroup-1.2-draft-01.xsd}Entry"

    wsrf-get-properties -s https://info.teragrid.org:8443/wsrf/services/DefaultIndexService \
        "{http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ServiceGroup-1.2-draft-01.xsd}Entry"

The wsn-subscribe command can be used to set up a subscription to an index and receive notifications:

   wsn-subscribe -s https://info.teragrid.org:8443/wsrf/services/DefaultIndexService \
        "{http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ServiceGroup-1.2-draft-01.xsd}Entry"

Java API

To use the Globus java API to talk to the MDS Index Service (or any other web service), you first acquire a service addressing locator for the service instance you want to talk to:

   String URIString = "https://info.teragrid.org:8443/wsrf/services/DefaultIndexService";
    EndpointReferenceType epr = new EndpointReferenceType();
    WSResourcePropertiesServiceAddressingLocator locator =
        new WSResourcePropertiesServiceAddressingLocator();

You can then use that service addressing locator to acquire a port type, which can be used to send requests to the server. For example, to perform a GetResourceProperty request, you would do the following:

   // Create the port type
    GetResourceProperty port = locator.getGetResourcePropertyPort(epr);

    // The argument to GetResourceProperty is the name of the resource property to get
    QName rpName =
        new rpName("http://docs.oasis-open.org/wsrf/2004/06/wsrf-WS-ServiceGroup-1.2-draft-01.xsd", "Entry");

    // Do the actual request
    GetResourcePropertyResponse response = port.getResourceProperty(rpName);

    //print the response
    System.out.println(AnyHelper.toSingleString(response));


To perform a QueryResourceProperties request:

   // Create the port type
    QueryResourceProperties_PortType port =
        locator.getQueryResourcePropertiesPort(endpoint);

    // The argument to QueryResourceProperties is a QueryExpressionType, which is basically
    // the query itself (in this case, an XPath string) and an indication of the dialect
    // in which the query is expressed (in this case, XPath):

    String xpathQuery = "count(//glue:ComputingElement)";
    QueryExpressionType query = new QueryExpressionType();
    query.setDialect(WSRFConstants.XPATH_1_DIALECT);
    query.setValue(xpathQuery);
    QueryResourceProperties_Element request = new QueryResourceProperties_Element();
    request.setQueryExpression(query);

    // now run the query
    QueryResourcePropertiesResponse response = port.queryResourceProperties(request);

    // print the results
    System.out.println(AnyHelper.toSingleString(response));

More information can be found in the GT 4.0 Java WS Core Developer's Guide and javadocs.

Personal tools