Quantcast
Channel: VMware Communities : All Content - vSphere Management SDK
Viewing all articles
Browse latest Browse all 1860

vSphere Server error: 0x803d0000 : The input data was not in the expected format or did not have the expected value.

$
0
0

Hi,

 

I am trying to connect esxi server using WWSAPI.

 

Generated the client side proxy stubs using WsUtil.exe comes with Microsoft SDK.

 

After setting all the things, when I call proxy stub for CurrentTime/Login (Tried with these two), it returns me with the below error:

0x803d0000 : The input data was not in the expected format or did not have the expected value.

 

Could any one please let me know how to resolve this issue?

 

also any one please suggest me on how to specify the managed object reference type and value attributes for vSphere APIs?

 

Below is the code which I tried:

 

HRESULT             hr  = NOERROR;
WS_ERROR        *   error   = NULL;
WS_HEAP         *   heap= NULL;
WS_SERVICE_PROXY*   proxy   = NULL;

 

// declare and initialize a Windows credential
WS_STRING_WINDOWS_INTEGRATED_AUTH_CREDENTIAL windowsCredential = {}; // zero out the struct

 

windowsCredential.credential.credentialType = WS_STRING_WINDOWS_INTEGRATED_AUTH_CREDENTIAL_TYPE; // set the credential type

 

// for illustration only; usernames and passwords should never be included in source files
windowsCredential.username.chars    = L"root";
windowsCredential.username.length   = (ULONG)wcslen(windowsCredential.username.chars);
windowsCredential.password.chars    = L"hvecu_12";
windowsCredential.password.length   = (ULONG)wcslen(windowsCredential.password.chars);

 

// declare and initialize properties to set the authentication scheme to Basic
ULONG scheme = WS_HTTP_HEADER_AUTH_SCHEME_BASIC;

 

WS_SECURITY_BINDING_PROPERTY httpAuthBindingProperties[1] =
{
    { WS_SECURITY_BINDING_PROPERTY_HTTP_HEADER_AUTH_SCHEME, &scheme, sizeof(scheme) }
};

 

/*WS_SECURITY_BINDING_PROPERTY_HTTP_HEADER_AUTH_SCHEME*/
// declare and initialize an HTTP header authentication security binding
WS_HTTP_HEADER_AUTH_SECURITY_BINDING httpAuthBinding = {}; // zero out the struct

 

httpAuthBinding.binding.bindingType = WS_HTTP_HEADER_AUTH_SECURITY_BINDING_TYPE; // set the binding type
httpAuthBinding.binding.properties  = httpAuthBindingProperties;
httpAuthBinding.binding.propertyCount   = WsCountOf(httpAuthBindingProperties);
httpAuthBinding.clientCredential    = &windowsCredential.credential;

 

DWORD dwIgnoreCnCertValue = WS_CERT_FAILURE_CN_MISMATCH | WS_CERT_FAILURE_UNTRUSTED_ROOT | WS_CERT_FAILURE_WRONG_USAGE | WS_CERT_FAILURE_REVOCATION_OFFLINE;

   

WS_SECURITY_BINDING_PROPERTY securityBindingPropertiesArray[1];

 

securityBindingPropertiesArray[0].id    = WS_SECURITY_BINDING_PROPERTY_CERT_FAILURES_TO_IGNORE;
securityBindingPropertiesArray[0].valueSize = sizeof(dwIgnoreCnCertValue);
securityBindingPropertiesArray[0].value = &dwIgnoreCnCertValue;

 

// declare and initialize an SSL transport security binding
WS_SSL_TRANSPORT_SECURITY_BINDING sslBinding = {}; // zero out the struct

 

sslBinding.binding.bindingType  = WS_SSL_TRANSPORT_SECURITY_BINDING_TYPE; // set the binding type
sslBinding.binding.properties   = securityBindingPropertiesArray;
sslBinding.binding.propertyCount= 1;

 

