The following are four application scenarios for accessing UTM applications from HTTP clients.
Direct call of existing line-mode program units
Existing line-mode programs can be called by HTTP clients without any changes to the application programs being necessary.
The prerequisite is that the addressed operation is a one-step operation.
The message for the program unit can be passed in the query and/or the message body of the HTTP request.
If the TAC of the program unit is specified directly in the path, openUTM performs a code conversion of the HTTP messages for such a TAC in BS2000 systems. The HTTP response formats openUTM as an HTML message, whereby several message parts passed with MPUT NT are combined and line breaks are received.
Call existing program units via an HTTP Exit
This scenario is useful for programs that expect data in a defined layout, such as programs that were previously called by UPIC clients.
The program unit does not have to be changed. Instead, the user can write an HTTP exit program and assign this exit program to the TAC in an HTTP-DESCRIPTOR statement.
The HTTP exit program is then called by openUTM for each input and output message of this TAC.
In the HTTP exit program, the user can perform the conversion of the network message to the data structure expected by the program unit, as well as the conversion of the response message from the program unit into a network message.
The HTTP exit program can also subdivide an HTTP request into several message parts, each of which can then be read with a separate MGET NT call. In a similar way, the HTTP exit program can assemble an HTTP response from several message parts supplied by several MPUT NT calls.
Calling existing program units from new HTTP clients
If an existing application is not to be modified, then a user can create new client programs, that communicate with the UTM application using the HTTP protocol and which provide data in the format expected by the existing program units of the UTM application and present the response of the UTM application in an appropriate form to the user.
Develop new program units for communication with HTTP Clients
New programs created specifically for communicating with HTTP clients have various ways of accessing protocol information.
On the one hand, information about an HTTP request can be obtained by an option of the INIT PU call.
On the other hand, openUTM provides a number of functions that allow to access segments of an HTTP message directly.
Reading an HTTP message
A payload message intended for a program unit can be specified in the query and/or in the message body for an HTTP request.
Reading an HTTP message without HTTP exit
A program unit can read the payload message of an HTTP request with MGET. If the HTTP request contains a query, openUTM returns the query during the first MGET of a program unit run. The message body can be read with subsequent MGET calls.
If no query is contained in an HTTP request, on the first MGET openUTM returns the (first part) of the message body. Subsequent MGET calls can be used to read further parts of the message body.
Reading an HTTP message with HTTP exit
In this case, the HTTP exit determines which data the program unit receives from the MGET and how this data is structured in message segments.
Structure of an HTTP-Response
Response messages to an HTTP client are passed to openUTM with MPUT calls. A user program can also use special functions to set the status code and header fields of an HTTP response.
Functions for accessing parts of an HTTP message
Not only the payload message of an HTTP message may be relevant for user programs. The URL and the HTTP headers may also contain information that an application program needs to process a request.
For this purpose openUTM provides a number of functions that can be used to read or write parts of an HTTP message from an HTTP exit or a program unit. These functions enable a user to control the program flow and supply parts of the response message.
An overview on these functions can be found in the subchapter „Program interface UTM-HTTP" in the openUTM manual „Programming Applications with KDCS". |