3.1.4.3 EndSession
Note Abstract data model objects that are referenced in this section are defined in section 3.1.1. SOAP fault processing is specified in section 3.1.4.4.
The server MUST perform an EndSession operation when it receives a DSML SOAP request message that contains an <EndSession> header (section 2.2.2.3).
If the server is not capable of performing an EndSession operation, and if the header contains a soap:mustUnderstand attribute equal to 1, then the server MUST generate a SOAP fault and MUST NOT process any DSML operations that are contained in the SOAP body of the message. Otherwise, if the server is not capable of performing an EndSession operation, and either the header does not contain a soap:mustUnderstand attribute equal to 1 or that attribute is not present, then the server processes the DSML operations as if the <EndSession> header were not specified.
To perform the EndSession operation, the server MUST retrieve the SessionTableEntry from the SessionTable that contains a SessionID with a value that matches the SessionID attribute specified in the <EndSession> header. If the SessionTableEntry is not present, the server MUST return a "Bad Session Request" SOAP fault as specified in section 3.1.4.4.
After the matching SessionTableEntry has been retrieved, the server MUST perform any DSML operations that are contained in the SOAP body of the request message, using the state stored in the SessionTableEntry. DSML operations have the form of a <dsml:batchRequest> element with zero or more child elements. The server SHOULD save any state changes in the Session object of the SessionTableEntry to correlate these operations with future operations.
Once the operations have successfully completed, or if there were no operations to perform, the server MUST remove the SessionTableEntry from the SessionTable. The server MUST generate a DSML response message [DSML2] with a <Session> header (section 2.2.2.2). The SessionID attribute of that <Session> header MUST be assigned the value of the SessionID object of the SessionTableEntry that was removed.
The server MUST dispose of the removed SessionTableEntry, including the state saved in SessionTableEntry.Session. The server MAY<8> wait for some time after it has removed the SessionTableEntry from the SessionTable before disposing of the SessionTableEntry.