IBM i Global

IBM i 

A space for professionals working with IBM’s integrated OS for Power systems to exchange ideas, ask questions, and share expertise on topics like RPG and COBOL development, application modernization, open source integration, system administration, and business continuity.


#Power


#IBMi
#Power
 View Only
  • 1.  Implementing webservices

    Posted Sat September 21, 2024 09:03 AM

    Hi,

    To implement webservices for IBM i are below steps, correct? if not could someone please advise correct steps?

    Implementing web services on IBM i can be done using the Integrated Web Services (IWS) server. Here's a step-by-step guide to get you started:

    ### 1. **Setting Up the IWS Server**
    1. **Start the IBM Web Administration for i Interface**:
       - Use the command `STRTCPSVR SERVER(*HTTP) HTTPSVR(*ADMIN)` to start the HTTP server.
       - Access the IBM Web Administration for i interface via a web browser.

    2. **Create an Integrated Web Services Server Instance**:
       - In the IBM Web Administration for i interface, navigate to the "Create New Server" option.
       - Select "Integrated Web Services Server" and follow the prompts to configure your server instance¹.

    ### 2. **Deploying a Web Service**
    1. **Prepare Your ILE Program**:
       - Ensure your ILE (Integrated Language Environment) program is ready to be exposed as a web service. This can be a *PGM or *SRVPGM object.

    2. **Deploy the ILE Program**:
       - Use the IBM Web Administration for i interface to deploy your ILE program as a web service.
       - Follow the steps to specify the program object and configure the web service settings¹.

    ### 3. **Consuming Web Services**
    1. **Using SQL to Consume Web Services**:
       - You can use the `HTTPGETCLOB` function to perform an HTTP GET request and retrieve the response as a CLOB (Character Large Object). Here's an example SQL script:
         ```sql
         SELECT FIRSTNAME, SURNAME, WEBSITE 
         FROM JSON_TABLE (
           SYSTOOLS.HTTPGETCLOB('https://example.com/api', NULL), 
           '$' COLUMNS (
             FIRSTNAME CHAR(50) PATH '$.firstName', 
             SURNAME CHAR(50) PATH '$.surName', 
             WEBSITE CHAR(50) PATH '$.webSite'
           )
         ) AS X;
         ```
       - This script retrieves data from a web service and parses it into a table format².

    ### 4. **Advanced Configuration**
    1. **Enable CORS and HSTS**:
       - For enhanced security, you can enable Cross-Origin Resource Sharing (CORS) and HTTP Strict Transport Security (HSTS) in the IWS server settings¹.

    2. **Logging and Monitoring**:
       - Configure logging in JSON format, HTTP access logging, and HTTP message logging to monitor your web services¹.

    Thanks.