[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Convert a Java source to RPGLE
Sender: Scott Klement <sk@xxxxxxxxxxxxxxxx>
Is there any way to convert the attached Java source to RPGLE? Or
1). In a RPGLE program, how to establish a connection to an HTTP server
(HTTP://MyHost:80)? ( Can http_connect be used?)
2). How to post message to an URL argument? (is it http_url_ post? Any
example?)
The program you have attached does not use POST, it uses a GET operation.
You can code the same thing in RPG using the HTTPAPI service program.
x = http_url_get('http://MyHost/servlet/commz.servlet.SendMsg'
+'?id=demo&n=659234234&msg=testing+one+two+three
+'&desc=test'
: '/tmp/myfile');
if (x <> 1);
errormsg = http_error();
endif;
When you do this, the results of your GET operation will be saved to the
stream file called /tmp/myfile in the IFS.
If you'd prefer that the results be returned to your prgoram (as they are
in the Java example) then you'd use HTTP_url_get_raw() instead. In that
case, you'll designate a subprocedure to be called whenever data is
received from the HTTP server.
x = http_url_get('http://MyHost/servlet/commz.servlet.SendMsg'
+'?id=demo&n=659234234&msg=testing+one+two+three
+'&desc=test'
: 1
: %paddr(MySubproc));
The MySubproc subprocedure will receive 3 parameters, as follows:
D mySubproc PI 10I 0
D FD 10I 0 value
D Data 8192A const options(*varsize)
D Len 10I 0 value
You can do whatever you like with the data that it sends you, just make
sure that you return the length of data that you received, otherwise
HTTPAPI will think that something's wrong and abort.
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubsribe from the list send mail
to majordomo@xxxxxxxxxxxxx with the body: unsubscribe ftpapi mymailaddr
-----------------------------------------------------------------------