0
現在我嘗試從Windows服務調用本地服務器的Web服務,但我有錯誤 錯誤是「請求被中止:請求被取消。」 我的代碼是請求被中止:請求被取消
try {
XmlDocument soapEnvelopeXml = new XmlDocument();
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("xx.asmx");
request.UserAgent = "Mozilla/5.0";
request.Host = "server";
request.ContentType = "text/xml; charset=utf-8";
request.Headers.Add("SOAPAction", "\"xx\"");
request.Method = "POST";
request.Accept = "text/xml";
soapEnvelopeXml.LoadXml(getXml(dt));
request.ContentLength = soapEnvelopeXml.OuterXml.Length;
using (Stream Stream = request.GetRequestStream()) {
soapEnvelopeXml.Save(Stream);
}
using (WebResponse response = request.GetResponse()) {
using (StreamReader rd = new StreamReader(response.GetResponseStream())) {
string soapResalt = rd.ReadToEnd();
CtlCommon.CreateErrorLog(strPath, soapResalt);
}
}
} catch (Exception ex) {
CtlCommon.CreateErrorLog(strPath, ex.InnerException.ToString);
CtlCommon.CreateErrorLog(strPath, ex.Message);
}
一段時間我試圖關閉流,StreamReader的和響應,但錯誤依然存在
我是解決此評論的問題[CallWebService ](http://stackoverflow.com/a/4791932/4623058) –