Any client application written for the Web Services API must perform certain basic functions. These include making a connection to the server, authenticating and creating a session, and closing the connection.
What to read next
vCenter Server Connections Every vCenter Server client application must connect to the server and pass user account credentials to authenticate to the server. After the connection has been established, the client application can use vSphere services to access the virtual environment.
Establishing a Single Sign-On Session with a vCenter Server vSphere uses single sign-on to provide a single point of authentication for clients. vSphere includes the vCenter Single Sign-On Server. To use vCenter Single Sign-On, your client obtains a SAML token (Security Assertion Markup Language) from the vCenter Single Sign-On Server and passes the token to the vCenter Server in the login request. The token represents the client and contains claims that support client authentication. Components in the vSphere environment perform operations based on the original authentication. For information about obtaining a vCenter Single Sign-On token from the vCenter Single Sign-On Server, see vCenter Single Sign On Programming Guide .
LoginByToken to vCenter Server By Using Java The following example is based on the LoginByTokenSample.java file contained in the vCenter Single Sign On SDK. The SDK contains Java code that supports HTTP and SOAP header manipulation.
Establishing a Session with Username and Password Credentials Although not as secure as LoginByToken , you can specify username and password credentials to establish a session with vCenter Server. Follow these steps:
Overview of a Java Sample Application for the Web Services SDK This section includes an example of a complete client application that demonstrates the basic client capability. The sample client application prints out the product name, server type, and product version to demonstrate that it is connected and able to retrieve information from the server.
Accessing the vSphere Server from a Web Services Client The steps that use the vSphere Web Services API to create the connection are:
Closing the Connection from a Web Services Client Use the VimPort
object again to close the connection. Always close your server connections to maintain security.
Using the Java Samples as Reference The following code fragment from the vSphere Management SDK shows another implementation of the server connection. You can use code similar to this sample in the vSphere Web Services SDK (path below) to get a session token for your client application.
Multiple Versions of the vSphere API When a client application connects to a Web service running on a vSphere server (ESXi or vCenter Server system), the server detects the version of the API that was used to develop the client and makes available only those operations supported by the client.
Java Sample Applications in the Web Services SDK The vSphere Web Services SDK includes sample applications, written in Java, that demonstrate features of the vSphere API and object model. Most of the samples do not handle exceptions, and they accept all security certificates. So use the applications as examples for extracting the types of data you want to view, but do not use the helper classes, trust store methods or exception handling techniques in your production environment.