查看wcf服务发回的数据大小

时间:2011-02-21 19:24:45

标签: c# wcf

任何人都知道查看WCF服务返回的数据大小的好工具吗?我尝试使用Redgates探查器,但我看不到你可以在哪里查看有关被发回的有效载荷的信息......

由于

错误 - 添加评论很痛苦所以我只想编辑这个问题......

基本上是 - 我最后添加了跟踪。这是我添加到.config文件中的内容。

 <system.diagnostics>
<sources>
  <source name="System.ServiceModel" propagateActivity="true">
    <listeners>
      <add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData= "{LogFile_BasePath}{LogFile_FileName}.svclog" />
    </listeners>
  </source>
  <source name="System.ServiceModel.MessageLogging">
    <listeners>
      <add name="messages" type="System.Diagnostics.XmlWriterTraceListener" initializeData="{LogFile_BasePath}{LogFile_FileName}.messages.svclog" />
    </listeners>
  </source>

</sources>

           

所以 - 说它真的很好,我可以看到未加密的SOAP消息很甜,但每当我得到一个类似+ 22k的消息时,我会得到这个消息

The trace record is not correct and cannot be loaded. This might be caused by one of the following reasons:
1. The source file has been changed, which affected the location of the loading trace.
2. There is no valid ending tag in the trace record.
3. The trace file goes wrong.

跟踪记录文件偏移量:3081471 错误跟踪记录:

嗯......看起来第二个问题是什么?我在猜?我不确定 - 我知道一切正常我只是想知道我为什么会这样做?这是我编写方法的方式吗?我会很难相信的鳍,我认为它根本不起作用,我坚持这个。

2 个答案:

答案 0 :(得分:4)

您始终可以使用Fiddler查看从您的服务中返回的内容(如果它通过HTTP返回)。您没有指定协议。

您还可以使用WCF Service Trace Viewer Tool

答案 1 :(得分:3)

使用内置WCF跟踪:http://msdn.microsoft.com/en-us/library/ms733025.aspx

您可以使用以下配置启用跟踪:

<configuration>
   <system.diagnostics>
      <sources>
            <source name="System.ServiceModel" 
                    switchValue="Information, ActivityTracing"
                    propagateActivity="true">
            <listeners>
               <add name="traceListener" 
                   type="System.Diagnostics.XmlWriterTraceListener" 
                   initializeData= "c:\log\Traces.svclog" />
            </listeners>
         </source>
      </sources>
   </system.diagnostics>
</configuration>

指定要输出的文件以代替c:\log\Traces.svclog。然后,您应该能够双击日志文件以使用SvcTraceViewer打开,并轻松查看所有请求以及有效负载内容和大小。