WCF - 检查正在发送/接收的消息? [英] WCF - Inspect the messages being sent/received?
问题描述
我有两个解决方案:- 服务器解决方案- 客户端解决方案
服务器将自己注册到我的本地主机 IIS:http://localhost/MyApp/
客户端从 localhost 应用程序添加 WCF 服务(服务引用):http://localhost/MyApp/MyService.svc
当我运行客户端时,我希望能够看到来回传递的消息.我下载了 Fiddler,但它似乎不想向我显示正在发送的任何流量,除非我实际使用网络浏览器.我使用 Fiddler 是错误还是我应该为此使用其他工具?
<小时>澄清一下,我想要做的是看到实际传入的消息.除了亲眼看到它们之外,我不想对它们做任何事情.
我喜欢 WCF 服务日志实用程序,但我认为那里没有正确的设置.我看不到实际的soap消息,只是收到了一条消息.
另外为了进一步澄清,我不在乎我使用什么工具,只要我能很容易地看到消息本身.
要查看消息内容,您必须在配置文件中添加 System.ServiceModel.MessageLogging 的源.跟踪查看器中的消息选项卡将显示特定服务调用的完整消息.
这是一个示例配置文件:
<预><代码><配置>...<系统诊断><来源><源名称="System.ServiceModel"开关值=全部"传播活动=真"><听众><add name="traceListener"/></听众></来源><source name="System.ServiceModel.MessageLogging"switchValue="全部"><听众><add name="traceListener"/></听众></来源></来源><sharedListeners><add name="traceListener"type="System.Diagnostics.XmlWriterTraceListener"initializeData="c:Traces.svclog"/></sharedListeners></system.diagnostics><system.serviceModel><诊断><messageLogging logEntireMessage="true"logMalformedMessages="true"logMessagesAtServiceLevel="true"logMessagesAtTransportLevel="true"maxMessagesToLog="500"/></诊断>...</system.serviceModel>...</配置>有关详细信息,请参阅 MSDN 上的配置跟踪主题.http://msdn.microsoft.com/en-us/library/ms733025.aspx
I have 2 solutions: - Server Solution - Client Solution
The server registers itself to my localhost IIS: http://localhost/MyApp/
The client adds WCF Services (Service References) from the localhost application: http://localhost/MyApp/MyService.svc
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.
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.
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>
See the Configuring Tracing topic on MSDN for more information. http://msdn.microsoft.com/en-us/library/ms733025.aspx
这篇关于WCF - 检查正在发送/接收的消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!