I should have clarified: this is not exactly what you requested, since you will need to add the method names to the URL. I think what you requested was a way to use a single URL, but have different code executed within the REST service based on the HTTP used to request something from the REST service. So
http://myUrl/students would execute a SQL statement when it receives a GET request but call a program when it receives a POST request.
What I was suggesting would require another element in the URL to identify the method of the IWS service. So:
(1.)
http://myUrl/students/enrolledStudent?class=PSYC101 would execute the SQL statement with a parameter to return students enrolled in Psychology 101.
(2.)
http://myUrl/students/enrollNewStudent?class=Psyc101&studentId=12345 . would call the stored procedure, which would in turn call the desired ILE program to enroll a new student into the Psychology 101 class.
Thanks,
Kelly Cookson
Senior Software Engineer II
Dot Foods, Inc.
1-217-773-4486 ext. 12676
www.dotfoods.com
-----Original Message-----
From: Kelly Cookson
Sent: Tuesday, November 17, 2020 1:56 PM
To: Web Enabling the IBM i (AS/400 and iSeries) <web400@xxxxxxxxxxxxxxxxxx>
Subject: RE: [EXTERNAL] Re: [WEB400] Mixing sql and service program in IWS...
Just throwing this out as a possibility...I have never done this and have no clue about performance, limitations, or complexity in troubleshooting.
Would it be possible to create a *stored procedure* that calls the desired ILE program? I know stored procedures can call ILE programs. I've seen other people do it in our shop.
Then, use IWS to create a single REST service (SQL type service). The REST service would contain two methods within it.
(1.) One method receives HTTP GET requests and executes the SQL statement against the database file or table (e.g., SELECT * FROM MYFILE).
(2.) A second method receives HTTP POST requests and executes a SQL CALL statement to call the stored procedure--which in turn calls the desired ILE program.
As an Amazon Associate we earn from qualifying purchases.