HTTP and SOAP Header
Handlers
To use a vCenter Single Sign-On token to
login to a
vCenter Server
instance, the example uses header handlers to manipulates the HTTP and SOAP
header elements of the login request.
After establishing a handler, subsequent requests
automatically invoke the handler.
- An extraction handler obtains the HTTP session cookie provided by thevCenter Serverinstance. After setting up the handler, a call to theRetrieveServiceContentmethod will invoke the handler to extract the cookie from the Server response.
- Insertion handlers put the vCenter Single Sign-On token and a timestamp into the SOAP header and the session cookie into the HTTP header of the login request.
The following figure shows the use of handlers to
manipulate header elements when establishing a vCenter Single Sign-On session
with a
vCenter Server
instance.
Starting a vCenter
Session

Every call to the
vCenter Server
instance will invoke any message handlers that have been established. The
overhead involved in using the SOAP and HTTP message handlers is not necessary
after the session has been established. The example saves the default message
handler before setting up the SOAP and HTTP handlers. After establishing the
session, the example will reset the handler chain and restore the default
handler.
The example code also uses multiple calls to the
VimPortType.getVimPort method
to manage the request context. The
getVimPort
method clears the
HTTP request context. After each call to the
getVimPort
method, the client
resets the request context endpoint address to the
vCenter Server
URL. After the client has obtained the session cookie, it will restore the
cookie in subsequent requests.