當連接webservice的客戶端需要代理驗證時的解決方法
try ??????????????????????????? try??????????????????????????? {??????????????????????????????? ProxyAuthenticate proxyAuthenticate = new ProxyAuthenticate(WebProxy.GetDefaultProxy().Address.Host);????//ProxyAuthenticate?為自定義的賬密輸入框??????????????????????????????? if (proxyAuthenticate.ShowDialog() == System.Windows.Forms.DialogResult.OK)??????????????????????????????? {??????????????????????????????????? Authority authority = new Authority();??????????????????????????????????? System.Net.IWebProxy theProxy = System.Net.WebRequest.DefaultWebProxy;??????????????????????????????????? authority.Proxy = theProxy;??????????????????????????????????? authority.Proxy.Credentials = new System.Net.NetworkCredential(proxyAuthenticate.GetUser(),proxyAuthenticate.GetPassword());??????????????????????????????????? xmlNode = authority.GetUserInfoByNameAndSerialnumber(this.CertName,this.SerialNumber);??????????????????????????????????? authority = null;??????????????????????????????????? break;??????????????????????????????? }??????????????????????????? }??????????????????????????? catch (Exception ex)??????????????????????????? {??????????????????????????????? errorMsg = ex.Message;??????????????????????????? }??????????????????????? }??????????????????????? else??????????????????????? {??????????????????????????? throw new Exception(errorMsg);??????????????????????? }??????????????????? }??????????????? } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |