我已经写了下面的方法来检索客户端Web服务的XML响应。 在低于code,我收到了错误的 {无法读取传输连接的数据:一个现有的连接被强行关闭远程主机}
I have written a below method to retrieve the XML response from client web-service. At below code, I'm receiving the error as {"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host."}
请帮忙。
低于code错误
WebResponse webResponse = req.GetResponse();
方法来调用WebService的 -
[WebMethod]
public XmlDocument GetData()
{
string sError = "";
string sApiSession;
DateTime dtRequested = DateTime.Now;
XmlDocument xmlDoc = new XmlDocument();
XDocument xDoc = new XDocument();
try
{
NetworkCredential creds = new NetworkCredential();
creds.UserName = System.Configuration.ConfigurationManager.AppSettings.Get("UserName");
creds.Password = System.Configuration.ConfigurationManager.AppSettings.Get("Password");
WebRequest req = WebRequest.Create(System.Configuration.ConfigurationManager.AppSettings.Get("Services"));
req.Method = System.Configuration.ConfigurationManager.AppSettings.Get("Method");
req.ContentType = System.Configuration.ConfigurationManager.AppSettings.Get("ContentType ");
req.Credentials = creds;
//Retriev into webresponse
WebResponse webResponse = req.GetResponse();
//Read from WebResponse to datastream
Stream dataStream = webResponse.GetResponseStream();
//read the content of data stream
using (StreamReader reader = new StreamReader(dataStream))
{
xDoc = XDocument.Load(reader);
}
}
catch (Exception ex)
{
throw;
}
return xmlDoc = getXml(xDoc);
}
我已经休耕下面的链接,但仍然没有结果。
I have fallowed the below link, but still no result.
http://briancaos.word$p$pss.com/2012/06/15/an-existing-connection-was-forcibly-closed-by-the-remote-host/
以上code工作正常,如果我从我们我的办公室网络中的尝试。在这个时刻,我们正在研究网络阻塞。
The above code working fine, If I try from our of my office network and box. at this moment we are working on network blocking.