tags:

views:

272

answers:

2

I am trying the samples from the Learning WCF book and trying to inspect the HTTP request/response. I can see the HTTP Request headers in MS TraceViewer but strangely not the response headers. (only envelope). If you notice something amiss, could you please let me know?

<configuration>
  <system.serviceModel>
    <diagnostics>
      <messageLogging logEntireMessage="true" logMalformedMessages="true"
        logMessagesAtServiceLevel="true"/>
    </diagnostics>

<!--other stuff-->

    <system.diagnostics>
        <sources>
          <source name="System.ServiceModel" switchValue="Off, ActivityTracing">
            <listeners>
              <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                <filter type="" />
              </add>
              <add initializeData="x.log" type="System.Diagnostics.XmlWriterTraceListener"
                name="sdt">
                <filter type="" />
              </add>
            </listeners>
          </source>
          <source name="System.ServiceModel.MessageLogging" switchValue="Verbose,ActivityTracing">
            <listeners>
              <add type="System.Diagnostics.DefaultTraceListener" name="Default">
                <filter type="" />
              </add>
              <add name="ServiceModelMessageLoggingListener">
                <filter type="" />
              </add>
            </listeners>
          </source>
        </sources>
        <sharedListeners>
          <add initializeData="D:\temp\messages.xml" type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
            name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
            <filter type="" />
          </add>
        </sharedListeners>
        <trace autoflush="true" />
      </system.diagnostics>
</configuration>

Request gets logged properly:

<MessageLogTraceRecord>
<HttpRequest xmlns="http://schemas.microsoft.com/2004/06/ServiceModel/Management/MessageTrace"&gt;
<Method>POST</Method>
<QueryString></QueryString>
<WebHeaders>
<SOAPAction>"http://www.thatindigogirl.com/samples/2006/06/GigManagerServiceContract/SaveGig"&lt;/SOAPAction&gt;
<Connection>Keep-Alive</Connection>
<Content-Length>485</Content-Length>
<Content-Type>text/xml; charset=utf-8</Content-Type>
<Expect>100-continue</Expect>
<Host>localhost:8000</Host>
</WebHeaders>
</HttpRequest>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
<s:Header>
<To s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;http://localhost:8000/GigManagerService&lt;/To&gt;
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;http://www.thatindigogirl.com/samples/2006/06/GigManagerServiceContract/SaveGig&lt;/Action&gt;
</s:Header>
<s:Body>
<SaveGig xmlns="http://www.thatindigogirl.com/samples/2006/06"&gt;
<item xmlns:a="wcf_expts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&gt;
<a:DateEnd>2009-11-01T05:30:00</a:DateEnd>
<a:DateStart>2009-10-31T22:30:00</a:DateStart>
<a:Description>some desc</a:Description>
<a:Id>0</a:Id>
<a:Place i:nil="true"></a:Place>
<a:Title>some boring event</a:Title>
<a:Url>http://askfdj.com&lt;/a:Url&gt;
</item>
</SaveGig>
</s:Body>
</s:Envelope>
</MessageLogTraceRecord>

and the Response I see in Trace Viewer (why no headers, http response?)

<MessageLogTraceRecord>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"&gt;
<s:Header>
<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none"&gt;http://www.thatindigogirl.com/samples/2006/06/GigManagerServiceContract/SaveGigResponse&lt;/Action&gt;
</s:Header>
<s:Body>
<SaveGigResponse xmlns="http://www.thatindigogirl.com/samples/2006/06"&gt;&lt;/SaveGigResponse&gt;
</s:Body>
</s:Envelope>
</MessageLogTraceRecord>
+1  A: 

Are you doing streaming on the response side? That would explain it - when you use streaming, only headers will be logged (not the streamed data).

Marc

marc_s
That was a useful lead. I didn't know about streaming mode. However, it seems the default is Buffered mode and even though I explicitly set it to Buffered as suggested in the link below, it doesn't seem to make a difference to my logs.http://msdn.microsoft.com/en-us/library/system.servicemodel.basichttpbinding.aspx
bagheera
A: 

If the message was streamed, you would see "...stream..." in the Body tag of the trace (I wrote a post on that).

Aare there other headers than the SOAP headers for a response to an HttpRequest? I mean what you seem to look for is HttpRequest headers, but the response isn't an HttpRequest. I'm not sure, so I might be very wrong :)

Philippe