I have a question about the vSphere Management SDK.
When connecting to a VMware environment using vSphere Management SDK 8.0, it took approximately 30 seconds to establish a connection.
Using the sample source code from vSphere Management SDK 7.0, the process took no time at all.
The language I am using is C#.
For vSphere Management SDK 7.0, the sample source code in C# is published.
Therefore, I am using it for connection tests.
For vSphere Management SDK 8.0, there is no C# sample source code published.
Instead, wsdl files are provided.
I generate a DLL from the wsdl file and conduct connection tests following the same procedure as SDK 7.0.
Upon examining the details, it seemed that the Connect() method was taking a long time.
The processing time of the API within the Connect() method has been measured, and I have attached the results.
* Questions
What could be the cause of the delay in establishing communication?
Is there a way to speed it up to the same level as SDK 7.0?
* Measurement Results
- SDK 7.0
new ChannelFactory():0.257s
CreateChannel():0.256s
RetrieveServiceContent():0.256s
- SDK 8.0
new ChannelFactory():2.422s
CreateChannel():13.405s
RetrieveServiceContent():12.924s
* source codes
public void Connect(string url, string username, string password)
{
if (_service != null)
{
Disconnect();
}
_service = GetVimService(url, username, password);
_sic = _service.RetrieveServiceContent(_svcRef); //*******Measurement target*******
if (_sic.sessionManager != null)
{
Console.WriteLine("Login start : " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
_service.Login(_sic.sessionManager, username, password, null);
Console.WriteLine("Login end : " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
}
_state = ConnectionState.Connected;
if (AfterConnect != null)
{
AfterConnect(this, new ConnectionEventArgs());
}
}
private static VimPortType GetVimService(
string url, string username = null, string password = null,
X509Certificate2 signingCertificate = null, XmlElement rawToken = null)
{
var binding = SamlTokenHelper.GetWcfBinding();
var address = new EndpointAddress(url);
var factory = new ChannelFactory<VimPortType>(binding, address); //*******Measurement target*******
// Attach the behaviour that handles the WS-Tust 1.4 protocol for VMware Vim Service
factory.Endpoint.Behaviors.Add(new WsTrustBehavior(rawToken));
factory.Credentials.UserName.UserName = username;
factory.Credentials.UserName.Password = password;
factory.Credentials.ClientCertificate.Certificate = signingCertificate;
factory.Credentials.SupportInteractive = false;
SamlTokenHelper.SetCredentials(username, password, signingCertificate, factory.Credentials);
var service = factory.CreateChannel(); //*******Measurement target*******
return service;
}