4

I am building a web service client to interact with a (java-based) remote web service, out of my control. I can call the web service operation, and can tell by packet-sniffing that the service is responding with populated data. However, by the time that response makes it into the client code, the response is only a shell, with all the data null.

I suspect that an error is occurring in the web service "plumbing" that is causing the data to be silently dropped or ignored, but I can't find a way to enable debugging (or even logs or error messages?) during the receipt of the response before it hits my client code.

My App.config has Message Logging enabled, but only outgoing messages are being logged:

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

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

I really want to set a breakpoint during the actual parsing of the response message, but having the Message Logger actually log the response may also help a bit.

I've also configured a custom MessageEncoder which was necessary to work around a bug in the remote service's parser. I can add breakpoints to the ReadMessage methods on that MessageEncoder, and can see that the data is still there at that point. However, the next step jumps back into the client code, and the Response object is empty -- no warnings or messages. Is there any way to see what's going on in between?

So, I guess this ends up being a two-part question:

  1. How/Where can I set a breakpoint to observe the SOAP message getting processed, after the MessageEncoder, but before it is sent to the client code?
  2. What's wrong with my logging config that only outgoing messages are logged?
1
  • Update: I used the MessageEncoder's access to the basic SOAP message and just dumped it to disk, then validated it using an external tool. I'll leave the question because I'm holding out hope there was a better way that I just didn't know about. The problem ended up being a namespace issue, such that the "data" was there, but inside elements with the correct LocalName, but incorrect namespace, so it was just being ignored -- which explains why there was no error thrown -- it was technically a valid document, and the parser correctly ignored irrelevant namespaces.
    – Gus
    Dec 29, 2011 at 19:10

1 Answer 1

7

Here is how you can get the response tracing to work for you:

1. Configuration

<system.diagnostics>
<sharedListeners>
  <add name="sharedListener"
       type="System.Diagnostics.XmlWriterTraceListener"
       initializeData="C:\LogFiles\messages.svclog" />
</sharedListeners>
<sources>
  <source name="System.ServiceModel" switchValue="Verbose, ActivityTracing" >
    <listeners>
      <add name="sharedListener" />
    </listeners>
  </source>
  <source name="System.ServiceModel.MessageLogging" switchValue="Verbose">
    <listeners>
      <add name="sharedListener" />
    </listeners>
  </source>
</sources>
</system.diagnostics>
<system.serviceModel>
<diagnostics performanceCounters="All" wmiProviderEnabled="True">
  <messageLogging
       logEntireMessage="True"
       logMalformedMessages="True"
       logMessagesAtServiceLevel="True"
       logMessagesAtTransportLevel="True"
       maxMessagesToLog="3000"
       maxSizeOfMessageToLog="30000"/>
</diagnostics>
</system.serviceModel>

This goes in your app.config / web.config under the configuration node.

2. Locating the Response

A quick validation to see that you actually receive service responses from the remote service is to open up the log file as an xml file in Visual studio and do a search for

Source="TransportReceive"

you should be able to see what the remote service has responded with within this MessageLogTraceRecord node.

3. Tooling

The recommended tool for viewing these messages is SvcTraceViewer.exe

You should be able to find this in either:

C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\x64

or

C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin

If you do not have this tool, you can find it in the Windows Sdk

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.