Sam
Sam

Reputation: 49

WCF Service Trace - How to see the input and out data for a service call?

We recently took over a Web services application which is written in WCF and C#. There is no client application to test the services on my local machine. All I could do is turning trace on in UAT. like below.

<system.diagnostics>
 <sources>
<source name="System.ServiceModel"
        switchValue="Information, ActivityTracing"
        propagateActivity="true" >
  <listeners>
    <add name="xml"/>
  </listeners>
</source>
<source name="System.ServiceModel.MessageLogging">
  <listeners>
    <add name="xml"/>
  </listeners>
</source>
<source name="myUserTraceSource"
        switchValue="Information, ActivityTracing">
  <listeners>
    <add name="xml"/>
  </listeners>
</source>
  </sources>
  <trace autoflush="true" />
  <sharedListeners>
<add name="xml"
     type="System.Diagnostics.XmlWriterTraceListener"
           initializeData="C:\logs\Traces.svclog" />
 </sharedListeners>
</system.diagnostics>

But when I open the trace file using Svcutil.exe, I do not see any real data elements that are being passed between systems. Where can I see the data? and is there any other/better way to run the application on my local machine?

Upvotes: 0

Views: 1246

Answers (2)

rene
rene

Reputation: 42494

You are missing the bits to enable messagelogging inside the serviceModel config.

Add this to your system.serviceModel config section in your web.config / app.config:

<system.serviceModel>  
    <diagnostics>  
      <messageLogging logEntireMessage="true"  
                      maxMessagesToLog="3000"  
                      maxSizeOfMessageToLog="20000"
                      logMessagesAtServiceLevel="true"  
                      logMalformedMessages="true"  
                      logMessagesAtTransportLevel="true" />  
    </diagnostics>  
    <!-- your bindings / services / behaviors are here --> 
</system.serviceModel> 

Also set your switchvalue to Verbose

<source name="System.ServiceModel.MessageLogging"
        switchValue="Verbose">
  <listeners>
    <add name="xml"/>
  </listeners>
</source>

Upvotes: 0

Vladimir Stefanov
Vladimir Stefanov

Reputation: 54

You can test the application using the WCF test client. WCF test client is a GUI tool that allows you to send requests to a web service and view the response. It auto-generates the methods in your service from the service definition, so you won't have to bother with that.

You can typically find the WCF Test Client (WcfTestClient.exe) in the following location: C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE - Community may be one of "Enterprise", "Professional" or "Community" depending on which level of Visual Studio is installed.

For more information visit: https://learn.microsoft.com/en-us/dotnet/framework/wcf/wcf-test-client-wcftestclient-exe

Upvotes: 1

Related Questions