In HTML web client plugin, How to get authentication parameters (such as objectId and sessionid) to talk to backend server?

We are migrating to new HTML plugin from "legacy script" plugin using VMware webclient 6.5 SDK. 
We have a back end server that gets installed on a remote Windows server. This backend server uses vi java library to communicate to ESXi hosts to fetch our proprietary information which is not available via the standard SDK APIs.
plugin.xml for our legacy script plugin looked like - 
While loading the plugin, vCentre server makes a Get request using above url along with few additional http params like objectId, serverGuid and sessionId to backend server.
For our new html plugin, we could figure out from wssdk SDK samples on how to retrieve serverGuid, using vi java library. 
Now, how to fetch other two params objectId and sessionid?
We tried below angular snippet to fetch objectId by referring custom-object sample
constructor(private _http: HttpClient,               
              private _route: ActivatedRoute,              
              ) { 
this._webPlatform = window.parent.vSphereClientSDK.getWebPlatformApi(window);
this._objectId = this._route.snapshot.params["objectId"];
objectId is always undefined.
None of the members under UserSession, represent required sessionId.
Any pointers in this regard is greatly appreciated.
0 Kudos
3 Replies
VMware Employee
VMware Employee

Hi Abby,

For objectId you need to use the JS API call WEB_PLATFORM.getObjectId(). See vm-data.js from the WSSDK sample.

For the session info you need to use the Java API:

 - Get the user session from the UserSessionService.

 - Use the "serversInfo" array which contains ServerInfo objects for each of the vCenters in the environment. This object in turn contains the necessary info - sessionKey, sessionCookie, serviceGuid. This also means that you don't need to make a separate vCenter call (via vim25 or vi-java) to fetch the serverGuid.

See DataProviderImpl.getServiceContent again from WSSDK sample to have a look at how this is showcased.

Note: If your plugin is supposed to work only on 6.5 and 6.7 please consider using the new JS APIs () as the Bridge JS APIs have been deprecated and will be removed at some future point when the community is ready for that. If you need to support also 6.0 or earlier you should indeed use the Bridge JS APIs.



0 Kudos

Thanks Valdi, we got both sessionCookie and ObjectId. Appreciate your help.

Now we just need the VCSA IP and port to call our rest API of backend remote server.

Any JS API/SDK API which can get us the VCSA IP and port number?

0 Kudos
VMware Employee
VMware Employee

Hi Abby,

The vCenter API URLs are also available from the UserSession Java API. You can get them from UserSessionService.getUserSession().serversInfo[].serviceUrl. From the URLs you can extract the host and the port.



0 Kudos