To get started with a repository in the web service, connect to a repository. To do this, use the OpenMetabase operation. Connection authorization can be executed by various methods: entering user login and password, using digital signature.. Depending on the selected authorization method, it may require to set up BI server first. Various settings that can be determined on the BI server side are given in the following subsections:
The OpenMetabase operation results in the moniker that is further used to execute various operations to control a repository and to work with its objects. The list of available operations and their description are given in the PP.SOM Service Operations section. There are also optimized operations that use JSON/SOAP structures and are executed by specifying them in the address bar on accessing BI server.
The introductory work with the web service can be organized via a guest connection that does not require a special connection to repository via the OpenMetabase operation.
Below is the example of HTML page code, opening of the page connects to the repository via BI server located in the URL specified in the svc variable. Description of the repository registered in BI server registry must have the WAREHOUSE identifier. On running the connection code, HTML page text displays the sent request and result of its running: response obtained from BI server or error code if repository connection failed.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Example for web service</title>
<meta http-equiv="X-UA-Compatible" content="IE=8" >
</head>
<body>
<script language="javascript" type="text/javascript">
<!--BI server address-->
var svc = "http://localhost:9090/axis2/services/PP.SOM.Som";
<!--JSON request for opening repository-->
OpenMetabase = { "OpenMetabase": { "tDef": { "id": "WAREHOUSE" }, "tCreds": { "user": { "id": "User" }, "pass": "Password" } } }
<!--Execute request-->
OpenMetabaseResult = PostRequest(svc, OpenMetabase);
<!--Function for sending JSON request-->
function PostRequest(url, request) {
document.writeln("<hr>Request:<p>" + JSON.stringify(request) + "<p>");
<!--Send request-->
var xhr = new XMLHttpRequest();
xhr.open("POST", url, false);
xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8');
xhr.send(JSON.stringify(request));
if (xhr.status == 200) {
document.writeln("Response:<p>" + xhr.responseText + "<p>");
return eval("(" + xhr.responseText + ")");
} else {
document.writeln("Request execution error:<p>" + xhr.responseText + "<p>");
return { "error" : true };
}
}
</script>
</body>
</html>
See also: