VMware

This Question is Answered

2 "helpful" answers available (6 pts)
5 Replies Last post: Nov 5, 2009 7:00 AM by jrackliffe  

Fully rehydrating a Vimclient from Vim.dll posted: Nov 4, 2009 12:42 PM

Click to view jrackliffe's profile Hot Shot 119 posts since
Mar 10, 2006

Not for Powershell, but the undelrying Vim.dll.

I wish to use this in a web environ and rather than deal with file management nightmares I want to scrape the vmware_soap_session cookie, serialize the value for it, and restore the session from the cookie on the callback rather than relogging in etc.

Well I have the cookie and the reconnect done, but after restoring the Cookie I still have a null ServiceContent. The LoadSession does not have this issue so I imagine there is something I can do to kick the VimClient so it reestablishes the underlying connection. Seems like if I call a GetView for a known entity that can help, but it seems rather brute force. Is there a more elegant way to reestablish the connection after restoring the cookie?

Also, I wish to second the need for a VimClient method for determining if a session is live after restoring. I used to just call CurrentTime on ServiceInstance in the WebServices and capture the exception. The "isSessionActive" in SessionManager needs the username and rather than having to carry that around tooit would be easier to have a bool that used the currentSession data in the cookie. In any case before kicking the VimClient SessionManager is null so its a no go anyways.

J

Re: Fully rehydrating a Vimclient from Vim.dll

1. Nov 4, 2009 11:36 PM in response to: jrackliffe
Click to view harkamal's profile Hot Shot 221 posts since
Mar 19, 2009
Can you not use VimClient.LoadSession to load the cookie?
LoadSession        Method     System.Void LoadSession(String fileName)

Re: Fully rehydrating a Vimclient from Vim.dll

2. Nov 5, 2009 12:49 AM in response to: jrackliffe
Click to view ykalchev's profile Hot Shot 68 posts since
Mar 5, 2008
Hi,
If you don't want to save/restore session cookie to/from file you can directly add VMware session cookie to VimClient.WebService.CookieContainer (actually LoadSession do the same):


Cookie sessionCookie = ....; // Already get vmware_soap_session cookie

VimClient vimClient;
vimClient = new VimClient();
vimClient.Connect(serviceUrl);
vimClient.VimService.CookieContainer.Add(sessionSookie);
SessionManager sessionMngr = 
       new SessionManager(vimClient, vimClient.ServiceContent.SessionManager);
sessionMngr.UpdateViewData();

if (sessionMngr.CurrentSession == null) {
   throw new InvalidOperationException("Fail to reuse session cookie");
}



Regards,
Yasen

Re: Fully rehydrating a Vimclient from Vim.dll

4. Nov 5, 2009 6:42 AM in response to: jrackliffe
Click to view harkamal's profile Hot Shot 221 posts since
Mar 19, 2009
Okay thanks, that helped me understand more. I was also thinking of using Memory stream and then using FileStream for LoadSession.

Good night

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities