WCF - 检查正在发送/接收的消息? [英] WCF - Inspect the messages being sent/received?
问题描述
我有两个解决方案:
- 服务器解决方案
- 客户端解决方案
I have 2 solutions: - Server Solution - Client Solution
服务器注册到我的localhost IIS: http:// localhost / MyApp /
The server registers itself to my localhost IIS: http://localhost/MyApp/
客户端从localhost添加WCF服务应用程序: http://localhost/MyApp/MyService.svc
The client adds WCF Services (Service References) from the localhost application: http://localhost/MyApp/MyService.svc
当我运行客户端时,我想能够看到消息被来回传递。我下载Fiddler,但它似乎不想显示任何流量被发送,除非我实际上使用网络浏览器。我使用Fiddler错了,还是有其他工具,我应该使用这个?
When I'm running the client I want to be able to see the messages being passed back and forth. I downloaded Fiddler, but it doesn't seem to want to show me any traffic being sent unless I actually use a web browser. Am I using Fiddler wrong or is there another tool I should be using for this?
想要做的是看到实际传递的信息。我不想对他们做任何事情,除非用我自己的眼睛看到它们。
To clarify, what I'm looking to do is to see the actual messages being passed in. I don't want to do anything with them except see them visually with my own eyes.
我喜欢WCF服务日志实用程序,但我不认为我有正确的设置。我看不到实际的soap消息,只是收到一条消息。
I like the WCF Service Log Utility, but I don't think I have the correct setting on there. I can't see the actual soap message, just that a message was received.
并且为了进一步澄清,我不在乎什么工具,我使用,只要
And also to clarify further, I don't care what tool I use as long as I can easily see the messages themselves.
推荐答案
要查看消息内容,必须为System.ServiceModel.MessageLogging添加源您的配置文件。跟踪查看器中的消息选项卡将显示特定服务调用的完整消息。
To view the message contents you must add a source for System.ServiceModel.MessageLogging in your configuration file. The message tab in the Trace Viewer will show the full message for a particular service call.
以下是一个示例配置文件:
Here is a sample configuration file:
<configuration>
...
<system.diagnostics>
<sources>
<source name="System.ServiceModel"
switchValue="All"
propagateActivity="true">
<listeners>
<add name="traceListener" />
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging"
switchValue="All">
<listeners>
<add name="traceListener" />
</listeners>
</source>
</sources>
<sharedListeners>
<add name="traceListener"
type="System.Diagnostics.XmlWriterTraceListener"
initializeData="c:\Traces.svclog" />
</sharedListeners>
</system.diagnostics>
<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true"
logMalformedMessages="true"
logMessagesAtServiceLevel="true"
logMessagesAtTransportLevel="true"
maxMessagesToLog="500"/>
</diagnostics>
...
</system.serviceModel>
...
</configuration>
有关详细信息,请参阅MSDN上的配置跟踪主题。 http://msdn.microsoft.com/en-us/library/ms733025.aspx
See the Configuring Tracing topic on MSDN for more information. http://msdn.microsoft.com/en-us/library/ms733025.aspx
这篇关于WCF - 检查正在发送/接收的消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!