DCOM to JSON AppServer Conversion

59 views
Skip to first unread message

Elyanna Jewel

unread,
Nov 17, 2023, 1:45:38 AM11/17/23
to OpenROAD Users Mailing List
Hi,

We are just converting our DCOM setup to JSON. Does anyone have a sample code for both AppServer Side (User Class, Procedures), and Client Side (User Frames).

I would like to see how you convert things to and from JSON String Format.

regards,
Rowell

Bodo Bergmann

unread,
Nov 17, 2023, 5:27:30 AM11/17/23
to openroa...@googlegroups.com

Hi Rowell,

 

Have a look at the various trainings/tutorials that are available in Actian Academy first: https://academy.actian.com/?q=OpenROAD%20JSON - they are full of examples.

 

Anyway, I assume that you are converting from direct DCOM connection (routing not specified or some DCOM specific settings – combination of unauthenticated/compressed)
to a connection using the “http-jsonrpc” routing (via the OpenROADJSONRPC servlet running in Tomcat).

 

Server side

The server application would not have to be changed.
The only item you would have to add is a JSON config file (%II_SYSTEM%\ingres\files\orjsonconfig\applicationname.json) for your application, that defines the 4GL procedures (and their parameters).
This can be created using the “JSON Configuration File Generator” utility – see https://docs.actian.com/openroad/11.2/index.html#page/ServerRef/JsonConfig4App_Utility.htm
and https://academy.actian.com/actian-openroad-json-generators

 

Client side

 

This will currently require you to change the Initiate() method parameters: routing= ' http-jsonrpc ' and location to the URL (including the application name).
Additionally, the Call4GL() method invocations into JSON-RPC requests, which you execute via the JsonRpcRequest() method.
If you have any BYREF variables, you will have to assign the according results from the response string returned into the 4GL variables using the AssignJsonRpcResponse2Vars() function.

 

Example – your current code would contain something :

 

      rv = rs.Initiate(type=RP_SHARED, image = 'comtest.img', flags = '-Tall,logonly -Lcomtest.log', location = 'yourserver'); // COM

      vhello = 'HELLO';

      ctr = 0;

      rv = rs.Call4GL('helloworld', hellostring= BYREF(vhello), counter=BYREF(ctr));

 

Converting to JSON-RPC request usage this looks like this:

 

      rv = rs.Initiate(type=RP_SHARED, image = '', routing = 'http-jsonrpc', location = 'http:://yourserver:8080/openroad/jsonrpc?app=comtest');

      // jreq and jresp are StringObject

      jreq.Value = '{"jsonrpc":"2.0","id":1,"method":"helloworld", "params":{"hellostring":"HELLO","counter":0,"$byref_params":"hellostring,counter"}}';

      jresp = rs.JsonRpcRequest(request= jreq);

      CALLPROC AssignJsonRpcResponse2Vars(jsonrpc_response=jresp, var_scope=CurExec.Scope,

            byref_assign_rule='vhello=hellostring,ctr=counter');

 

For creating the JSON-RPC request strings you can make use of the “JSONRPC Sample Request Generator” utility.

For converting your 4GL variables/object/arrays used as parameters into JSON you can use the JsonHandler.NewJsonValue() and/or JsonObject.NewMember() methods.
You can then use the JsonHandler.Write() method to convert the JsonValue/JsonObject objects into a JSON string.
This might be some effort (if your procedure has many parameters).

 

And now the good news:

We have implemented a change that allows to directly use the Call4GL() method in OpenROAD on a connection that uses “http-jsonrpc” routing.
It will internally do the conversion of 4GL parameters, the JsonRpcRequest() method invocation and the assignment of the BYREF parameters.
Therefore, the only change you’ll have to do is in the Initiate() method invocation.
This change will be part of the next (upcoming) patch for OpenROAD 11.2.

 

HTH.
Kind regards,
Bodo.

Bodo Bergmann
Engineering Architect | OpenROAD Engineering

Actian, a division of HCLSoftware

A blue rectangular object with white text

Description automatically generated
GESELLSCHAFTSANGABEN: Actian Germany GmbH | Sitz der Gesellschaft: Halenreie 42, 22359 Hamburg | Geschäftsführung: Stephen Padgett, Marc Monahan | Handelsregister: Amtsgericht Hamburg | HRB 135991 | USt-IdNr: DE252449897

--
You received this message because you are subscribed to the Google Groups "OpenROAD Users Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to openroad-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/openroad-users/69f8bfd0-d3e6-4e22-bb0e-74b3ea853027n%40googlegroups.com.

