You may saw that I am using SQL to access to the system.
Since you could communicate via SQL you can call every Programm you want via external SQL Procedures or Functions.
The http_post method in RPG is not necessary anymore. You can use python for this job. This is much more simpler and very easy than to do it by RPG.
With this concept you now will use RPG only for your business logic, as it is supposed to be.
Announcement
Collapse
No announcement yet.
RESPONSE / BODY from QSYS2.HTTP_POST
Collapse
X
-
Thank you.
I don't like IBM IWS too.
I had a look at your python web server but unfortunately I cannot reuse my RPGLE code
Leave a comment:
-
This is a quite complicated way to provide a web service server.
There exist the IBM IWS (Integrated Webservice Server) ... which I personally don't like.
I would prefer to use Python for that job.
With that solution I don't have all these problems which happens when you use RPG or IWS.
I have a very small (fist step) open source project if you are interessted: https://github.com/andreas-prouza/python-webapi
Leave a comment:
-
Server , provide service from RPGLE
This is httpd_conf file from IBM I Apache web server.
Below is the SQL invoked by the calling RPGLE program
dcl-s vJsonData Varchar(8000); // contains BODY
dcl-s myclob SQLTYPE(CLOB:800000); // RESPONSE from /api/getcmddata WW003R.PGM
Exec Sql
values qsys2.http_post(
'http://localhost:8080/api/getCmdData',
:vJsonData,
'{"header":"content-type,application/json","header":"content-length, 1000","sslTolerate":"true"}'
) Into :MYCLOB;
Now in WW003R program (invoked via /api/getcmddata) I Need to parse HTTP BODY request and set HTTP_RESPONSE from qsys2.http_post SQL statement in order to set its value into MYCLOB calling program variable.
I have hundreds of RPGLE programs already running and would like to use them instead to rewrite them into a new IWS instance
Leave a comment:
-
Hi Andreas,
thank you for your reply.
I'm trying to reuse hundreds of RPGLE programs that are actually working in the IBM I Apache web server, but I can't find how to do it.
Leave a comment:
-
HI HMiller,
In your post I can't see the definition of MY_CLOB var.
Why don't parse you json with jdb2 son_table? is very friendly.
Bye
Leave a comment:
-
Hi Giovanni,
A PGM Object never has a "return" value.
This only can be provided by Procedures (*MODULE, *SRVPGM).
For *PGM you only can pass a return value over the parameter list.
Leave a comment:
-
RESPONSE / BODY from QSYS2.HTTP_POST
Hello,
I added the SQL Function QSYS2.HTTP_POST in a RPGLE program.
Exec Sql
values qsys2.http_post(
'http://localhost:8080/api/getDBData',
:vJsonData,
'{"header":"content-type,application/json","header":"content-length, 1000","sslTolerate":"true"}'
) Into :MYCLOB;
I can't use IWS as I need to reuse hundreds of RPGLE program that use standard CGI methodology.
I am unable to return response from the RPGLE called program to fill :MYCLOB variable.
Ctl-Opt Main(Main) openopt(*nocvtdata) option(*noDebugIO:*srcStmt);
Dcl-Proc Main;
Dcl-Pi Main ; // Cannot define a return value due to *RNF3841 compilation error
End-Pi;
// BODY PARSING
// Not working . I had to pass body via environment variable.
Data-Into http_stdin
%data('*STDIN'
:'allowmissing=yes allowextra=yes countprefix=num_ case=any')
%parser('YAJLINTO');
// RESPONSE NOT WORKING
data-gen http_stdout
%data(vJsonVar:'countprefix=num_')
%GEN( 'YAJLDTAGEN'
: '{"write to stdout":true, "http status":200, "include empty arrays": true}');
GiovanniTags: None
Leave a comment: