我在尝试发送/接收大型请求/响应时遇到 Web 服务 (asmx) 问题...我不断收到错误消息“底层连接已关闭:接收时发生意外错误”
HttpWebRequest request = HttpWebRequest.Create("https://test.smth.cin:443/ws/1.0") as HttpWebRequest;
request.KeepAlive = true;
request.Method = "POST";
request.ContentType = "text/xml; charset=utf-8";
request.ClientCertificates.Add(Cert);
request.Headers.Add("SOAPAction", @"https://test.smth.cin:443/ws/1.0" + p_SOAPAction);
request.Timeout = 2200000;
StreamWriter requestWriter = new StreamWriter(request.GetRequestStream(),System.Text.Encoding.UTF8);
requestWriter.Write(str_SOAP);
requestWriter.Flush();
requestWriter.Close();
HttpWebResponse response = request.GetResponse() as HttpWebResponse;
Stream responsedata = response.GetResponseStream();
StreamReader responsereader = new StreamReader(responsedata);
WS_Response ws_r = new WS_Response();
XmlDocument WS_XML_Response = new XmlDocument();
byte[] encodedString = Encoding.UTF8.GetBytes(str_SOAP);
// Put the byte array into a stream and rewind it to the beginning
MemoryStream ms = new MemoryStream(encodedString);
ms.Flush();
ms.Position = 0;
WS_XML_Response.Load(ms);
我也在<httpRuntime maxRequestLength="200000" executionTimeout="360000" />
webconfig 中进行了设置,但仍然出现错误。
有任何想法吗?