Hello,

On 3/9/2012 9:40 PM, ssc1478 wrote:
It can't find the program so I think it thinks that OH is the program
instead of an argument.

My httpd.conf file has a ScriptAliasMatch to map anything following
PHIL to /qsys.lib/phil.lib:
ScriptAliasMatch ^/PHIL/(.*) /qsys.lib/phil.lib/$1.pgm


Right... you're telling it that everything that follows '/PHIL/' is to be placed in $1. So, this would result in Apache looking for a program named:

/qsys.lib/phil.lib/B01/OH.pgm

So, you don't really want it to take everything after "/PHIL/" and make it the program name, do you?

My suggestion is to write a "REST service router" program that receives the initial control from Apache, then calls the appropriate web service that you write. It can parse the program name from the URL.

ScriptAlias /rest /qsys.lib/phil.lib/rest.pgm

Now write a program (named REST.PGM) that reads the URL and parses the program name out of it. This is off the top of my head, and I haven't tested it:

uri = %str(getenv('REQUEST_URI'));

monitor;
keystr = %scan('/rest/': uri) + %len('/rest/');
nextbit = %scan('/': uri: keystr);
keyname = %subst(uri: keystr: (nextbit-keystr));
on-error;
// handle error
endmon;

Now you have a variable named 'keyname'. That could contain the name of the program you want to call, and then you could just call it. Or if you want to be fancy, it could be the key to a database record containing info about your RESTful services. This would be a bit more secure (since the caller can't call any arbitrary program on your system) and gives you the option to do other useful things, such as store the library list for each program in the PF, and set up the library list on each call, etc.

So you could do something like this. (Assuming RESTFILE is your database file containing the web services, and it has fields in it named RFLIB and RFPGM containing the library/program to call.)

D myPgmName s 21a
D RUNSERVICE PR ExtPgm(myPgmName)
.
.
chain keystr RESTFILE;
if not %found;
// handle error
else;
// maybe add code here to set up library list?
myPgmName = %trim(RFLIB) + '/' + %trim(RFPGM);
RUNPGM(myPgmName);
endif;

You might want to wrap the whole thing in a MONITOR, too.. and add a DSPJOBLOG OUTPUT(*PRINT), etc. That way, if the web service crashes, you can get diagnostics easily, and send a useful message back to the caller.

Food for thought...

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.