1. Problem description:
Widow.location = function() is defined in JS. When the page is closed, the logout() function is not executed.
window.onunload = function() {logout();}function logout(reqParam, callback){var userManageServiceUrl = "http://" + getServerAddr() + "/axis2/services/UserManageService";var urlList = [];var url = window.location.href;urlList = url.split("?");var sessionID = urlList[1];reqParam.sessionID = sessionID;var pl = new SOAPClientParameters();var reqParamStr = JSON.stringify(reqParam);pl.add("reqParam", reqParamStr);SOAPClient.invoke(userManageServiceUrl, "logout", pl, false, callback);}2. Cause of the problem:
The SOAPClient.invoke() method is called in logout(), with the parameter true, which means that the front-end and server communicate in asynchronous manner. That is, the front-end has not received the response from the server side, and the following statement has been executed. In this problem, the front-end has closed the page before the server's response was executed, so it is manifested as the logout() has not been executed.
3. Solution:
Change the communication method between the front-end and server to synchronously, that is, change true in the SOAPClient.invoke() method to false, and the problem has been solved.