public AboutInfo getAboutInfo() { return getServiceContent().getAbout(); }
public String getApiType() { return this.connection.getServiceContent().getAbout().getApiType(); }
public ServiceInstance(URL url, String username, String password, boolean ignoreCert, String namespace) throws RemoteException, MalformedURLException { if(url == null || username==null) { throw new NullPointerException("None of url, username can be null."); } setMOR(SERVICE_INSTANCE_MOR); VimPortType vimService = new VimPortType(url.toString(), ignoreCert); vimService.getWsc().setVimNameSpace(namespace); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); vimService.getWsc().setSoapActionOnApiVersion(serviceContent.getAbout().getApiVersion()); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); //with new SOAP_ACTION setServerConnection(new ServerConnection(url, vimService, this)); UserSession userSession = getSessionManager().login(username, password, null); getServerConnection().setUserSession(userSession); }
public ServiceInstance(URL url, String sessionStr, boolean ignoreCert, String namespace) throws RemoteException, MalformedURLException { if(url == null || sessionStr ==null) { throw new NullPointerException("None of url, session string can be null."); } setMOR(SERVICE_INSTANCE_MOR); VimPortType vimService = new VimPortType(url.toString(), ignoreCert); WSClient wsc = vimService.getWsc(); wsc.setCookie(sessionStr); wsc.setVimNameSpace(namespace); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); wsc.setSoapActionOnApiVersion(serviceContent.getAbout().getApiVersion()); setServerConnection(new ServerConnection(url, vimService, this)); serviceContent = vimService.retrieveServiceContent(SERVICE_INSTANCE_MOR); //with new SOAP_ACTION UserSession userSession = (UserSession) getSessionManager().getCurrentProperty("currentSession"); getServerConnection().setUserSession(userSession); }
@Test public void example() throws InvalidPropertyFaultMsg, RuntimeFaultFaultMsg { BasicConnection conn = new BasicConnection(); String url = System.getProperty("vsphere.url"); String username = System.getProperty("vsphere.username"); String password = System.getProperty("vsphere.password"); conn.setURI(URI.create(url)); conn.setUsername(username); conn.setPassword(password); conn.setIgnoreSslErrors(true); conn.setRequestTimeout(30, TimeUnit.SECONDS); conn.connect(); AboutInfo about = conn.getServiceContent().getAbout(); System.out.println(Utils.toJsonHtml(about)); ManagedObjectReference rootFolder = conn.getServiceContent().getRootFolder(); GetMoRef getMoRef = new GetMoRef(conn); String name = getMoRef.entityProp(rootFolder, "name"); System.out.println("Root folder is called \'" + name + "\'"); } }