Can not connect to SSL web service from windows mobile.
-
Hi Friends, I am developing a Windows Mobile application using 6.0 professional SDK. Here I am consuming a web service which is hosted on HTTPS. I am able to add the web reference successfully but when I call a method of the service using proxy it throws following exception. "Could not establish trust relationship with remote server." The same scenario works fine if I test it with a desktop windows application. I am able to call the method successfully and I receive the response too, but I dont know why it is not working with Windows Mobile. I am able to browse the websites from the mobile browser so there is no issue about the connection. Please help me soon friends I m running out of time...I have search all over the world during last 2 days but could not find any satisfactory and working solution. Thank you all in advance.
Thanks and Regards, Chetan Ranpariya
-
Hi Friends, I am developing a Windows Mobile application using 6.0 professional SDK. Here I am consuming a web service which is hosted on HTTPS. I am able to add the web reference successfully but when I call a method of the service using proxy it throws following exception. "Could not establish trust relationship with remote server." The same scenario works fine if I test it with a desktop windows application. I am able to call the method successfully and I receive the response too, but I dont know why it is not working with Windows Mobile. I am able to browse the websites from the mobile browser so there is no issue about the connection. Please help me soon friends I m running out of time...I have search all over the world during last 2 days but could not find any satisfactory and working solution. Thank you all in advance.
Thanks and Regards, Chetan Ranpariya
-
Hi Joel, Thanks for the reply. I tried the tip you mentioned. I am currently running the application on device emulators. I changed the date time information of the emulator to my system date time but it didn't work. The web service I m consuming is in different timezone, and I tried to change the emulator datetime information to that timezone too, but that also didn't help me. I event asked the service providers but according to them there is nothing changed from their side except the service url which I am currently using. If I refer the same service url in a windows desktop application, everything works fine. I am really stuck. Please help me.
Thanks and Regards, Chetan Ranpariya
-
Hi Friends, I am developing a Windows Mobile application using 6.0 professional SDK. Here I am consuming a web service which is hosted on HTTPS. I am able to add the web reference successfully but when I call a method of the service using proxy it throws following exception. "Could not establish trust relationship with remote server." The same scenario works fine if I test it with a desktop windows application. I am able to call the method successfully and I receive the response too, but I dont know why it is not working with Windows Mobile. I am able to browse the websites from the mobile browser so there is no issue about the connection. Please help me soon friends I m running out of time...I have search all over the world during last 2 days but could not find any satisfactory and working solution. Thank you all in advance.
Thanks and Regards, Chetan Ranpariya
Hi friends, Finally I found the solution of this problem. I had to create a class which implemented ICertificatePolicy interface as following.
public class AlwaysTrustedCertificatePolicy : ICertificatePolicy
{
#region ICertificatePolicy Members
public bool CheckValidationResult(ServicePoint srvPoint,
System.Security.Cryptography.X509Certificates.X509Certificate certificate,
WebRequest request,
int certificateProblem)
{
return true;
}
#endregion
}And before calling the first ever method of service I created an instance of this class and assign it to "CertificatePolicy" of "ServicePointManager" class.
ICertificatePolicy certificatePolicy = new new AlwaysTrustedCertificatePolicy();
ServicePointManager.CertificatePolicy = certificatePolicy;
var serviceClient = new ServiceClient();
serviceClient.Login(username, password);
This worked for me very well... but this is I guess work around not the proper solution. If any body finds the solution please post.
Thanks and Regards, Chetan Ranpariya
-
Dude! I tried this (setting the correct date/time) out of desperation after continually having a "Could not establish trust relationship with remote server" error message and it flippin' worked. Thanks for the tip--why can't these error messages give a little more information????