Hi Richard,
You have to look at the CGI conversion mode (CGI_MODE) of the Apache HTTP server with values like %%BINARY%% or %%MIXED%%. That determines the conversion of data from the outside world to your CGI program. It works in harmony with the DefaultNetCCSID and CGIJobCCSID keyword.
We've struggled with that in the past and then decided to send unicode data to our home grown browser front end as hexadecimal data and convert it back to unicode in te browser. That workaround won't be an option for you.
This mode has an effect on the apï's you can use in you CGI program to read StdIn (for method POST) or QUERY_STRING EnvVar (for GET)
Kind regards,
Martijn van Breden
lead software architect
Hi All,
I’m working on doing a sample minimalist CGI Web API program that uses no external API stack other than what the OS provides along with SQL in an RPGLE program.
I essentially want to see what a lightweight RPG CGI REST architecture might be in today’s arena.
I know there are frameworks like IWS, HTTPAPI, YAJL and NOXDB, CGIDEV2 etc that can be used as helpers.
I also know I can use Python, PHP, Node, Java etc. I want this ONLY to be SQLRPGLE.
This is a POC to see if I can do a minimalist approach to CGI. And even AI keeps screwing things up as far as appropriate API definitions and data conversion :-)
The biggest issue is handling the UTF-8 data conversion.
Also for context it’s been a few years since I’ve worked much with RPGLE and CGI. And I’m going all in on SQLRPGLE and JSON_TABLE/JSON_OBJECT with this sample.
Basically I want to:
-Take in a posted JSON packet. (Works)
-Read the request data QtmhRdStdIn. (Works but it appears to be raw UTF-8 data. I think)
-Convert and review the URL data and JSON and convert it to something readable in RPGLE as it appears to be coming in as UTF-8.
-Run an SQL using JSON values extracted from the JSON request using JSON_TABLE.
-Run the SQL query.
-Turn around and output the results as JSON
My only real stumbling block is converting the incoming and outgoing data correctly from and back to UTF-8. And that may also be an Apache configuration issue as far as character conversion. ICONV may be part of the answer but even AI comes up with long answers that didn’t seem to work as I had to use the 80/20 where it gave me 80% and I had to punt on the 20%.
Anyway, any insights relevant to the constraints I laid out are appreciated in case anyone else has already been there when playing with SQLRPGLE, CGI and JSON.
Regards,
Richard Schoen
Web:
http://www.richardschoen.net
Email: richard@xxxxxxxxxxxxxxxxx
--
This is the RPG programming on IBM i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit:
https://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at
https://archive.midrange.com/rpg400-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related questions.