In today's business world, operations often rely on multiple applications and systems. To ensure these systems work together smoothly, web services and APIs (Application Programming Interfaces) have become essential components of modern IT ecosystems. One platform that has embraced this paradigm shift is IBM i (formerly known as AS/400), a highly secure and reliable environment that powers critical business applications across industries.
What are APIs and Web Services?
An API is a set of rules and protocols that allow software applications to communicate with one another. APIs enable the integration of different systems and automation of processes, providing access to databases and other resources.
A Web Service is a standardized way of integrating web-based applications. It is a resource available over the internet and provides valuable functionality that other applications can use, such as payment processing, user authentication, and data storage. Essentially, web services allow different applications to communicate over the internet.
While all web services are APIs, not all APIs are web services.
Types of Web Services
- SOAP:
- SOAP stands for Simple Object Access Protocol. It is an XML-based protocol for accessing web services, defining a standard communication protocol for XML message exchange.
- SOAP specifies how messages should be sent and received in a web service, making it ideal for complex, enterprise-grade transactions due to its rigidity and communication standards.
- It supports multiple transport protocols, including HTTP and SMTP.
- REST:
- REST stands for Representational State Transfer. It is an architectural style that uses standard HTTP methods (GET, POST, PUT, DELETE) for communication. RESTful services are lightweight, easier to maintain, and widely used in modern web applications.
- REST architecture revolves around system resources and how they are addressed and communicated through HTTP protocols.
- Over the years, REST has become the dominant web service design model due to its simplicity and ease of use, replacing many SOAP-based interfaces.
REST Architecture
- Statelessness: Each client request to the server must contain all necessary information to process the request, eliminating the need for the server to store client context between requests. This simplifies server design and enhances scalability.
- Client-Server Architecture: REST separates user interface concerns from data storage concerns, enabling independent evolution of client and server components.
- Uniform Interface: RESTful systems adhere to a uniform interface, simplifying and decoupling the architecture.
- Layered System: REST allows for a layered architecture where each layer performs a specific function, such as security, load balancing, or caching. This modularity enhances scalability and manageability.
- Cacheable: Server responses can be marked as cacheable or non-cacheable. Caching improves performance by reducing redundant requests.
Consuming Web Services on IBM i with Native SQL
- IBM i Native SQL Routine (SYSTOOLS):
- IBM i offers several functions for making HTTP requests to web services via the SYSTOOLS SQL routine. Commonly used functions include:
- HTTPPOSTCLOBVERBOSE
- HTTPPUTCLOBVERBOSE
- HTTPGETCLOBVERBOSE
- HTTPDELETECLOBVERBOSE
- These functions were first introduced after the IBM i 7.2 release in 2014.
- A JVM (1.6 or newer) must be installed, and the JVM starts in each job, which may have performance implications.
- The HTTP request header must be in XML format.
2. IBM i Native SQL Routine (QSYS2):
-
- IBM i also provides functions for HTTP requests through the QSYS2 SQL routine, commonly used functions include:
- HTTP_POST_VERBOSE
- HTTP_PUT_VERBOSE
- HTTP_GET_VERBOSE
- HTTP_DELETE_VERBOSE
- These functions provide the same capabilities as SYSTOOLS HTTP functions but without the overhead of creating a JVM.
- They are supported on IBM i version 7.4 or higher.
- The HTTP request header must be in JSON format.