3

我正在使用 Microsoft Service Trace Viewer 检查日志中的异常。例外是:

An error occurred while receiving the HTTP response to ...someservice.svc.
This could be due to the service endpoint binding not using the HTTP protocol.
This could also be due to an HTTP request context being aborted by the server
(possibly due to the service shutting down). See server logs for more details.

Web服务已启动并正在运行,我可以很好地访问它。我正在使用来自同一个 Web 服务的方法生成多个报告,除了一个之外,一切都很好。(这份报告有很多数据)。我猜这与返回太多数据/超时有关,但我如何使用 Microsoft Service Trace Viewer 进行检查?(我是这个工具的新手)。

这是我的异常字符串:

<ExceptionString>System.ServiceModel.CommunicationException: An error occurred
while receiving the HTTP response to http://someservice.svc. This could be due
 to the service endpoint binding not using the HTTP protocol. This could also
be due to an HTTP request context being aborted by the server (possibly due to
the service shutting down). See server logs for more details. --->

System.Net.WebException: The underlying connection was closed: An unexpected
error occurred on a receive. --->

System.IO.IOException: Unable to read data from the transport connection: An
existing connection was forcibly closed by the remote host. --->

System.Net.Sockets.SocketException: An existing connection was forcibly
closed by the remote host
   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)
   --- End of inner exception stack trace ---
   at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.PooledStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   at System.Net.Connection.SyncRead(HttpWebRequest request, Boolean userRetrievedStream, Boolean probeRead)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.GetResponse()
   at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
   --- End of inner exception stack trace ---</ExceptionString>

请帮忙,我真的不知道这里...

4

2 回答 2

2

要尝试获取更具体的错误,请在客户端和服务上启用跟踪,请参阅下面的链接以获取更多信息。拥有 .svclog 文件后,使用跟踪查看器将其打开,然后单击以红色突出显示的任何活动以查看详细信息 - 如果您超过了 WCF 限制(例如 MaxReceivedMessageSize),它应该出现在客户端或服务的日志中。

http://msdn.microsoft.com/en-us/library/ms733025.aspx

如何打开 WCF 跟踪?

于 2012-11-14T15:21:42.057 回答
0

我遇到的一个常见原因是 DataContractSerializer 异常。通常它对我来说是一个循环引用。

通常我要做的是在服务中的某处留下一个注释代码块,该代码块使用 DataContractSerializer 手动序列化即将返回的对象。您将从它生成的异常中获得更有用的消息。

假设您有一个“值”变量,这是完成任务的一种方法:

var xs = new DataContractSerializer(value.GetType());
var ms = new MemoryStream();
xs.WriteObject(ms, value);

然后我将执行代码来检查异常。

于 2013-05-15T20:37:19.300 回答