ctxt.put(BindingProvider.SESSION_MAINTAIN_PROPERTY, true);
ctxt.put("com.sun.xml.internal.ws.request.timeout", 600000);
ctxt.put("com.sun.xml.internal.ws.connect.timeout", 600000);
ServiceContent serviceContent = vimPort.retrieveServiceContent(SVC_INST_REF);
// Extract a cookie. See vmware sample program com.vmware.httpfileaccess.GetVMFiles
Map<String, List<String>> headers = (Map<String, List<String>>) ((BindingProvider) vimPort)
.getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
List<String> cookies = headers.get("Set-cookie");
String cookieValue = cookies.get(0);
StringTokenizer tokenizer = new StringTokenizer(cookieValue, ";");
cookieValue = tokenizer.nextToken();
String pathData = "$" + tokenizer.nextToken();
serviceCookie = "$Version=\"1\"; " + cookieValue + "; " + pathData;
vimPort.login(serviceContent.getSessionManager(), userName, password, null);
isConnected = true;
propCollectorRef = serviceContent.getPropertyCollector();
}