.Net 间歇性 System.Web.Services.Protocols.SoapHeaderException

发布于 2024-08-20 12:48:36 字数 4352 浏览 3 评论 0原文

我们有一个使用第三方 Web 服务的 .net 3.5 Web 应用程序。代理是通过向其 wsdl 添加 Web 引用来创建的。该代理未编译。

我们的错误日志记录经常出现但间歇性的异常:

发生并捕获了“System.Web.Services.Protocols.SoapHeaderException”类型的异常

如果我按照生成异常的页面的 url 进行操作,则无法重新创建它。

编辑:这是大多数异常 - 它从何处冒出

Message : Internal Error
Type : System.Web.Services.Protocols.SoapHeaderException, System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Source : System.Web.Services Help link : 
Actor : 
Code : http://schemas.xmlsoap.org/soap/envelope/:Client
Detail : 
Lang : 
Node : 
Role : 
SubCode : 
Data : System.Collections.ListDictionaryInternal
TargetSite : System.Object[] ReadResponse(System.Web.Services.Protocols.SoapClientMessage, System.Net.WebResponse, System.IO.Stream, Boolean)
Stack Trace :    at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at Vendor.getSearch(getSearchRequest getSearchRequest) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\be43c34e\b09edc7e\App_WebReferences.pww-cf-q.0.cs:line 73

编辑 2:内部异常:

我有时会记录以下内部异常:

Message : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
    Type : System.IO.IOException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Source : System
    Help link : 
    Data : System.Collections.ListDictionaryInternal
    TargetSite : Int32 Read(Byte[], Int32, Int32)
    Stack Trace :    at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
       at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
       at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
       at System.Net.TlsStream.CallProcessAuthentication(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
       at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
       at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
       at System.Net.ConnectStream.WriteHeaders(Boolean async)

和/或:

Message : An existing connection was forcibly closed by the remote host
        Type : System.Net.Sockets.SocketException, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
        Source : System
        Help link : 
        ErrorCode : 10054
        SocketErrorCode : ConnectionReset
        NativeErrorCode : 10054
        Data : System.Collections.ListDictionaryInternal
        TargetSite : Int32 Receive(Byte[], Int32, Int32, System.Net.Sockets.SocketFlags)
        Stack Trace :    at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
           at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)

更新

我们仍在努力。本来是路线问题,后来解决了。我们仍然收到套接字错误的内部异常。今天我们得到了 MS 支持,他们查看了一些痕迹和网络捕获。 Web 服务主机执行循环 DNS,并且它们可能会在不同的 IP 地址上响应来自一个 ip 的 syn syn/ack,而下一个响应则来自不同的 ip。这不好。这可能是针对我们的具体情况,但也许也适用于其他人。

Microsoft 网络监视器和应用程序跟踪为我们提供了所需的信息。

We have a .net 3.5 web app that consumes third party web services. The proxy was created by adding a web reference to their wsdl. This proxy is not compiled.

Our error logging is picking up frequent but intermittent exceptions:

An exception of type 'System.Web.Services.Protocols.SoapHeaderException' occurred and was caught

If I follow the url to the page that generated the exception, I can't recreate it.

Edit: Here is most of the exception - where it bubbled up from

Message : Internal Error
Type : System.Web.Services.Protocols.SoapHeaderException, System.Web.Services, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a Source : System.Web.Services Help link : 
Actor : 
Code : http://schemas.xmlsoap.org/soap/envelope/:Client
Detail : 
Lang : 
Node : 
Role : 
SubCode : 
Data : System.Collections.ListDictionaryInternal
TargetSite : System.Object[] ReadResponse(System.Web.Services.Protocols.SoapClientMessage, System.Net.WebResponse, System.IO.Stream, Boolean)
Stack Trace :    at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at Vendor.getSearch(getSearchRequest getSearchRequest) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\root\be43c34e\b09edc7e\App_WebReferences.pww-cf-q.0.cs:line 73

Edit 2: Inner exceptions:

I sometimes get the following inner exceptions logged:

Message : Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host.
    Type : System.IO.IOException, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    Source : System
    Help link : 
    Data : System.Collections.ListDictionaryInternal
    TargetSite : Int32 Read(Byte[], Int32, Int32)
    Stack Trace :    at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
       at System.Net.FixedSizeReader.ReadPacket(Byte[] buffer, Int32 offset, Int32 count)
       at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
       at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
       at System.Net.TlsStream.CallProcessAuthentication(Object state)
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
       at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
       at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
       at System.Net.ConnectStream.WriteHeaders(Boolean async)

And/Or:

