Try OpenEdge Now
skip to main content
Web Services
Creating ABL Clients to Consume OpenEdge SOAP Web Services : Handling SOAP Message Headers in ABL : Creating and managing SOAP message headers : Reusing an unchanged SOAP response header : Response header handler for returning a header for reuse
 
Response header handler for returning a header for reuse
This is the SOAP response header handler (RespHandler) that returns the header that is reused for passing around the AccessID value:
Response header handler saving a SOAP response header for reuse
PROCEDURE RespHandler: /*1*/
  DEFINE INPUT PARAMETER hHeader    AS HANDLE.
  DEFINE INPUT PARAMETER cNamespace AS CHARACTER.
  DEFINE INPUT PARAMETER cLocalNS   AS CHARACTER.
  /* If the g_header global variable is valid coming in, it has already been
    set in a previous response, therefore, delete the unnecessary response
    header object. Otherwise, set g-header to the response header object to
    pass back to the request header handler on subsequent requests. */

  IF NOT VALID-HANDLE(g_header) THEN /*2a*/ /* first response */
    g_header = hHeader.
  ELSE DO: /*2b*/ /* all subsequent responses */
    DELETE OBJECT hHeader.   END.
END PROCEDURE.
The code in the preceding example:
1. Receives the SOAP response header using the hHeader parameter
2. Tests if the global header handle (g_header) already references a valid object, and:
a. If it does not reference an object, the handler must be running as part of the initial call to OpenAccess and thus saves the input SOAP header object (hHeader) to the global context (g_header) for use by subsequent requests. From this moment forward, all requests to the Web service discard the header object input to the response handler as unnecessary.
b. If it does reference an object, the handle must already reference a SOAP response header returned in a prior request (the call to OpenAccess) and has no need of a subsequent response header. It therefore deletes the unnecessary SOAP header object returned to the handler through the hHeader parameter in order to prevent a memory leak accumulating in subsequent requests.