“ServiceObjects” makes middleware integrations available to use for client applications beside other objects that are presented or incoming, such as “DataObjects”. It has 3 methods that help developer to build necessary configurations and service specific methods on JavaScript side.
1. Getting List of ServiceObjects Avaible on The Middleware
Livo.ServiceObjects.listServiceObjects(successCallback,errorCallback); method gets all available ServiceObjects as json array of json objects if method is successfully returns.
successCallback = function(mwReturn){
var objectList = mwReturn;//whatever, maybe happy dynamic code blocks come here.
};
This method is provided to use in some cases, not necessary actually if the developer knows the object she/he works with. Information about related serviceobject has been documented on its own section.
2. Getting Requested ServiceObject
General structure of a ServiceObject on JavaScript side is like below;
var requestedServiceObj= {
name:"SAPService", // name of the ServiceObject
type:"json", //Type of the service. Also the type can be URLs etc.
operationNames:["getImportStructure","getExportStructure","importAndGetExport"] // Operation names that the service has.
};
var serviceName ="SAPService";
Livo.ServiceObjects.getServiceObject(requestedServiceObj, conf, successCallback, errorCallback);
“serviceName” can be used instead of “requestedServiceObj.” The idea of using json object instead of name comes from identifying service. When service configuration page dug deeper, it will be more clear but for simplicity, there are different types of ServiceObjects and will be more, service names are unique within each type but not between types, it comes handy when the developer gives same name for different types.
Configurations are ServiceObject specific, some of the services does not need any configuration(null configuration).
Simple method creation;
var operations; // Method holder
successCallback = function(mwReturn){
operations = mwReturn;
}
After successCallback invoked, “operations” variable will have service methods created so you can call operations.getImportStructure(); and so on. Created methods has 3 parameters. These 3 parameters are, “payload”(given parameters as json object), “successCallback”, “errorCallback” methods. You can do whatever you want in successCallback methods to handle your situation. “successCallback” returns data or null if the operation is successfull, errorCallback returns fail message that can be network based or payload based.