DCS Web Service
Introduction
The original reason for creating DCS web service was to retrieve data answered in a questionnaire and display them on a Portal element.
Do not use this service, a new data cache exists, more information about the API is available here Data_cache_service.
Features
There are currently 2 functions supported, their return values are tables in JSON's array format.
//get top N data ordered by a column descendingly (DESC) or ascendingly (ASC)
public object GetTopDCSData(int dcsId, string[] columns, int topN, string orderByColumn, string orderType)
//get specific columns' data
public object GetDCSData(int dcsId, string[] columns)
How to use
The simplest way is to use ajax request using jquery.
If the request is not made from an internal page inside Catglobe system, we need to make a dummy login first, then make the call to the web service.
//-------CONFIGURATION--------------------
var dcsId = 4246;//Primary key of the DCS
var columns = "'UserId', 'FirstName', 'DisabledDate', 'DeletedDate', 'Amt', 'Kommune_gammel', 'Region', 'Postnummer', 'Boligtype'";//selected columns
var username = "maimai";//your username to login to Catglobe system
var password = "cg";//your password
var rootUrl = 'http://localhost/supernova';//replace this with your site, ex: http://mycatinet.catglobe.com
//--------------------------------------------------
var webMethod = rootUrl + '/DataModule/DataCache/WebService/DCSWebService.asmx/GetDCSData';
var loginPage = rootUrl + '/Login.aspx?u='+username+'&p='+password;
var parameters = "{'dcsId':" + dcsId + ",'columns':[" + columns + "]}";//JSON format
$.ajax({
type: "POST",
url: loginPage,
success: function(msg)
{
//login successfully, now call the web service
$.ajax({
type: "POST",
url: webMethod,
data: parameters,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function(msg)
{
var dataTable = eval(msg.d);
//Code of using the data table here
},
error: function(e)
{
//error when connecting to the web service
}
});
},
error: function(e)
{
//error when trying to login
}
});
Limitation
There is a limit of data retrieval defined by JavaScriptSerializer.maxJsonLength, which is 4 MB Unicode characters as default. If the data retrieval is higher than this, an error will be returned in the onFailFunction: "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property"
This can be fixed by updating the web config file:
<system.web.extensions>
<scripting>
<webServices>
<jsonSerialization maxJsonLength="500000">
</jsonSerialization>
</webServices>
</scripting>
</system.web.extensions>