The GPIR web services are made up of GPIRQuery which is used for reading information from GPIR, and GPIRIngester which is used for writing information to it. Both services rely on XML documents that follow the GPIR schemas.
The GPIRQuery web service exposes the following two methods:
The former returns data for a single resource while the later returns data for multiple resources that are in a VO. The query name parameter called strQuery is limited to the types listed below.
These queries above were ?simple? queries returning a specific type of resource or VO data. The queries below are more complex compound queries that can be convenient when writing portals that display a broad range of data on a single page.
Here is a sample query client:
import java.net.*;
import java.util.*;
import java.lang.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
public class QueryClient {
/* The Web service URL, NAME and METHOD */
private final static String WSURL = "http://myhost:8080/gpir/webservices";
private final static String WS_NAME = "GPIRQuery";
private final static String WS_METHOD = "getQueryByVo";
public static void runWS(String strQuery, String strVO) throws Exception {
URL url = new URL(WSURL);
Call call = new Call();
String encodingStyleURI = Constants.NS_URI_SOAP_ENC;
call.setEncodingStyleURI(encodingStyleURI);
call.setTargetObjectURI(WS_NAME);
call.setMethodName(WS_METHOD);
Vector params = new Vector();
params.addElement(new Parameter("strQuery", String.class, strQuery, null));
params.addElement(new Parameter("strVO", String.class, strVO, null));
call.setParams(params);
Response resp = call.invoke(url, "");
if (resp.generatedFault()) {
Fault fault = resp.getFault();
System.out.println("ERROR call failed: ");
System.out.println(" Fault Code = " + fault.getFaultCode());
System.out.println(" Fault String = " + fault.getFaultString());
} else {
Parameter result = resp.getReturnValue();
System.out.println(result.getValue());
}
}
}
The GPIRIngester is in essence a mirror image of the GPIRQuery. A single ingest method accepts as it's one argument an XML document corresponding to one of the follows schemas:
The ingester method distinguishes between ingester types by examining the value of the root element of the XML document. If this value does not correspond to one of the root element values as specified in the schemas it will return an error.
Here is a sample Ingester Client:
import java.net.*;
import java.util.*;
import java.lang.*;
import org.apache.soap.*;
import org.apache.soap.rpc.*;
public class IngesterClient {
// The Web service URL, NAME and METHOD
private final static String WSURL = "http://myhost:8080/gpir/webservices";
private final static String WS_NAME = "GPIRIngester";
private final static String WS_METHOD = "ingest";
public static void runWS(String strXML) throws Exception {
URL url = new URL(WSURL);
//Build SOAP Call
Call call = new Call();
String encodingStyleURI = Constants.NS_URI_SOAP_ENC;
call.setEncodingStyleURI(encodingStyleURI);
call.setTargetObjectURI(WS_NAME);
call.setMethodName(WS_METHOD);
//Build Paramter list for method call
Vector params = new Vector();
params.addElement(new Parameter("strXMLSource", String.class, strXML, null));
call.setParams(params);
//Run method call, retrieve response
Response resp = call.invoke(url, "");
//Report error or result string
if (resp.generatedFault()) {
Fault fault = resp.getFault();
System.out.println("ERROR call failed: ");
System.out.println(" Fault Code = " + fault.getFaultCode());
System.out.println(" Fault String = " + fault.getFaultString());
} else {
Parameter result = resp.getReturnValue();
System.out.println(result.getValue());
}
}
}