日期:2014-05-17 浏览次数:20550 次
string PingAnResponXml = "";
HttpWebRequest PingAnRequest = null;
HttpWebResponse PingAnResponse = null;
Encoding encodeType = Encoding.GetEncoding("GB2312");
//连接超时后重新建立连接
for (int i = 0; i < 2; i++)
{
try
{
PingAnResponXml = "";
//验证服务器证书回调自动验证
MyPolicy myPolicy = new MyPolicy();
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(myPolicy.AcceptAllCertifications);
//建立连接
PingAnRequest = (HttpWebRequest)WebRequest.Create(Configuration.PingAnServiceUrl);
PingAnRequest.ProtocolVersion = HttpVersion.Version10;
//获取私钥路径
string clientp12path = System.IO.Path.Combine(HttpRuntime.AppDomainAppPath, "App_Data\\EXV_BIS_IFRONT_PCIS_YZJIB_001_STG.pfx");
X509Certificate2 cer = new X509Certificate2(clientp12path, "123456", X509KeyStorageFlags.MachineKeySet);
PingAnRequest.ClientCertificates.Add(cer);
//设置连接超时
&nbs