DOCM to JSON-RPC Convesion

61 views
Skip to first unread message

Jan

unread,
Jun 11, 2024, 8:58:20 AMJun 11
to OpenROAD Users Mailing List
Hello all,

We're trying to convert our current setup from DCOM to JSON but have encountered some problems. 

I'm trying to duplicate a user class from the client side back to the app server.

Tried passing converting the whole user class to jsonobject as a string in the request. value and this works but since the value attribute has a limited length.

an example of our code in DCOM was like:
            userclass_one = userclass_two.duplicate();

but since I'm unable to pass a complex object in a request.value in json-rpc request, We're trying to look for another way to pass a complex object in json-rpc. Please advise.

Thank you

Adrian Williamson

unread,
Jun 11, 2024, 9:05:59 AMJun 11
to openroa...@googlegroups.com

Hi,

 

Tried passing converting the whole user class to jsonobject as a string in the request.”

 

Have the actual code snippet for that?

 

From some of the language in your note I am wondering if you should be using the method on the JsonHandler Class instead shown below.

 

Apologies if I got that wrong.

 

Cheers

Adrian

 

From

https://docs.actian.com/openroad/12.0/index.html#page/LangRef/Object2JsonValue_Method.htm

 

--
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/fed5c840-ff53-4f4c-a7ee-faba63ef2b35n%40googlegroups.com.

image001.jpg

Jan

unread,
Jun 14, 2024, 5:29:48 AMJun 14
to OpenROAD Users Mailing List
Hi,

Thank you for your response. Sorry for the confusion.

 I was trying to call a method from the app server using a JSON-RPC request. We have a code that duplicates the user class to pass the data to another. See snippet below.
Untitled.png

We're trying to pass the whole user class converted to a string object in the JSON-RPC request .value but since the value attribute can only hold 2000 in length (please let me know if we are wrong on this) we can't pass bigger user classes. 

is there any other way to pass user classes to the app server from the client side? 

Regards,
Jan

 

Bodo Bergmann

unread,
Jun 14, 2024, 5:59:22 AMJun 14
to openroa...@googlegroups.com
Hi Jan,

Could it be that the Initiate() already fails?
Check the return value and the Errorcode/Errortext attributes of CurRemoteServer after its invocation.
The value of the "location" parameter looks wrong.
Should be something like this: 'http://localhost:8080/openroad/jsonrpc?app=yourappname',
where yourappname is the registered akaname (in orserver.json) for the application containing the "go" 4GL procedure.
Of course there should be a  yourappname.json file in the %II_SYSTEM%\ingres\files\orjsonconfig directory containing the "go" procedure in the "rows" of the "registeredprocs", defining "p_this" parameter as "byref_use": true.

BTW: No need to do all the duplicate() invocations - you can use varsample2 directly in the Object2JsonValue() method invocation.

Bodo

Bodo Bergmann

Engineering Architect | OpenROAD Engineering

Actian, a division of HCLSoftware

actian.com    hcl-software.com

 GESELLSCHAFTSANGABEN: Actian Germany GmbH | Registry Off: Halenreie 42, 22359 Hamburg | Geschäftsführung: Stephen Padgett, Marc Monahan | HandelsregisterAmtsgericht Hamburg | HRB 135991 | USt-IdNr: DE252449897 


Jan

unread,
Jun 18, 2024, 9:53:37 PMJun 18
to OpenROAD Users Mailing List
Hi Bodo,

The code above works as intended, we can receive a JSON response from the app server. "app" is our application name.


We're just wondering if there are limitations when passing the whole user class as a JSON string in the request. value since when we are using the value attribute as a parameter in the request.value.
Untitled1.png
Based on the image below, the value attribute can only hold 2000 in length.
Untitled.png

Since we are expecting a value of greater than 2000 when we convert our user classes.


Regards,
Jan

Bodo Bergmann

unread,
Jun 20, 2024, 5:00:40 AMJun 20
to openroa...@googlegroups.com
Hello Jan,

In order to prevent a cut-off of the request string you could of course use StringObject methods for the concatenation like this:

request.Value = '{"jsonrpc":"2.0", , "id":1, "method":"go", "params":{"$byref_params":"p_this", "p_this":';
request.ConcatString(string = jsonstring); // Add value for the user class object
request.ConcatVarchar(text = '}}'); // Closing the "params" object and the whole request object

HTH.
Regards,
Bodo.


Bodo Bergmann

unread,
Jun 20, 2024, 5:07:09 AMJun 20
to openroa...@googlegroups.com
Please correct the first statement (contained a superfluous comma):

request.Value = '{"jsonrpc":"2.0", "id":1, "method":"go", "params":{"$byref_params":"p_this", "p_this":';

Jan

unread,
Jun 24, 2024, 3:18:02 AMJun 24
to OpenROAD Users Mailing List
Hi Bodo,

Thank you and the code you've provided greatly worked for us.

Out of curiosity, are there other ways to pass user class to the app server aside from the method above?

Again, Thank you.

Regards,
Jan

Bodo Bergmann

unread,
Jun 24, 2024, 4:37:02 AMJun 24
to openroa...@googlegroups.com
Hi Jan,

When using the JsonRpcRequest() method, you'll have to pass a request StringObject.
This could be constructed in different ways.
For instance you you could first populate the whole request as a JsonObject with members "jsonrpc", "id", "method" and "params" (within which you have the "$byref_params" and "p_this" members) - but you would also use the Object2JsonValue() method to create the value for your "p_this" parameter from your userclass object. Then you could use the JsonHandler.Write() method to generate the request string from that complex JsonObject.

As a much simpler alternative I recommend to consider using the Call4GL() method - same as you used it with DCOM like this:
    CurRemoteServer.Call4GL('go', p_this = BYREF(varsample));

It will internally convert the call into a JsonRpcRequest() to be executed on a server connection with "http-jsonrpc" routing.
This will require a recent OR 11.2 patch (15922 or higher).

HTH.
Regards,
Bodo.


Reply all
Reply to author
Forward
0 new messages