// declare and initialize the array of all security bindings
WS_SECURITY_BINDING* securityBindings[2] = { &sslBinding.binding, &httpAuthBinding.binding };

 

//- We also have to use SOAP 1.1

   /* WS_ENVELOPE_VERSION soapVersion = WS_ENVELOPE_VERSION_SOAP_1_1;

WS_ADDRESSING_VERSION addressingVersion = WS_ADDRESSING_VERSION_TRANSPORT;*/

 

WS_CHANNEL_PROPERTY channelProperties[2];
ULONG           channelPropertyCount        = 0;
WS_ADDRESSING_VERSION addressingVersion         = WS_ADDRESSING_VERSION_TRANSPORT;

 

WS_ENVELOPE_VERSION soapVersion                 = WS_ENVELOPE_VERSION_SOAP_1_1;
channelProperties[channelPropertyCount].id      = WS_CHANNEL_PROPERTY_ENVELOPE_VERSION;
channelProperties[channelPropertyCount].value   = &soapVersion;
channelProperties[channelPropertyCount].valueSize   = sizeof(soapVersion);
channelPropertyCount++;

 

channelProperties[channelPropertyCount].id      = WS_CHANNEL_PROPERTY_ADDRESSING_VERSION;
channelProperties[channelPropertyCount].value   = &addressingVersion;
channelProperties[channelPropertyCount].valueSize   = sizeof(addressingVersion);
channelPropertyCount++;

 

/*WS_CHANNEL_PROPERTY channelProperties[] = {
    { WS_CHANNEL_PROPERTY_ENVELOPE_VERSION, &soapVersion, sizeof(soapVersion) },
    { WS_CHANNEL_PROPERTY_ADDRESSING_VERSION, &addressingVersion, sizeof(addressingVersion) } };*/

 

// declare and initialize the security description
WS_SECURITY_DESCRIPTION securityDescription = {}; // zero out the struct
securityDescription.securityBindings    = securityBindings;
securityDescription.securityBindingCount= WsCountOf(securityBindings);

 

int                 result      = 0;
WS_ENDPOINT_ADDRESS address     = {};
WS_STRING           url         = WS_STRING_VALUE(_T("https://10.165.7.196/sdk/vimService"));
                        address.url = url;

 

// Create an error object for storing rich error information
hr = WsCreateError(
                    NULL,
                    0,
                    &error
                  );
if (FAILED(hr))
{
    goto Exit;
}

 

// Create a heap to store deserialized data
hr = WsCreateHeap(
                    /*maxSize*/ 2048,
                    /*trimSize*/ 512,
                    NULL,
                    0,
                    &heap,
                    error
                 );
if (FAILED(hr))
{
    goto Exit;
}

 

// Create the proxy
hr = WsCreateServiceProxy(
                            WS_CHANNEL_TYPE_REQUEST,
                            WS_HTTP_CHANNEL_BINDING,
                            &securityDescription,
                            NULL,
                            0,
                            channelProperties,
                            channelPropertyCount,
                            &proxy,
                            error
                         );
if (FAILED(hr))
{
    goto Exit;
}

 

hr = WsOpenServiceProxy(
                        proxy,
                        &address,
                        NULL,
                        error
                       );
if (FAILED(hr))
{
    goto Exit;
}

 

 

 

mor.type   = _T("SessionManager");
mor._value = _T("SessionManager");

 

UserSession * userSession;

   

hr = VimBinding_Login(
                        proxy,
                        &mor,
                        L"root",
                        L"hvecu_12",
                        NULL,
                        &userSession,
                        heap,
                        NULL,
                        NULL,
                        NULL,
                        error
                     );

   

WS_DATETIME serverDate;

 

hr = VimBinding_CurrentTime(
                            proxy,
                            &mor,
                            &serverDate,
                            heap,
                            NULL,
                            NULL,
                            NULL,
                            error
                          );

 

Thanks,

Bhargava


Viewing all articles
Browse latest Browse all 1860

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>