Java 类com.vmware.vim25.ws.WSClient 实例源码

项目:vmwareConDiag    文件:ViJavaConnectTest.java   
/**
 * Sets the timeout for server connections.
 *
 * @param timeout the timeout to be used for connecting
 * @return true, if the operation was successful
 */
public boolean setTimeout(int timeout) {
    if (serviceInstance != null) {
        ServerConnection serverConnection = serviceInstance.getServerConnection();
        if (serverConnection != null) {
            VimPortType vimService = serverConnection.getVimService();
            if (vimService != null) {
                WSClient wsClient = vimService.getWsc();
                if (wsClient != null) {
                    wsClient.setConnectTimeout(timeout);
                    wsClient.setReadTimeout(timeout);
                    return true;
                }
            }
        }
    }
    return false;
}
项目:vijava    文件:ServiceInstance.java   
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);
}
项目:opennmszh    文件:VmwareViJavaAccess.java   
/**
 * Sets the timeout for server connections.
 *
 * @param timeout the timeout to be used for connecting
 * @return true, if the operation was successful
 */
public boolean setTimeout(int timeout) {
    if (m_serviceInstance != null) {
        ServerConnection serverConnection = m_serviceInstance.getServerConnection();
        if (serverConnection != null) {
            VimPortType vimService = serverConnection.getVimService();
            if (vimService != null) {
                WSClient wsClient = vimService.getWsc();
                if (wsClient != null) {
                    wsClient.setConnectTimeout(timeout);
                    wsClient.setReadTimeout(timeout);
                    return true;
                }
            }
        }
    }
    return false;
}
项目:jcloud-vsphere    文件:VSphereLocationSupplierTest.java   
@Test
public void vSphereLocationSupplierTest() throws IOException {
   ServerConnection serverConnection = PowerMock.createMock(ServerConnection.class);
   WSClient wsClient = PowerMock.createMock(WSClient.class);
   ManagedObjectReference managedObjectReference = PowerMock.createMock(ManagedObjectReference.class);
   ServiceInstance serviceInstance = PowerMock.createMock(ServiceInstance.class);
   CreateAndConnectVSphereClient supplier = PowerMock.createMock(CreateAndConnectVSphereClient.class);
   VSphereServiceInstance vSphereServiceInstance = PowerMock.createMock(VSphereServiceInstance.class);
   Folder rootFolder = PowerMock.createMock(Folder.class);

   expect(supplier.get()).andReturn(vSphereServiceInstance);

   expect(vSphereServiceInstance.getInstance()).andReturn(serviceInstance);

   expect(serviceInstance.getRootFolder()).andReturn(rootFolder);

   expect(rootFolder.getServerConnection()).andReturn(serverConnection).anyTimes();
   expect(rootFolder.getMOR()).andReturn(managedObjectReference);
   expect(serverConnection.getServiceInstance()).andReturn(serviceInstance).anyTimes();
   expect(serverConnection.getVimService()).andReturn(new VimPortType(wsClient)).anyTimes();
   AboutInfo aboutInfo = new AboutInfo();
   aboutInfo.setApiVersion("5.1");
   expect(serviceInstance.getPropertyCollector()).andReturn(new PropertyCollector(serverConnection, managedObjectReference));
   expect(serviceInstance.getAboutInfo()).andReturn(aboutInfo);
   vSphereServiceInstance.close();
   replay(supplier, vSphereServiceInstance, serviceInstance, rootFolder, serverConnection);


   VSphereLocationSupplier vSphereLocationSupplier = new VSphereLocationSupplier(supplier);
   Set<? extends Location> location = vSphereLocationSupplier.get();

   Assert.assertEquals(1, location.size());
   for (Location l : location) {
      Assert.assertEquals("default", l.getId());
   }


   verify(supplier, vSphereServiceInstance, serviceInstance, rootFolder, serverConnection);
}
项目:vijava    文件:VimPortType.java   
public VimPortType(WSClient url) throws java.net.MalformedURLException
{
  super(url);
}
项目:vijava    文件:ServerConnection.java   
/**
 * @return the current session string in format like:
 * vmware_soap_session="B3240D15-34DF-4BB8-B902-A844FDF42E85"
 */
public String getSessionStr()
{
    WSClient wsc = vimService.getWsc();
    return wsc.getCookie();
}