2
votes

I'm trying to log the SOAP requests that my application (client) is making to an old ASMX web service.

I then want to use the SvcTraceViewer tool to view those messages (like you can in WCF). The log file is being created, but I can't seem to find the right configuration setup so that I can see the messages.

The system.diagnostics settings I have is:

<system.diagnostics>
    <trace autoflush="true"/>
    <sources>
        <source name="System.Net" maxdatasize="1024">
            <listeners>
                <add name="TraceFile"/>
            </listeners>
        </source>
        <source name="System.Net.Sockets" maxdatasize="1024">
            <listeners>
                <add name="TraceFile"/>
            </listeners>
        </source>
        <source name="System.Net.Http">
            <listeners>
                <add name="TraceFile"/>
            </listeners>
        </source>
        <source name="System.Web.Services.Asmx">
            <listeners>
                <add name="TraceFile"/>
            </listeners>
        </source>
    </sources>
    <sharedListeners>
        <add name="TraceFile" type="System.Diagnostics.XmlWriterTraceListener" initializeData="trace.svclog"/>
    </sharedListeners>
    <switches>
        <add name="System.Net" value="Verbose"/>
        <add name="System.Net.Sockets" value="Verbose"/>
        <add name="System.Net.Http" value="Verbose"/>
        <add name="System.Web.Services.Asmx" value="Verbose"  />
    </switches>
</system.diagnostics>

I can see the individual packets (I assume from the System.Net, and each packet contains part of the message, but not one single place to easily extract that message.

Logging the inbound messages on the server in ASMX is easy:

<microsoft.web.services>
    <!-- Set the enabled attribute to "true" for input and output tracing -->
    <diagnostics>
        <trace enabled="true" input="InputTrace.webinfo" output="OutputTrace.webinfo" />
    </diagnostics>
</microsoft.web.services>

But logging the client requests appears to be quite challenging. WCF has the ServiceModel.Diagnostics Messaging config, but I can't find anything comparable for AMSX web services.

<system.diagnostics>
<sources>
  <source name="System.ServiceModel.MessageLogging">
    <listeners>
             <add name="messages"
             type="System.Diagnostics.XmlWriterTraceListener"
             initializeData="c:\logs\messages.svclog" />
      </listeners>
  </source>
</sources>
</system.diagnostics>

<system.serviceModel>
<diagnostics>
<messageLogging 
     logEntireMessage="true" 
     logMalformedMessages="false"
     logMessagesAtServiceLevel="true" 
     logMessagesAtTransportLevel="false"
     maxMessagesToLog="3000"
     maxSizeOfMessageToLog="2000"/>
</diagnostics>
</system.serviceModel>

Do I really have to write a SoapExtension to log the messages at the client end, or is there a simple config setting I am missing?

1

1 Answers

0
votes

Maybe you should use below example for client logging:

http://msdn.microsoft.com/en-us/library/vstudio/bb885203(v=vs.100).aspx

On the client side, the trace points are the followings:

  • Before and after Request Serialization
  • Before and after GetWebResponse
  • Before and after Response Deserialization
  • Before and after XmlSerializer Creation