[英]httpwebrequest.getResponse timesout in webservice
Q1: Any idea why the below webservice never returns from req.getResponse() and gives timeout error. Q1:为什么下面的Web服务永远不会从req.getResponse()返回并给出超时错误的任何想法。
The webservice creates the httpwebrequest object on behalf of the user and waits for the callback thread to provide the certificate, and then returns the result. Web服务代表用户创建httpwebrequest对象,并等待回调线程提供证书,然后返回结果。
Any thing I may be missing here?( may be some persmission on the test server etc). 我在这里可能会缺少任何东西吗?(可能是对测试服务器的许可等)。 ( note that I have used httpwebrequest+callback before outside webservice without any problem)
(请注意,我在外部网络服务之前使用了httpwebrequest + callback没问题)
Q2: Is there a syncrhonous way of retrieving cert from httpsserver rather getting in callback? Q2:是否有一种从httpsserver检索证书而不是进入回调的同步方法?
[WebService(Namespace = "http://testserver")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
// [System.Web.Script.Services.ScriptService]
public class main : System.Web.Services.WebService
{
static main pointer;
private static bool ValidateRemoteCertificate(
object sender,
X509Certificate certificate,
X509Chain chain,
SslPolicyErrors policyErrors
)
{
X509Certificate2 cert = new X509Certificate2(certificate);
HttpWebRequest wbr= (HttpWebRequest)sender;
pointer.Application[wbr.RequestUri.ToString()] = cert.Thumbprint;
return true;
}
public main()
{
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateRemoteCertificate);
pointer = this;
}
[WebMethod]
public string verifyCertificate(string thumb, string sslsite)
{
string result = "";
try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sslsite);
pointer.Application[req.RequestUri.ToString()] = null;
req.GetResponse();
/* while (Application[req.RequestUri.ToString()] == null)
{
Thread.CurrentThread.Join(1000);
}
*/
result = (string)Application[req.RequestUri.ToString()];
}
catch (Exception e)
{
result = e.ToString();
}
return result;
}
}
It turned out that I was missing the proxy setting in the request object. 原来,我在请求对象中缺少代理设置。 Once I enable it , it work
一旦启用它,它就可以工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.