Page tree
Skip to end of metadata
Go to start of metadata

The Data Hub components expose a set of APIs (Application Programming Interfaces) that can be queried using external tools. These APIs are internally implemented using the Java 2 Platform Enterprise Edition (J2EE) Technologies and are provided as RESTful (Representational State Transfer) web services.

These are accessible through the HTTP protocol, with data exchange taking place in XML format. These services are called by clients implemented in any programming language supporting the corresponding protocols.

Examples on writing clients

This section provides an example on how to write a client for a RESTful service. The corresponding code needs to be adapted with specific calls according to the selected API.

For RESTful services (Capacity-aware Placement Advice API, TimeForecast Model API, Search API, Backend Control API), you need to make HTTP calls using the Data Access Objects (DAO) described in this guide.

The following code shows an example of a Java REST client:

String request = "http://<bco_datahub_server>
HttpClient client = new HttpClient(); // Initializing Http Client
// Initializing POSTMethod
PostMethod method = new PostMethod(request);

("http.useragent", "My REST client");

StringBuilder xmlContent = new StringBuilder();
String readLine;
 try {
   //Open the file for the content of request
   BufferedReader br = new BufferedReader
                       (new FileReader("reqcontent.xml"));
   // read file lines
   while ((readLine = br.readLine()) != null) {
 catch (IOException e) {
	// TODO: handle exception

try {
        // Set request body
	method.setRequestEntity(new StringRequestEntity
        (xmlContent.toString(), "application/xml", null)); 

        // Make request and get status code
	int statusCode =  client.executeMethod(method);
	Example of possible outcome for statusCode:
	statusCode=200 the request has succeeded
	statusCode=400 alerts for a bad input parameter
	statusCode=403 indicates a forbidden error
	statusCode=503 alerts for an internal error in the request

	if (statusCode == HttpStatus.SC_OK){
        BufferedReader br = new BufferedReader(new InputStreamReader
		while(((readLine = br.readLine()) != null)) {
		 System.err.println("The Post method failed due to an error,
                                     HTTP Status " + statusCode);
}catch (Exception e){
	// TODO: handle exception

For further discussion on exposed APIs and how they can be queried using external tools, see: