I have the following function to call net service in .NET 1.1 version.
It works great. System.Net.ServicePointManager.CertificatePolicy is
obsolete and it's suggested to use ServerCertificateValidationCallback
instead in .NET 2.0. I have tried to convert this code into .NET 2.0
version but no success. Could anyone please help me out? thanks,
public static Request GetData(string s1, string s2)
{
RequestService nws = new RequestService();
System.Net.ServicePointManager.CertificatePolicy = new
TrustAllCertificatePolicy();
Request a = new Request();
RequestPub b = new RequestPub();
a.mrn = int.Parse(s1);
a.epi= short.Parse(s2);
a.tatus = 0;
try
{
System.Net.CredentialCache cache = new
System.Net.CredentialCache();
cache.Add(new Uri(nws.Url), "Basic", new
System.Net.NetworkCredential("****", "****"));
nws.Credentials = cache;
b = nws.CreateRequestPub(a);
return b;
}
catch (Exception ex)
{
}
finally
{
}
return b;
}
public class TrustAllCertificatePolicy :
System.Net.ICertificatePolicy
{
public TrustAllCertificatePolicy()
{ }
public bool CheckValidationResult(ServicePoint sp,
X509Certificate cert, WebRequest req, int problem)
{
return true;
}
}