/*** PROCEDURE: Start transactions on an order. ***/
DEFINE INPUT PARAMETER OrderNum AS INTEGER. DEFINE OUTPUT PARAMETER hOrderSvc AS HANDLE. DEFINE OUTPUT PARAMETER gcUUID AS CHARACTER. /* Create hOrderSvc server handle and connect to order Web service. */ . . . /* Create hPortType procedure handle and map port type to it. */ . . . /* Set up response header handler. */ hPortType:SET-CALLBACK-PROCEDURE( "RESPONSE-HEADER", "TransactionResponseHandler", THIS-PROCEDURE ). /* Start a transaction on an order. */RUN startTransaction( "ORDER", OrderNum ) IN hPortType NO-ERROR. . . . |
/*
This response handler looks for a header entry named "OrderInfoID" and assumes that it contains an element named "uuid". The handler saves away the value of "uuid". This routine assumes that the SOAP header is no longer needed after the callback completes. */ PROCEDURE TransResponseHandler: DEFINE INPUT PARAMETER hSOAPHeader AS HANDLE. DEFINE INPUT PARAMETER cOperationNamespace AS CHARACTER. DEFINE INPUT PARAMETER cOperationLocalname AS CHARACTER. DEFINE VARIABLE hsheEntry AS HANDLE. CREATE SOAP-HEADER-ENTRYREF hsheEntry IN WIDGET-POOL "soap". DEFINE VARIABLE hxnTemp AS HANDLE. DEFINE VARIABLE hxnWorkRoot AS HANDLE. DEFINE VARIABLE hxnTemp2 AS HANDLE. CREATE X-NODEREF hxnTemp IN WIDGET-POOL "soap". CREATE X-NODEREF hxnTemp2 IN WIDGET-POOL "soap". CREATE X-NODEREF hxnWorkRoot IN WIDGET-POOL "soap". /* Walk the SOAP-HEADER's list of header entries, */ /* looking for the "OrderInfoID" header entry */ DEFINE VARIABLE idx AS INTEGER. REPEAT idx = 1 TO hSOAPHeader:NUM-HEADER-ENTRIES: hSOAPHeader:GET-HEADER-ENTRY(hsheEntry, idx). IF hsheEntry:LOCAL-NAME = "OrderInfoID" AND hsheEntry:NAMESPACE-URI = "http://www.example.com/webservices/OrderInfo" THEN DO: /* Get the X-noderef side of the hsheEntry so we can navigate its body. */ hsheEntry:GET-NODE(hxnWorkRoot). hxnWorkRoot:GET-CHILD(hxnTemp, 1). /* hxnTemp is now uuid node */ hxnTemp:GET-CHILD(hxnTemp2,1). /* hxnTemp2 is text node of uuid */ gcUUID = hxnTemp2:NODE-VALUE. /* save the text content */ END. END. /* Delete all objects created in this procedure. */ DELETE WIDGET-POOL "soap". /* Delete the SOAP header freeing all of its memory. */ DELETE OBJECT hSOAPHeader. END PROCEDURE. |