需要帮助了解Microsoft Service Trace Viewer日志

时间:2012-11-14 13:02:02

标签: wcf web-services svctraceviewer

我正在使用Microsoft服务跟踪查看器检查日志中是否有异常。例外是:

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服务的方法生成了几个报告,除了一个之外一切都很好。 (这份报告有很多数据)。我猜这与返回太多数据/超时有关,但我如何使用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>

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

2 个答案:

答案 0 :(得分:2)

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

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

How to turn on WCF tracing?

答案 1 :(得分:0)

我遇到的一个常见原因是DataContractSerializer异常。通常这是我的循环参考。

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

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

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

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