Request header handler for reusing and modifying a header
- Last Updated: January 16, 2024
- 2 minute read
- OpenEdge
- Version 12.8
- Documentation
This is the SOAP request header handler (ReqHandler) that reuses the initial
SOAP response header and adds a Password value to the existing
AuthHead header entry to pass along with the AccessID
value between the client and Web service:
Request header handler modifying a saved SOAP response header
|
The code in the preceding example:
- Sends the SOAP request header for the
HelloWorldandHelloSecureWorldrequests (and any request run after runningOpenAccess). - Tests if the global header handle (
g_header) references a valid object, and:- If it does not reference an object, the request handler must be
running as part of the initial call to
OpenAccessand sets the output parameters to ensure that no initial SOAP request header is sent - If it does reference an object, the handler passes the global header
object as output using the request header parameter (
hHeader) and ensures that the object is not deleted (saving it for use in any further request)
- If it does not reference an object, the request handler must be
running as part of the initial call to
- Tests if a password has been specified for the current Web service
request, indicated by any
cPasswordvalue that is not theUnknown value (?). If the current Web service request is nonsecure (as with theHelloWorldoperation), all work has been done and the request handler can end. If the current Web service request is secure (as with theHelloSecureWorldoperation), the request handler adds the password information to the SOAP request header, as follows:Note: After the first secure request, all future requests (secure or nonsecure) send a request header that includes password information because the password information is never deleted until replaced by a newly-specified password.- Creates the XML x-document and x-noderef objects to manipulate the SOAP header
- Creates the SOAP header entryref object (
hHeaderEntryref) to access SOAP header entries and defines the namespace (ClientNS) used for defining the SOAP header entry for this request - Returns the existing header entry from the saved global SOAP header
object using the
GET-HEADER-ENTRY( )method on the SOAP header object and accesses the XML root node of the entry using theGET-NODE( )method on the SOAP header entryref objectNote: The handler is adding the password information to an existing SOAP header entry. If it was adding a new header entry to hold the information, it would invoke theADD-HEADER-ENTRY( )method to add the header entry to contain the new XML for it. - Imports the header entry root node into an x-document object in order to access and modify the XML for the header entry, and also deletes any password data from a previous secure request before adding the currently-specified password data
- Adds the
<Password>element as a sibling of the<AccessID>element - Adds the
<Password>element value - Replaces the entire existing header entry in the global SOAP header object with the header entry updated in the x-document object
- Sets the password value (
cPassword) to unknown (?), which retains the current password in the header entry until it is explicitly changed incPassword, then deletes all of the helper XML and SOAP header entryref objects created in the header handler