Domanda

Hi I'm reading through the MCTS Training kit for the 70-503 exam, about tracing and message logging in WCF. And I've noticed that the trace file seems to have a more detailed header in the SOAP message when logEntireMessage is set to false, which doesn't make sense to me. So could someone explain this to me.

My app.config looks like this, where I've defined a filter:

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <diagnostics>
      <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="true" maxMessagesToLog="3000" maxSizeOfMessageToLog="2000">
        <filters>
          <add xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
            /soap:Envelope/soap:Header/a:Action[starts-with(text(), 'http://schemas.xmlsoap.org')]
          </add>
        </filters>
      </messageLogging>
    </diagnostics>
    <bindings>
      <wsHttpBinding>
        <binding name="IGetHeaders">
        </binding>
      </wsHttpBinding>
    </bindings>
    <client>
      <endpoint address="http://localhost:8731/Design_Time_Addresses/DemoService/HeaderService/" binding="wsHttpBinding" bindingConfiguration="IGetHeaders" contract="DemoService.IGetHeaders" name="IGetHeaders">
        <headers>
          <MyHeader xmlns="http://tempuri.org" name="Sample">This is my header data</MyHeader>
        </headers>
        <identity>
          <dns value="localhost"/>
        </identity>
      </endpoint>
    </client>
  </system.serviceModel>
  <system.diagnostics>
    <sources>
      <source name="System.ServiceModel.MessageLogging" switchName="Information, ActivityTracing">
        <listeners>
          <add name="log" type="System.Diagnostics.XmlWriterTraceListener" initializeData="Traces.svclog"/>
        </listeners>
      </source>
    </sources>
    <trace autoflush="true"/>
  </system.diagnostics>
  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
  </startup>
</configuration>

And the below is the trace file, when logEntireMessage is set to true

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
    <EventID>0</EventID>
    <Type>3</Type>
    <SubType Name="Information">0</SubType>
    <Level>8</Level>
    <TimeCreated SystemTime="2013-11-04T12:26:27.6791265Z" />
    <Source Name="System.ServiceModel.MessageLogging" />
    <Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
    <Execution ProcessName="TestClient.vshost" ProcessID="6392" ThreadID="8" />
    <Channel/>
    <Computer>MY-PC</Computer>
</System>
<ApplicationData>
    <TraceData>
        <DataItem>
            <MessageLogTraceRecord Time="2013-11-04T13:26:27.6591254+01:00" Source="TransportReceive" Type="System.ServiceModel.Channels.BufferedMessage" xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
                <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing">
                    <s:Header>
                        <a:Action s:mustUnderstand="1">http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Issue</a:Action>
                        <a:RelatesTo>urn:uuid:a7c94fd2-fb5a-4ba8-b18f-e9531c9a4cc6</a:RelatesTo>
                    </s:Header>
                    <s:Body>
                        <t:RequestSecurityTokenResponse Context="uuid-656588df-463f-4558-b59d-277cd3b854d6-1" xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust" xmlns:u="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
                            <t:BinaryExchange ValueType="http://schemas.xmlsoap.org/ws/2005/02/trust/spnego" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary">oYG6MIG3oAMKAQGhDAYKKwYBBAGCNwICCqKBoQSBnk5UTE1TU1AAAgAAAA4ADgA4AAAANcKa4ltbUQc7i9awkCraAQAAAABYAFgARgAAAAYBsR0AAAAPQgBBAEgAUgAtAFAAQwACAA4AQgBBAEgAUgAtAFAAQwABAA4AQgBBAEgAUgAtAFAAQwAEAA4AQgBhAGgAcgAtAFAAQwADAA4AQgBhAGgAcgAtAFAAQwAHAAgAHid5FVnZzgEAAAAA</t:BinaryExchange>
                        </t:RequestSecurityTokenResponse>
                    </s:Body>
                </s:Envelope>
            </MessageLogTraceRecord>
        </DataItem>
    </TraceData>
</ApplicationData>

And this is the same file, with the only difference, that logEntireMessage has been set to false. In this file though, I noticed that it seems that there is a lot more information regarding the header in the SOAP message, i.e. my custom endpoint header <MyHeader> is included, and the <ReplyTo> tag etc.

<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
    <System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
        <EventID>0</EventID>
        <Type>3</Type>
        <SubType Name="Information">0</SubType>
        <Level>8</Level>
        <TimeCreated SystemTime="2013-11-04T12:44:36.0783794Z" />
        <Source Name="System.ServiceModel.MessageLogging" />
        <Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
        <Execution ProcessName="TestClient.vshost" ProcessID="8044" ThreadID="9" />
        <Channel/>
        <Computer>MY-PC</Computer>
    </System>
    <ApplicationData>
        <TraceData>
            <DataItem>
                <MessageLogTraceRecord Time="2013-11-04T13:44:36.0463775+01:00" Source="TransportSend" Type="System.ServiceModel.Channels.BodyWriterMessage" xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
                    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
                        <s:Header>
                            <a:Action s:mustUnderstand="1" xmlns:a="http://www.w3.org/2005/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/trust/RST/Issue</a:Action>
                            <a:MessageID xmlns:a="http://www.w3.org/2005/08/addressing">urn:uuid:a44c286b-1d4b-4446-994c-85f3916f7898</a:MessageID>
                            <a:ReplyTo xmlns:a="http://www.w3.org/2005/08/addressing">
                                <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
                            </a:ReplyTo>
                            <a:To s:mustUnderstand="1" xmlns:a="http://www.w3.org/2005/08/addressing">http://localhost:8731/Design_Time_Addresses/DemoService/HeaderService/</a:To>
                            <MyHeader name="Sample" a:IsReferenceParameter="true" xmlns="http://tempuri.org" xmlns:a="http://www.w3.org/2005/08/addressing">This is my header data</MyHeader>
                        </s:Header>
                    </s:Envelope>
                </MessageLogTraceRecord>
            </DataItem>
        </TraceData>
    </ApplicationData>
</E2ETraceEvent>
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
    <System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
        <EventID>0</EventID>
        <Type>3</Type>
        <SubType Name="Information">0</SubType>
        <Level>8</Level>
        <TimeCreated SystemTime="2013-11-04T12:44:40.7496466Z" />
        <Source Name="System.ServiceModel.MessageLogging" />
        <Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
        <Execution ProcessName="TestClient.vshost" ProcessID="8044" ThreadID="9" />
        <Channel/>
        <Computer>MY-PC</Computer>
    </System>
    <ApplicationData>
        <TraceData>
            <DataItem>
                <MessageLogTraceRecord Time="2013-11-04T13:44:40.7396460+01:00" Source="TransportReceive" Type="System.ServiceModel.Channels.BufferedMessage" xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
                    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
                        <s:Header>
                            <a:Action s:mustUnderstand="1" xmlns:a="http://www.w3.org/2005/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Issue</a:Action>
                            <a:RelatesTo xmlns:a="http://www.w3.org/2005/08/addressing">urn:uuid:a44c286b-1d4b-4446-994c-85f3916f7898</a:RelatesTo>
                        </s:Header>
                    </s:Envelope>
                </MessageLogTraceRecord>
            </DataItem>
        </TraceData>
    </ApplicationData>
</E2ETraceEvent>
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
    <System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
        <EventID>0</EventID>
        <Type>3</Type>
        <SubType Name="Information">0</SubType>
        <Level>8</Level>
        <TimeCreated SystemTime="2013-11-04T12:44:40.8846543Z" />
        <Source Name="System.ServiceModel.MessageLogging" />
        <Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
        <Execution ProcessName="TestClient.vshost" ProcessID="8044" ThreadID="9" />
        <Channel/>
        <Computer>MY-PC</Computer>
    </System>
    <ApplicationData>
        <TraceData>
            <DataItem>
                <MessageLogTraceRecord Time="2013-11-04T13:44:40.8836542+01:00" Source="TransportSend" Type="System.ServiceModel.Channels.BodyWriterMessage" xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
                    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
                        <s:Header>
                            <a:Action s:mustUnderstand="1" xmlns:a="http://www.w3.org/2005/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Issue</a:Action>
                            <a:MessageID xmlns:a="http://www.w3.org/2005/08/addressing">urn:uuid:aec9f076-b9a2-42c2-9e4b-b745e45c3c4c</a:MessageID>
                            <a:ReplyTo xmlns:a="http://www.w3.org/2005/08/addressing">
                                <a:Address>http://www.w3.org/2005/08/addressing/anonymous</a:Address>
                            </a:ReplyTo>
                            <a:To s:mustUnderstand="1" xmlns:a="http://www.w3.org/2005/08/addressing">http://localhost:8731/Design_Time_Addresses/DemoService/HeaderService/</a:To>
                            <MyHeader name="Sample" a:IsReferenceParameter="true" xmlns="http://tempuri.org" xmlns:a="http://www.w3.org/2005/08/addressing">This is my header data</MyHeader>
                        </s:Header>
                    </s:Envelope>
                </MessageLogTraceRecord>
            </DataItem>
        </TraceData>
    </ApplicationData>
</E2ETraceEvent>
<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
    <System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
        <EventID>0</EventID>
        <Type>3</Type>
        <SubType Name="Information">0</SubType>
        <Level>8</Level>
        <TimeCreated SystemTime="2013-11-04T12:44:40.8906546Z" />
        <Source Name="System.ServiceModel.MessageLogging" />
        <Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" />
        <Execution ProcessName="TestClient.vshost" ProcessID="8044" ThreadID="9" />
        <Channel/>
        <Computer>MY-PC</Computer>
    </System>
    <ApplicationData>
        <TraceData>
            <DataItem>
                <MessageLogTraceRecord Time="2013-11-04T13:44:40.8906546+01:00" Source="TransportReceive" Type="System.ServiceModel.Channels.BufferedMessage" xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace">
                    <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope">
                        <s:Header>
                            <a:Action s:mustUnderstand="1" xmlns:a="http://www.w3.org/2005/08/addressing">http://schemas.xmlsoap.org/ws/2005/02/trust/RSTR/Issue</a:Action>
                            <a:RelatesTo xmlns:a="http://www.w3.org/2005/08/addressing">urn:uuid:aec9f076-b9a2-42c2-9e4b-b745e45c3c4c</a:RelatesTo>
                        </s:Header>
                    </s:Envelope>
                </MessageLogTraceRecord>
            </DataItem>
        </TraceData>
    </ApplicationData>
</E2ETraceEvent>

The MSDN documentation says about logEntireMessage attribute:

This value specifies whether the entire message (message header and body) is logged. The default value is false, meaning that only the header is logged. This setting affects service and transport message logging levels.

So why do the headers seem different? What am I missing here?

È stato utile?

Soluzione

These are not the same message. Look closely at the action. The first is an RST (Request for Security Token). The second is an RSTR (Request for Security Token Response). Hence the reason for the difference.

When you compare for the same message, you will see just headers when logEntireMessage is false. The SOAP Body is included when you set it to true.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top