HTTP and SOAP Header
Handlers in Java
To use a vCenter Single Sign-On token to
login to a vCenter server, 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.
- Insertion handlers put the vCenter Single Sign On token and a timestamp into the SOAP header into the HTTP header of the login request.
- An extraction handler obtains the HTTP session cookie provided by the vCenter Server. After setting up the handler, a call to theLoginByTokenmethod will invoke the handler to extract the cookie from the Server response.
The following figure shows the use of handlers to
manipulate header elements when establishing a vCenter Single Sign On session
with a vCenter Server.
Starting a vCenter
Session

Every call to the vCenter
Server 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.