Server Reference Guide > Server Reference Guide > JSON-RPC 2.0 Interface > Creating a Sample OpenROAD Server Application with JSON-RPC Support
Was this helpful?
Creating a Sample OpenROAD Server Application with JSON-RPC Support
1. Using Workbench, create a new OpenROAD application named testapp with a Database Connection “None.”
2. Add a new Ghost Frame Component named startingghost.
3. Set startingghost as the Starting Component of the testapp application.
4. Add a new 4GL Procedure named “add,” which will be called using the JSON-RPC interface.
5. Implement the procedure with two integer parameters “val1” and “val2” and returning val1+val2 as an integer.
PROCEDURE add (
    val1 = INTEGER NOT NULL,
    val2 = INTEGER NOT NULL
)=
{
    RETURN val1+val2;
}
6. Create testapp.json using the JsonConfig4App utility for the “add” 4GL procedure.
7. Copy testapp.json into %II_SYSTEM%\ingres\files\orjsonconfig.
8. Create an image of the testapp application as testapp.img.
9. Copy testapp.img into the directory specified by the II_W4GLAPPS_DIR environment variable. (See Environment Variables for All Platforms in the Workbench User Guide.)
10. Register the testapp application, either interactively or from command line:
Interactively, using VOSA (see Local Application Registration):
From the command line, using the orserveradm.py script (see Manage the Installation with orserveradm.py Script):
cd "%II_SYSTEM%\ingres\bin"
echo {"akaname":"testapp", "imagefile":"testapp.img", "cmdflags":"-Tall,logonly -Ltestapp.log"} | python orserveradm.py AddApp
11. Restart Tomcat and the OpenROAD Application Server.
12. Test the servlet using your Tomcat webapp URL such as http://localhost:8080/openroad/jsonrpc?app=testapp.
13. Send the following JSON-RPC request for the “add” procedure:
{
    "jsonrpc": "2.0",
    "method": "add",
    "params": {
        "val1": 1,
    "val2": 2
      },
    "id": 1
}
The JSON-RPC response should be:
{
    "result": 3,
    "id": 1,
    "jsonrpc": "2.0"
}
You can execute the previous JSON-RPC request using a test user frame of the jsonrpcservertest application.
 
Last modified date: 12/20/2023