下面的代码将在一个线程中执行. 现在问题是当调用本机的webservice时,不会出现错误,但调用其它机器上的webservice时有时出现"操作超时"错误.,而且每调用成功2次后必定会出现该错误4次,好像是1:2的频率出现.
public override bool Execute()
{
try
{
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(m;
req.ContentType = "text/xml";
req.Accept = "text/xml";
req.Method = "POST";
StringBuilder strBld = new StringBuilder(); //"<?xml version=/"1.0/" encoding=/"utf-8/"?>"
strBld.Append("<soap12:Envelope xmlns:xsi=/"http://www.w3.org/2001/XMLSchema-instance/" xmlns:xsd=/"http://www.w3.org/2001/XMLSchema/" xmlns:soap12=/"http://www.w3.org/2003/05/soap-envelope/">");
strBld.Append("<soap12:Body>");
strBld.AppendFormat("<HelloWorld xmlns=http://www.abc.com/>");
strBld.Append("</soap12:Body>");
strBld.Append("</soap12:Envelope>");
Stream stream = req.GetRequestStream(); //这里有时出现"操作超时"
stream.Write(System.Text.ASCIIEncoding.ASCII.GetBytes(strBld.ToString()),strBld.Length);
stream.Close();
HttpWebResponse response = (HttpWebResponse)req.GetResponse();
if (response.StatusCode == HttpStatusCode.OK)
{
return true;
}
else
{
this.LastError = "服务器段错误代码:" + response.StatusCode.ToString();
return false;
}
}
catch (Exception e)
{
this.LastError = "执行出错:" + e.Message;
return false;
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。