0

我们有一个在 IIS 中运行的 ASP.NET Web 应用程序,它使用 SoapHttpClientProtocol 类进行 SOAP 调用。在过去的几天里,一些 XP 机器在进行 SOAP 服务调用时开始报告超时错误。

来自测试应用程序的堆栈跟踪:

System.Net.WebException: The operation has timed out
   at System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest request)
   at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest request)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at TestWS.localhost.Service1.HelloWorld() in C:\Prototypes\TestWS\Web References\localhost\Reference.cs:line 78
   at ASP.default_aspx.__Renderform1(HtmlTextWriter __w, Control parameterContainer) in c:\Inetpub\wwwroot\TestWS\Default.aspx:line 17

使用 TCP/ Trace 和 Wireshark,我们可以看到正在发送请求的标头,但没有发送内容。但是,content-length HTTP 参数是正确的,就好像内容流没有被刷新一样。

我们怀疑微软更新导致了这个问题。可能是 KB970430KB971737KB968389。该问题似乎与 IIS 5.x(IIS 的 XP 版本)有关。

4

1 回答 1

0

更新:事实证明,这是在 Web 服务器上运行的 ESET 防病毒软件的问题,它对从 Web 服务器到 SOAP 服务器的 HTTP 连接进行动态检查。

完整描述:作为记录,这是 .NET 中 HTTP 协议处理中的一个缺陷。场景如下:

客户端发送 HTTP POST 的标头:

POST /WS/Test.asmx HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; MS Web Services Client Protocol 2.0.50727.3603) 
Content-Type: text/xml; charset=utf-8
SOAPAction: "http://testuri.org/HelloWorld"
Host: loadtest-app
Content-Length: 288
Expect: 100-continue
Connection: Keep-Alive

内容未发送是因为 Expect: 100-Continue。服务器现在响应:

HTTP/1.1 100 Continue

此时客户端没有响应。一种解决方法是禁用 100-continue,这实际上强制请求标头和内容在一个块中发送。这可以在 web.config 中使用:

<system.net>
   <settings>
      <servicePointManager expect100Continue="false"/>
   </settings>
</system.net>

但是,如果我们还打开客户端跟踪日志记录,则会引发协议异常,指出 CR 应该在 HTTP 标头中后跟 LF。.Net 网络逻辑中似乎有一些脆弱的代码。回顾一下,这只是 IIS 5.1(在 XP 上运行的版本)中的 ASP.NET 的一个问题。

于 2009-12-18T10:16:52.410 回答