Message : An existing connection was forcibly closed by the remote host
        Type : System.Net.Sockets.SocketException, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
        Source : System
        Help link : 
        ErrorCode : 10054
        SocketErrorCode : ConnectionReset
        NativeErrorCode : 10054
        Data : System.Collections.ListDictionaryInternal
        TargetSite : Int32 Receive(Byte[], Int32, Int32, System.Net.Sockets.SocketFlags)
        Stack Trace :    at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
           at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)

Update

We're still working on it. Originally there was a route issue, which was resolved. We're still getting the inner exception with socket errors. We had MS support involved today, and they looked at some traces and network captures. The web service host does round-robin DNS, and they may be responding on a different IP address for the syn syn/ack from one ip, and the next from a different ip. This is not good. This is likely quite specific to our situation, but perhaps it applies to others as well.

Microsoft Network Monitor and an application trace got us the information we needed.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

冷弦 2024-08-27 12:48:36

原因是,在从服务器读取响应的开头(位于响应开头的 SOAP 标头)时,服务器不是发送 SOAP 响应,而是关闭了 TCP/IP 连接。

显然错误不在客户端。这很可能是一种服务器过载情况,它只是终止 TCP/IP 连接,而不是提供响应或 500 或 503 HTTP 错误代码。某些网络设备导致这些连接丢失的可能性(非常小),但我自然会首先开始调查服务器端。

我建议使用 Fiddler 或 Wireshark 等工具来记录这些错误之一。由于这是强制关闭 TCP/IP 连接,因此我会寻找与服务器的通信,该通信以强制关闭连接的 TCP RST 数据包结束。

The reason for this is is that while reading the beginning of the response from the server (the SOAP headers that are at the start of the response), the server instead of sending a SOAP response, closed the TCP/IP connection.

Obviously the error is not on the client side. It is most likely a server overload situation where instead of serving a response or a 500 or 503 HTTP error code it simply terminates the TCP/IP connection. There is a (very small) probability that some network equipment is causing these connection drops, but I would naturally start investigating the server side first.

I recommend using a tool like Fiddler or Wireshark to log one of these errors. Since it's a forced TCP/IP connection close, I would look for communications with the server that end with TCP RST packet that forces the connection to close.

撧情箌佬 2024-08-27 12:48:36

此异常通过 SOAP 标头来自服务器端,您的客户端可能没有错误。您可能会从第三方网络服务提供商那里获得有关此错误的更多信息。

This exception comes from the server side through SOAP headers and your client is probably not at fault here. You might get more info about this error from those 3rd party web service providers.

诗笺 2024-08-27 12:48:36

我们最近在自己的网络服务中遇到了这个问题,最终导致超时问题。 Web 服务的实际超时设置得足够高并且永远不会受到影响,但它抛出此异常是因为它没有提供任何更新来保持活动状态(非泵送)。这就是我们的解决方案,希望它有所帮助。您可以对您的 Web 服务进行子类化或将其直接放入 reference.cs 文件中,但当您更新 Web 引用时它会被覆盖。

public partial class TheWebServiceSubClass : TheWebService
{
    protected override WebRequest GetWebRequest(Uri uri)
    {
        HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);

        webRequest.KeepAlive = false;
        webRequest.ProtocolVersion=HttpVersion.Version10;
        return webRequest;
    }
}

We recently ran into this with our own web services and it ended up being a timeout issue. The actual timeout of the web service was set high enough and never getting hit, but it was throwing this exception because it was not giving any updates to stay alive (non-pumping). This was the solution for us, hope it helps. You can subclasss your web service or put this straight into the reference.cs file, but it gets overwritten when you update web references.

public partial class TheWebServiceSubClass : TheWebService
{
    protected override WebRequest GetWebRequest(Uri uri)
    {
        HttpWebRequest webRequest = (HttpWebRequest) base.GetWebRequest(uri);

        webRequest.KeepAlive = false;
        webRequest.ProtocolVersion=HttpVersion.Version10;
        return webRequest;
    }
}
恏ㄋ傷疤忘ㄋ疼 2024-08-27 12:48:36

假设服务器工作正常,故障中包含 Client 代码这一事实表明服务器认为客户端有故障。

您是否将 SOAP 标头传递给服务?然后看看你是否可能做错了?也许你本来应该传头球,但有时你却没有?

Assuming that the server is working properly, the fact that it included the Client code in the fault indicates that the server believes the client is at fault.

Are you passing SOAP Headers to the service? Then look to see if it's possible you're doing it incorrectly? Perhaps you're meant to be passing headers but sometimes you don't?

墨小沫ゞ 2024-08-27 12:48:36

您看到的异常可能是由服务器端代码中的错误引起的。

看起来异常发生在 Vendor.getSearch 中。这个方法包含什么代码?

The exceptions you are seeing might be caused by errors in your server side code.

It looks like the exception occurred in Vendor.getSearch. What code does this method contain?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文