Durwin Wright

unread,
Nov 17, 2023, 9:24:43 AM11/17/23
to Durwin Wright, openroa...@googlegroups.com, Brigitte Duplenne, Chris Clark, Mahin Pandya, Bodo Bergmann, Bodo Bergmann

Hello 

Please contact durwin...@hcl-software.com.  We have some interesting news regarding your proposed conversion.

 

We have implemented a way to allow the OR 11.2.0 Windows client to convert Call4GL() method internally to JsonRpcRequest() method calls.  I have a presentation that describes how to do the conversion as well.  I have written a sample application that shows how to do this against the COMTEST sample application server.

 

It would be good to setup a meeting to discuss this further

 

Durwin Wright

OpenROAD Engineering

Actian, a division of HCLSOFTWARE

 

 

From: Durwin Wright <Durwin...@hcl-software.com>
Sent: Friday, November 17, 2023 8:13 AM
To: openroa...@googlegroups.com; Durwin Wright <durwin...@hcl-software.com>; Durwin Wright <Durwin...@actian.com>; Brigitte Duplenne <Brigitte...@actian.com>; Chris Clark <Chris...@actian.com>; Mahin Pandya <mahin....@actian.com>; Bodo Bergmann <Bodo.B...@actian.com>; Bodo Bergmann <bodo.b...@hcl-software.com>
Subject: Re: [openroad-users] DCOM to JSON AppServer Conversion

 

Hello 

Please contact durwin...@hcl-software.com.  We have some interesting news regarding your proposed conversion.

 

We have implemented a way to allow the OR 11.2.0 Windows client to convert Call4GL() method internally to JsonRpcRequest() method calls.  I have a presentation that describes how to do the conversion as well.  I have written a sample application that shows how to do this against the COMTEST sample application server.

 

It would be good to setup a meeting to discuss this further

 

Durwin Wright

OpenROAD Engineering

Actian, a division of HCLSOFTWARE

 

--

Elyanna Jewel

unread,
Nov 19, 2023, 11:08:27 PM11/19/23
to OpenROAD Users Mailing List
Hi Bodo,

You're assumption here is correct.

--- "Anyway, I assume that you are converting from direct DCOM connection (routing not specified or some DCOM specific settings – combination of unauthenticated/compressed)
to a connection using the “http-jsonrpc” routing (via the OpenROADJSONRPC servlet running in Tomcat)." ---


We managed to create a successful "http-jsonrpc" routing. The thing is, all of our applications utilizes CurObjects with UserClasses and less 4GL Procedures. We new that only 4gl procedures are exposed and not the methods.
It is easy to pass a single value from a procedure, but what we want to know is what is the proper way of converting our usual way.

UPDATE tblusers SET
username = UPPERCASE(:curobject.username),
lname = UPPERCASE(:curobject.lname),
fname = UPPERCASE(:curobject.fname),
password = AES_ENCRYPT_IV(:uPassword,'0000'),
per_del = :curobject.per_del,
per_inv = :curobject.per_inv,
per_sup = :curobject.per_sup,
per_too = :curobject.per_too,
per_doc = :curobject.per_doc,
per_adm = :curobject.per_adm

WHERE idno = :curobject.idno;
         
    CurObject.qry_stat = gprocErrorHandler();
    If CurObject.qry_stat._isSuccessful = False then
       RETURN 2;
    EndIf;
    COMMIT;

Bodo

unread,
Nov 20, 2023, 4:15:35 AM11/20/23
to OpenROAD Users Mailing List
Hi Rowell/Elyanna,

I am not sure where your code sample is coming from, but it looks like from the method script of a UserClass (as you are using CurObject).
This would not have to change at all.
With a JSON-RPC request you can also pass complex objects (e.g. userclass objects/arrays) to the called 4GL procedure.
A complex object is represented as JSON object within the params of the JSON-RPC request string, and also in the "$byref_results" of the response string.
So, in the client rather than:
    rs.Call4GL('my4GLproc', p_user = BYREF(a_user));
you would use a JsonRpcRequest() method with a request like this (you would have to construct the JSON for the parameters before):
    {"jsonrpc": "2.0", "id": 1, "method": "my4GLproc", "params": {"p_user": {"username":"jdoe","lname":"Doe","fname":"John"}, "$byref_params":"p_user"}}

HTH.
Regards,
Bodo.
Reply all
Reply to author
Forward
0 new messages