我限制了应用程序中用户最多两次并发登录。我想在soap webservice请求之后终止会话,但我的会话没有终止。 我尝试了不同的方法,但没有取得任何成功。
我应该如何设置keep alive标头,以便在Web服务调用之后会话结束。
public class CallDropIncidentDataClient {
private static com.hp.schemas.sm._7.CallDropIncidentManagement getPaymentServicePort() {
URL url = null;
try {
url = new URL(AppConfig.getProperty("Wsdl_CDIncidenManagement_Url"));
} catch (MalformedURLException ex) {
}
QName qName = new QName(AppConfig.getProperty("Wsdl_CDIncidenManagement_Namespace"), AppConfig.getProperty("Wsdl_CDIncidenManagement_Name"));
com.hp.schemas.sm._7.CallDropIncidentManagement_Service service = new com.hp.schemas.sm._7.CallDropIncidentManagement_Service(url, qName);
com.hp.schemas.sm._7.CallDropIncidentManagement port = service.getCallDropIncidentManagement();
// Map<String, Object> req_ctx = ((BindingProvider) port).getRequestContext();
// req_ctx.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, AppConfig.getProperty("Wsdl_CDIncidenManagement_Url"));
//req_ctx.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, false);
// Map<String, List<String>> headers = new HashMap<String, List<String>>();
Map<String, List<String>> headers = new HashMap<String, List<String>>();// ((BindingProvider) port).getRequestContext();
// headers.put("username", "xx");
// headers.put("password", "xxxx");
headers.put("Connection", Collections.singletonList("Keep-Alive"));
headers.put("keep-alive", Collections.singletonList("timeout=1000"));
//
//System.getProperties().put("http.keepalive", "false");
//String requestTimeout = "1000";
BindingProvider prov = (BindingProvider)port;
prov.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "xx");
prov.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "xxx");
prov.getRequestContext().put(BindingProviderProperties.REQUEST_TIMEOUT, 2000);
// prov.getRequestContext().put("com.sun.xml.ws.request.timeout", requestTimeout);
prov.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, headers);
prov.getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY, Boolean.FALSE);
prov.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, AppConfig.getProperty("Wsdl_CDIncidenManagement_Url"));
return port;
}
public static CloseCallDropIncidentResponse closeCallDropIncident(com.hp.schemas.sm._7.CloseCallDropIncidentRequest closeCallDropIncidentRequest) {
com.hp.schemas.sm._7.CallDropIncidentManagement port = getPaymentServicePort();
return port.closeCallDropIncident(closeCallDropIncidentRequest);
}
public static CreateCallDropIncidentResponse createCallDropIncident(com.hp.schemas.sm._7.CreateCallDropIncidentRequest createCallDropIncidentRequest) {
com.hp.schemas.sm._7.CallDropIncidentManagement port = getPaymentServicePort();
return port.createCallDropIncident(createCallDropIncidentRequest);
}
public static RetrieveCallDropIncidentResponse retrieveCallDropIncident(com.hp.schemas.sm._7.RetrieveCallDropIncidentRequest retrieveCallDropIncidentRequest) {
com.hp.schemas.sm._7.CallDropIncidentManagement port = getPaymentServicePort();
return port.retrieveCallDropIncident(retrieveCallDropIncidentRequest);
}
public static RetrieveCallDropIncidentKeysListResponse retrieveCallDropIncidentKeysList(com.hp.schemas.sm._7.RetrieveCallDropIncidentKeysListRequest retrieveCallDropIncidentKeysListRequest) {
com.hp.schemas.sm._7.CallDropIncidentManagement port = getPaymentServicePort();
return port.retrieveCallDropIncidentKeysList(retrieveCallDropIncidentKeysListRequest);
}
public static RetrieveCallDropIncidentListResponse retrieveCallDropIncidentList(com.hp.schemas.sm._7.RetrieveCallDropIncidentListRequest retrieveCallDropIncidentListRequest) {
com.hp.schemas.sm._7.CallDropIncidentManagement port = getPaymentServicePort();
return port.retrieveCallDropIncidentList(retrieveCallDropIncidentListRequest);
}
public static UpdateCallDropIncidentResponse updateCallDropIncident(com.hp.schemas.sm._7.UpdateCallDropIncidentRequest updateCallDropIncidentRequest) {
com.hp.schemas.sm._7.CallDropIncidentManagement port = getPaymentServicePort();
return port.updateCallDropIncident(updateCallDropIncidentRequest);
}
}