JSDO Generic Service Interface support for Invoke Task

The JSDO Generic Service Interface supports InvokeTask calls for Business Task method through PASOE Web Handler (OpenEdge 11.6+).

The InvokeTaks is implemented in two interface methods: Catalog and InvokeMethod. It's not required to register additional Web Handlers beyond what's documented here.

A Business Task which should be invokable through the Generic Service Interface needs to implement the Consultingwerk.OERA.IBusinessTaskCatalogInfo interface. This Inerface defined the GetCatalogData method which returns the IBusinessTaskCatalogData instance. The catalog data describes the Business Task methods and their parameters:

  • ProDataset references
  • ProDataset effective parameter mode (Input, Output, InputOutput)
  • JSON Serializable Parameter class name
Sample GetCatalogData method
    /**
     * Purpose: Returns the REST/JSDO catalog data to the caller
     * Notes:
     * @return The IBusinessTaskCatalogData instance describing the methods of the Business Task
     */
    METHOD PUBLIC Consultingwerk.OERA.IBusinessTaskCatalogData GetCatalogData ():

        DEFINE VARIABLE oCatalog AS BusinessTaskCatalogData NO-UNDO .


        // Initialize first Method Descriptor through the catalog data descriptor
        oCatalog = NEW BusinessTaskCatalogData (THIS-OBJECT:GetClass():TypeName,
                                                "SampleBusinessTaskMethod",
                                                DATASET dsCustomer:HANDLE,
                                                DatasetParameterModeEnum:InputOutput,
                                                DATASET dsItem:HANDLE,
                                                DatasetParameterModeEnum:Input,
                                                GET-CLASS (IntegerHolder)) .

        // Add a second method
        oCatalog:Methods:Add ("SampleBusinessTaskMethod2",
                              DATASET dsItem:HANDLE,
                              DatasetParameterModeEnum:Output,
                              GET-CLASS (CharacterHolder)) .

        RETURN oCatalog .

    END METHOD.

In the JavaScript code, the Business Task can be called through an JSDO, initialized for the Business Task Name (instead of the Business Entity Name). The Business Task Methods are callable directly on the JSDO instance (like invokable methods of a Business Entity). The Business Task will not provide the standard CRUD methods for the JSDO. The Catalog for the JSDO does only describe the operations and no schema (including relations). This is due to the fact that a Business Task does is not implemented around a primary ProDataset.

Sample JavaScript caller
    var jsdosession, dataSource;      

    var serviceURI = "http://localhost:8820/web",

        jsdoSettings = {
            serviceURI: serviceURI,
            catalogURIs: serviceURI + "/Catalog/Test.SCL1343.SampleBusinessTask"
        },                
        promise;
          
    // create a new session object
    jsdosession = new progress.data.JSDOSession(jsdoSettings);
    promise = jsdosession.login("", "");        

    promise.done(function(jsdosession, result, info) {

        jsdosession.addCatalog(jsdoSettings.catalogURIs)
        .done(function(jsdosession, result, details){

            dsTasks = new progress.data.JSDO ({ name: "Test.SCL1343.SampleBusinessTask" }); 

            // A call parameter that is compatible to an Consultingwerk.CharacterHolder 
            var oParameter = { plcParameter: { Value: 42 } }

            // Perform the asynchronous call
            // true = asynchronously
            var call = dsTasks.SampleBusinessTaskMethod (oParameter, true).deferred;

            // done handler
            call.done (function (method, jsdo, success, request) {
                console.log ("done");
                console.log ("method", method);
                console.log ("jsdo", jsdo);
                console.log ("success", success);
                console.log ("request", request);

                // Retrieve JavaScript object from ABL serializable parameter 
                var oOutput = request.response.plcParameter;
                console.log ("Output Object Value Property", oOutput.Value); 

                // Access return ProDataset values
                var customer = request.response.plcDataset.dsCustomer.eCustomer[0];
                console.log ("Customer Data:", customer.Name) ;
            }); // call.done
        }); // addCatalog.done
    }); // login promise.done