EDN Admin
Well-known member
Hi ALL,
I am creating an Win32 application for calling web service using WSDL file in which i am getting "The certificate authority is invalid or incorrect" error every time.
I have provided the log in credentials.
Any idea how to resolve this.
Here is the sample code in which i am getting errorint main()
{
HRESULT hr;
WS_ERROR *error;
hr = WsCreateError(NULL, 0, &error);
if (FAILED(hr))
{
PrintError(hr, error);
int a = 0;
return -1;
}
WS_HEAP *heap;
hr = WsCreateHeap(100, 0, NULL, 0, &heap, error);
if (FAILED(hr))
{
PrintError(hr, error);
WsFreeError(error);
return -1;
}
WCHAR* result = new WCHAR[2048];
WCHAR* arg1 = new WCHAR[50];
WCHAR* arg2 = new WCHAR[50];
*wcscpy(arg1, L"arg1Value");
*wcscpy(arg2, L"arg2Value");
BOOL arg3 = TRUE;
WS_SERVICE_PROXY *serviceProxy;
WS_STRING_USERNAME_CREDENTIAL usernameCredential = {}; // zero out the struct
WS_STRING userName = WS_STRING_VALUE(L"username");
WS_STRING passWord = WS_STRING_VALUE(L"password");
usernameCredential.credential.credentialType = WS_STRING_USERNAME_CREDENTIAL_TYPE; // set the credential type
usernameCredential.username = userName;
usernameCredential.password = passWord;
// declare and initialize a username message security binding
WS_USERNAME_MESSAGE_SECURITY_BINDING usernameBinding = {}; // zero out the struct
usernameBinding.binding.bindingType = WS_USERNAME_MESSAGE_SECURITY_BINDING_TYPE; // set the binding type
usernameBinding.bindingUsage = WS_SUPPORTING_MESSAGE_SECURITY_USAGE; // set the binding usage
usernameBinding.clientCredential = &usernameCredential.credential;
// 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
// declare and initialize the array of all security bindings
WS_SECURITY_BINDING* securityBindings[2] = { &sslBinding.binding, &usernameBinding.binding };
// declare and initialize the security description
WS_SECURITY_DESCRIPTION securityDescription = {}; // zero out the struct
securityDescription.securityBindings = securityBindings;
securityDescription.securityBindingCount = WsCountOf(securityBindings);
hr = WsCreateServiceProxy(WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING,
&securityDescription, NULL, 0,
NULL, 0, &serviceProxy, error);
if (FAILED(hr))
{
PrintError(hr, error);
WsFreeHeap(heap);
WsFreeError(error);
return -1;
}
WS_ENDPOINT_ADDRESS address = {};
WS_STRING Url = WS_STRING_VALUE(L"https://demo.myService.url");
address.url = Url;
hr = WsOpenServiceProxy(serviceProxy, &address, NULL, error);
if (FAILED(hr))
{
PrintError(hr, error);
WsFreeServiceProxy(serviceProxy);
WsFreeHeap(heap);
WsFreeError(error);
return -1;
}
hr = RequestForResult(serviceProxy,arg1, arg2, arg3, &result, heap, NULL, NULL, NULL, error);
if (SUCCEEDED(hr))
wprintf(L"Successfully created.... %d", 1);
else
{
PrintError(hr, error);
wprintf(L"Falied.... %d", 0);
}
WsCloseServiceProxy(serviceProxy, NULL, error);
WsFreeServiceProxy(serviceProxy);
getch();
}
Thanks in advance
Regards
Ashish
View the full article
I am creating an Win32 application for calling web service using WSDL file in which i am getting "The certificate authority is invalid or incorrect" error every time.
I have provided the log in credentials.
Any idea how to resolve this.
Here is the sample code in which i am getting errorint main()
{
HRESULT hr;
WS_ERROR *error;
hr = WsCreateError(NULL, 0, &error);
if (FAILED(hr))
{
PrintError(hr, error);
int a = 0;
return -1;
}
WS_HEAP *heap;
hr = WsCreateHeap(100, 0, NULL, 0, &heap, error);
if (FAILED(hr))
{
PrintError(hr, error);
WsFreeError(error);
return -1;
}
WCHAR* result = new WCHAR[2048];
WCHAR* arg1 = new WCHAR[50];
WCHAR* arg2 = new WCHAR[50];
*wcscpy(arg1, L"arg1Value");
*wcscpy(arg2, L"arg2Value");
BOOL arg3 = TRUE;
WS_SERVICE_PROXY *serviceProxy;
WS_STRING_USERNAME_CREDENTIAL usernameCredential = {}; // zero out the struct
WS_STRING userName = WS_STRING_VALUE(L"username");
WS_STRING passWord = WS_STRING_VALUE(L"password");
usernameCredential.credential.credentialType = WS_STRING_USERNAME_CREDENTIAL_TYPE; // set the credential type
usernameCredential.username = userName;
usernameCredential.password = passWord;
// declare and initialize a username message security binding
WS_USERNAME_MESSAGE_SECURITY_BINDING usernameBinding = {}; // zero out the struct
usernameBinding.binding.bindingType = WS_USERNAME_MESSAGE_SECURITY_BINDING_TYPE; // set the binding type
usernameBinding.bindingUsage = WS_SUPPORTING_MESSAGE_SECURITY_USAGE; // set the binding usage
usernameBinding.clientCredential = &usernameCredential.credential;
// 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
// declare and initialize the array of all security bindings
WS_SECURITY_BINDING* securityBindings[2] = { &sslBinding.binding, &usernameBinding.binding };
// declare and initialize the security description
WS_SECURITY_DESCRIPTION securityDescription = {}; // zero out the struct
securityDescription.securityBindings = securityBindings;
securityDescription.securityBindingCount = WsCountOf(securityBindings);
hr = WsCreateServiceProxy(WS_CHANNEL_TYPE_REQUEST, WS_HTTP_CHANNEL_BINDING,
&securityDescription, NULL, 0,
NULL, 0, &serviceProxy, error);
if (FAILED(hr))
{
PrintError(hr, error);
WsFreeHeap(heap);
WsFreeError(error);
return -1;
}
WS_ENDPOINT_ADDRESS address = {};
WS_STRING Url = WS_STRING_VALUE(L"https://demo.myService.url");
address.url = Url;
hr = WsOpenServiceProxy(serviceProxy, &address, NULL, error);
if (FAILED(hr))
{
PrintError(hr, error);
WsFreeServiceProxy(serviceProxy);
WsFreeHeap(heap);
WsFreeError(error);
return -1;
}
hr = RequestForResult(serviceProxy,arg1, arg2, arg3, &result, heap, NULL, NULL, NULL, error);
if (SUCCEEDED(hr))
wprintf(L"Successfully created.... %d", 1);
else
{
PrintError(hr, error);
wprintf(L"Falied.... %d", 0);
}
WsCloseServiceProxy(serviceProxy, NULL, error);
WsFreeServiceProxy(serviceProxy);
getch();
}
Thanks in advance
Regards
Ashish
View the full article