Chapter 7. Writing Server API programs

Overview of the Server API

The Server API allows you to extend the server’s base functions. You can write extensions to do customized processing, such as:

vEnhance the basic authentication or replace it with a site-specific process.

vAdd error handling routines to track problems or alert for serious conditions.

vDetect and track information that comes in from the requesting client, such as server referrals and user agent code.

General procedure for writing Server API programs

Before you start writing your Server API programs, you need to understand how the IBM HTTP Server works. The server performs a sequence of steps for each client request that it processes. Your program can run and make function calls at any of these steps. You need to decide where in the basic server request process you want to add customized functions. For example, do you want the server to do something after it reads a client request but before it performs any other processing? Or, maybe you want the server to perform special routines during authentication and then after it sends the requested file.

You can instruct the server to call the application functions in your program at the appropriate processing step. You can do this by using the API directives in your server configuration file.

Guidelines

Use the following guidelines when creating Server API programs:

vIf compiling on AS/400 with Integrated Language Environment (ILE)/C, ensure that you include QHTTPSVR in the library list.

vGive each of your application functions a unique function name and call the server predefined functions as needed. Be sure to include HTAPI.h and to use the HTTPD_LINKAGE macro in your function definitions to avoid abending the server. This macro ensures that all functions use the same calling conventions.

vThe server runs in a multithreaded environment; therefore, your application functions must be threadsafe. If your application is re-entrant, performance will not decrease.

vKeep the actions in your applications to a thread scope. Do not perform any actions as a process scope, such as exit or change user ID.

vEliminate global variables or protect them with a mutual exclusion semaphore.

vDo not forget to set the Content-Type header if you are using HTTPD_write() to send data back to the client.

vYou also must take into consideration the Content-Encoding header when you use HTTPD_write() to send data back to the client.

vAlways check your return codes and provide conditional processing where necessary.

vCompile and then create your service program by using CRTSRVPGM. When using CRTSRVPGM, you must bind to QZHBIAPI *SRVPGM that is in the QHTTPSVR library.

© Copyright IBM Corp. 1997, 2000

109

Page 119
Image 119
IBM AS/400E Writing Server API programs, Overview of the Server API, General procedure for writing Server API programs

AS/400E specifications

The IBM AS/400E, now more commonly known as IBM i, is a robust and versatile midrange server that has been designed to provide a comprehensive computing solution for businesses of all sizes. First introduced in the late 1980s, the AS/400 series has undergone multiple enhancements and rebranding, with the AS/400E being one of the notable iterations. This powerful platform is closely associated with IBM's commitment to reliability, scalability, and integrated business solutions.

One of the main features of the AS/400E is its highly integrated architecture that combines hardware and software into a cohesive system. This integration allows for seamless operations, reducing the complexity typically associated with managing disparate systems. The system is powered by IBM's proprietary OS/400 operating system, which has evolved into IBM i, featuring advanced capabilities like object-oriented programming, integrated database management, and security features that are essential for enterprise environments.

A key characteristic of the AS/400E is its robust database support, primarily through the use of DB2 for i. This integrated database management system enables efficient data handling and retrieval, facilitating real-time business analytics and reporting. Furthermore, the platform supports a variety of programming languages, including RPG, COBOL, and Java, making it flexible for developers who require diverse tools for application development.

The AS/400E is also known for its exceptional reliability and uptime, making it a preferred choice for critical business applications in industries such as finance, healthcare, and manufacturing. This reliability is backed by advanced error detection and correction mechanisms, as well as redundancy features that help prevent data loss and minimize downtime.

In terms of scalability, the AS/400E can effortlessly expand to accommodate growing business demands. Organizations can increase processing power by adding more resources without significant disruption. This scalability, combined with the system’s built-in virtualization capabilities, allows businesses to optimize resource usage and streamline operations.

Security is another defining feature of the AS/400E. The platform incorporates various layers of security measures, including user authentication, encryption, and comprehensive auditing capabilities, ensuring that sensitive business data is protected against unauthorized access.

Overall, the IBM AS/400E remains a powerful tool in the enterprise computing landscape, providing businesses with an integrated, reliable, and secure solution for their technological needs. Its enduring popularity is a testament to its capability to evolve with changing business requirements while maintaining its core attributes of high performance and stability.