[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Call URL with RUNTIME parameters
Hello Theresa,
> I have installed HTTPAPI on my AS400 and tried to follow the tutorial
> but I am totally lost. Do I need to learn SOAP and/or XML to use the
> HTTPAPI utility?
I wasn't aware that there was a tutorial?!
You don't need learn SOAP or XML unless you plan to use SOAP or XML.
That's just what most web services use.
> I there any simple code template that I can use to plug into my RPG.
> Here is the URL I am trying to call (it shouldn't work for anyone
> outside our network).
EXAMPLE1? EXAMPLE2? Did you look at the EXAMPLE members included?
> TCP/IP version:
> http://172.17.10.55:8080/wow65/run?opid=432&QOEERRFND=D&QOEREFNBR=5144910
IMHO, it's never a good idea to hard-code an IP address into a computer
program. (But, it should work)
> Domain name version:
> http://wat-wow01.waterousco.acipco.com:8080/wow65/run?opid=432&QOEERRFND=D&QOEREFNBR=5144910
This should also work.
As a simple sort of "getting started" example, you might try doing this:
H DFTACTGRP(*NO) ACTGRP('KLEMENT') BNDDIR('HTTPAPI')
/copy httpapi_h
D url s 300a varying
D rc s 10i 0
/free
http_debug(*ON: '/tmp/theresa.log');
url = 'http://wat-wow01.waterousco.acipco.com:8080/+
wow65/run?opid=432&QOEERRFND=D&QOEREFNBR=5144910';
rc = http_url_get( url: '/tmp/testreply.txt');
if (rc <> 1);
http_crash();
endif;
*inlr = *on;
This should attempt to connect to the HTTP server, "run" that URL, and
then if it provides any sort of reply, it'll store the result in a file
called '/tmp/testreply.txt' in your IFS.
Diagnostic info should be written to /tmp/theresa.log, so if you're
having troubles, you can look there to see what's going on. Or if you
need to seek help from this mailing list, that log provides a lot of
info that will make it easier for us to help you.
If that example DOES work, then the next thing you'll want to look at is
"how do I put data in the URL that comes from a variable". You could do
it by simple concatenation, as long as you're careful to make sure your
data is escaped properly for a URL. Or, to make things easier, you can
use HTTPAPI's WEBFORMS utilities to make sure any special characters
are escaped properly.
H DFTACTGRP(*NO) ACTGRP('KLEMENT') BNDDIR('HTTPAPI')
/define WEBFORMS
/copy httpapi_h
D url s 300a varying
D form s like(WEBFORM)
D rc s 10i 0
D opid s 5p 0 inz(432)
D qoeerrfnd s 10a inz('D')
D qoerefnbr s 20a inz('5144910')
/free
http_debug(*on: '/tmp/theresa.log');
form = WEBFORM_open();
WEBFORM_setVar(form: 'opid': %char(opid));
WEBFORM_setVar(form: 'QOEERRFND': %trimr(qoeerrfnd));
WEBFORM_setVar(form: 'QOEREFNBR': %trimr(qoerefnbr));
url = 'http://wat-wow01.waterousco.acipco.com:8080'
+ '/wow65/run?'+ WEBFORM_getData(form);
WEBFORM_close(form);
rc = http_url_get( url: '/tmp/testreply.txt');
if (rc <> 1);
http_crash();
endif;
*inlr = *on;
You say that you don't want to get anything back. I'm skeptical of this
-- I would expect that you'd at least like to get back an indication of
whether the program was called successfully or not??
If it fails, the file you get back from the HTTP server will be your
best indication of what went wrong... i.e. why it failed. So I think
you probably do want to get something back.
There are ways to tell HTTPAPI that you want to completely ignore any
information that comes back... but lets start with this for now, and see
how far that takes you. If you still want to ignore anything that comes
back (which would be unusual) then let me know and I'll explain that part.
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------