Introduction

The WebSpeed Generic Service for the JSDO implements the Cloud Data Object (CDO) protocol using a WebSpeed service instead of a Data Object service.

Notes:


This service only needs to be deployed once and can be used as a proxy to access data from multiple tables. Dynamic code in the WebHandler can also be used to call methods in a Business Entity so that existing Business Entities or custom ones can be used.

The attached zip file contains the sample source code for the generic service.


Note: The sample source code gives access to all the tables in the database, including schema tables. Also, the program uses dynamic code to execute existing Business Entities if found in the PROPATH. From a security point of view, you may want to validate any input that comes from the web and filter the data (for example what tables to access) that is returned.

Creating a WebSpeed service in OpenEdge 11.6

Steps

  1. Create new OpenEdge project with ABL Web App as the project type. Use “WebApp” as the name of the project.

  2. At the Create an ABL Service page, specify the following values:
    1. Service name: GenericService
    2. WebHandler - Create new: GenericService
    3. Resource URI(s): /GenericService/{AccessType}/{TableName}

  3. At the Select database connections, specify a connection to the sports2000 database.
  4. Switch to the OpenEdge Server Perspective.
  5. Copy the following files from the AppServer folder in the zip file to the AppServer folder in the project:
    1. GenericEntity.cls: This class provides a generic implementation of a Business Entity for the READ operation.
    2. IBusinessEntity.cls: This interface provides a definition for the Read method.
  6. Locate GenericService.cls in the Project Explorer view. The file is located at PASOEContent/WEB-INF/openedge. Alternatively, you can use the Link with Editor option in the Project Explorer view or the Show in Project Explorer option from the context menu to show the location.
  7. Replace GenericService.cls with the version included in the openedge folder in the zip file.

  8. Using the Servers view, access the settings for the oepas1 instance of PASOE and specify the sports2000 database in the launch configuration properties.
  9. Start PASOE by using start from the context menu in the Servers view.
  10. To test, launch a web browser and enter the following URLs:
    1. http://localhost:8810/web/GenericService/catalog/Customer : This URL returns the JSDO catalog for the Customer table.
    2. http://localhost:8810/web/GenericService/data/Customer : This URL returns the data for the Customer table.
    3. You can also enter http://localhost:8810/web/GenericService/data/<table-name> and specify any table in the database.
    4. Open KendoUI.html in the web browser. Kendo UI sample with a Kendo UI Grid that accesses the Customer resource. The Kendo UI Grid shows the records from the Customer table using the Generic Service.


Implementation Notes

  • The GenericService WebHandler reads the AccessType parameter, the TableName parameter and the QUERY_STRING value from the web request then calls the GenericEntity class.
  • The GenericEntity class has sample code to create the JSDO catalog dynamically and to return data for the READ operation.



Example using an existing Business Entities


Steps

  1. Copy Customer.cls and customer.i from the AppServer folder in the zip file to the AppServer folder in the project.
  2. Open KendoUI.html in a web browser. The Kendo UI Grid shows the record from the Customer table by calling the Customer.cls Business Entity dynamically.


Implementation Notes

  • The Customer file implements the sample IBusinessEntity and the Read() method which calls the original read method.
  • The GenericService WebHandler creates an instance of the Business Entity (if found) and then the calls the Read() method.