To access a vSphere Automation service, you must have a valid session connection. The sequence for accessing a vSphere Automation service includes creating a protocol connection object and using it to create the service stub.

Prerequisites

Establish a connection to the vSphere Automation endpoint URL. For more information about the authentication mechanisms that you can use, see Authentication Mechanisms.

Procedure

  1. Create a protocol factory object.
  2. Create a protocol connection object to access an API provider.

    The vSphere Automation API clients use ApiProvider instances to invoke operations on services running in the virtual environment. To invoke an operation, you must specify the target service and operation, input parameters, and execution context.

  3. Create a StubFactory object by using the ApiProvider instance.
  4. Create a StubConfiguration instance and set the security context to be used for the service stub.
  5. Create the stub for the vSphere Automation service interface by calling the create method of the StubFactory instance. Pass the service class and the StubConfiguration instance as arguments.