Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
743 views
in Technique[技术] by (71.8m points)

soap - WCF - Inspect the messages being sent/received?

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.

question from:https://stackoverflow.com/questions/6215882/wcf-inspect-the-messages-being-sent-received

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...