简体   繁体   中英

Inspect WCF SOAP message payload

I am debugging a WCF SOAP client. I can modify the client, but don't have any control over the server. I would like to inspect the actual messages sent and received in order to find out why a message which works in SoapUI fails when sent by the client.

The communication is over SSL, so I can't use Wireshark to inspect the messages on the wire.

I have enabled wcf tracing (with logEntireMessage="true" ), but while an enormous amount of data is logged, the actual response payload does not seem to be logged. It is just shown as " ... stream ... " in Trace Viewer. Also I cant seem to find the HTTP headers for the outgoing message in the trace.

Anybody have an idea how to get closer to inspecting the actual messages?

Edit: Fiddler helped me find the problem. (It was a UTF-8 byte order mark in the payload, that the server didn't like.) WFC tracing on the other hand is too "high level" to find this kind of problem, as far as I can tell.

One option is to use Fiddler . Another option is WCF logging (as you said), make sure you mark to log at both transport and message level. Here's what works for me:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.diagnostics>
        <sources>
            <source name="System.ServiceModel.MessageLogging" switchValue="Warning, ActivityTracing">
                <listeners>
                    <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                        <filter type="" />
                    </add>
                    <add name="ServiceModelMessageLoggingListener">
                        <filter type="" />
                    </add>
                </listeners>
            </source>
        </sources>
        <sharedListeners>
            <add initializeData="C:\messages.svclog"
                type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
                name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
                <filter type="" />
            </add>
        </sharedListeners>
    </system.diagnostics>
    <system.serviceModel>
        <diagnostics>
            <messageLogging logEntireMessage="true" logMalformedMessages="true"
                logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
        </diagnostics>
    </system.serviceModel>
</configuration>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM