/** * Uses the new RetrievePropertiesEx method to emulate the now deprecated RetrieveProperties * method. * * @param listpfs * @return list of object content * @throws Exception */ private static List<ObjectContent> retrievePropertiesAllObjects(List<PropertyFilterSpec> listpfs) throws Exception { RetrieveOptions propObjectRetrieveOpts = new RetrieveOptions(); List<ObjectContent> listobjcontent = new ArrayList<ObjectContent>(); try { RetrieveResult rslts = vimPort.retrievePropertiesEx(propCollectorRef, listpfs, propObjectRetrieveOpts); if (rslts != null && rslts.getObjects() != null && !rslts.getObjects().isEmpty()) { listobjcontent.addAll(rslts.getObjects()); } String token = null; if (rslts != null && rslts.getToken() != null) { token = rslts.getToken(); } while (token != null && !token.isEmpty()) { rslts = vimPort.continueRetrievePropertiesEx(propCollectorRef, token); token = null; if (rslts != null) { token = rslts.getToken(); if (rslts.getObjects() != null && !rslts.getObjects().isEmpty()) { listobjcontent.addAll(rslts.getObjects()); } } } } catch (SOAPFaultException sfe) { printSoapFaultException(sfe); } catch (Exception e) { System.out.println(" : Failed Getting Contents"); e.printStackTrace(); } return listobjcontent; }