Saving the vCenter Server
Session CookieLast Updated December 19, 2024
The code fragment in this section
establishes an HTTP session with the
instance and saves the HTTP session cookie.
The following sequence describes these steps and
shows the corresponding objects and methods.
Use the
getHandlerResolver
method to save the default message handler. To use the HTTP and SOAP message
handlers, you must first save the default message handler so that you can
restore it after login. The HTTP and SOAP message handlers impose overhead that
is unnecessary after login.
| VimService.getHandlerResolver( )
|
Set the cookie handler.
The
HeaderCookieExtractionHandler method retrieves
the HTTP cookie.
| ![]() |
Get the VIM port. The VIM
port provides access to the vSphere API methods, including the
LoginByToken method.
| ![]() |
Set the request context
endpoint address to the vCenter Server URL.
| ![]() |
Retrieve the
ServiceContent . This
method establishes the HTTP connection and sets the session cookie.
| ![]() |
Extract the cookie and
save it for later use.
| HeaderCookieExtractionHandler.getCookie
( )
|
The following example shows Java code that saves
the session cookie.
Saving the vCenter Server Session
Cookie