Working with messages in a terminal message handler

A typical terminal handler processes a request, invokes an application program, and generates a response.

Note: Although Web services typically use SOAP messages which contain XML, your message handlers will work as well with other message formats
In a terminal message handler, you can work with a request, and - optionally - generate a response and pass it back along the pipeline. A typical terminal handler will use the request as input to an application program, and use the application program's response to construct the response.
  1. Using the contents of container DFHFUNCTION, determine that the message passed to this handler is a request, and that the handler is being called as a terminal handler.
    DFHFUNCTION Request or response Type of handler Inbound or outbound
    PROCESS-REQUEST Request Terminal Inbound
    Tip:
    • If DFHFUNCTION contains any other value, the handler is not a terminal handler, and these steps do not apply.
  2. Retrieve the request from container DFHREQUEST. Container DFHRESPONSE is also present, with a length of zero.
  3. Perform any processing of the message which is required. Typically, a terminal handler will invoke an application program.
  4. Construct your response, and put it in container DFHRESPONSE. If there is no response, you must delete container DFHRESPONSE.
The response is passed to the next handler in the response phase of the pipeline. The handler is invoked for function SEND-RESPONSE. If there is no response, the next handler is invoked for function NO-RESPONSE.