<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:copyright="http://blogs.law.harvard.edu/tech/rss" xmlns:image="http://purl.org/rss/1.0/modules/image/">
    <channel>
        <title>Windows Communication Foundation</title>
        <link>http://geekswithblogs.net/TheSenator/category/6731.aspx</link>
        <description>Explore WCF with me.</description>
        <language>en-US</language>
        <copyright>Steve Loethen</copyright>
        <managingEditor>sloethen@sbcglobal.net</managingEditor>
        <generator>Subtext Version 0.0.0.0</generator>
        <item>
            <title>With all these messages flying about, what do they look like...</title>
            <link>http://geekswithblogs.net/TheSenator/archive/2007/06/26/With-all-these-messages-flying-about-what-do-they-look.aspx</link>
            <description>&lt;p&gt;So far we have a contract, 2 client/server pairs (one programmatic and one administrative).  We can observe that the highly difficult tasks of text concatenation and changing case are happening.  But these examples are extremely trivial, and as we increase complexity, try new things, it would be nice to observer what is going on, especially when it does not go well.&lt;/p&gt; &lt;p&gt;Luck for us, there is a built in logging facility in .NET and a complete feature set and viewing tool specifically for WCF.  And all can be accomplished via the config file.  Let's hit the servers config file.&lt;/p&gt; &lt;p&gt;First, lets set up diagnostics...&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;system.diagnostics&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;sources&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;source&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt; &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;System.ServiceModel&lt;/span&gt;"
&lt;span style="color: rgb(0,0,255)"&gt;            &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;switchValue&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;Information, ActivityTracing&lt;/span&gt;"
&lt;span style="color: rgb(0,0,255)"&gt;            &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;propagateActivity&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;true&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt; &amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;listeners&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;add&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt; &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;xml&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;/&amp;gt;
      &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;listeners&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;source&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;source&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt; &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;System.ServiceModel.MessageLogging&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;listeners&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;add&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt; &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;xml&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;/&amp;gt;
      &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;listeners&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;source&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;source&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt; &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;myUserTraceSource&lt;/span&gt;"
&lt;span style="color: rgb(0,0,255)"&gt;            &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;switchValue&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;Information, ActivityTracing&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;listeners&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
        &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;add&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt; &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;xml&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;/&amp;gt;
      &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;listeners&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;source&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
  &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;sources&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
  &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;sharedListeners&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;add&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt; &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;name&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;xml&lt;/span&gt;"
&lt;span style="color: rgb(0,0,255)"&gt;         &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;type&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;System.Diagnostics.XmlWriterTraceListener&lt;/span&gt;"
&lt;span style="color: rgb(0,0,255)"&gt;               &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;initializeData&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;d:\logs\Traces.svclog&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt; /&amp;gt;
  &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;sharedListeners&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
 &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;system.diagnostics&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;This is straight out of the WCF help file.  It defines 3 sources, that use a common trace log, located at d:\logs\traces.svclog.  The first 2 come from system components, the third from a source I can drive.  We are not currently driving it yet, but let's leave it in so we can put stuff in it later for debugging purposes.&lt;/p&gt;
&lt;p&gt;So, the trace destination is there.  Let's tell the WCF system to feed it.&lt;/p&gt;
&lt;p&gt;The above big of config fell into the &amp;lt;configuration&amp;gt; section of our app.config.  The next bit is inside our System.ServiceModel section.&lt;/p&gt;&lt;pre class="code"&gt;&lt;span style="color: rgb(0,0,255)"&gt;    &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;diagnostics&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt; &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;wmiProviderEnabled&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;true&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;
      &amp;lt;&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;messageLogging&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt; 
           &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;logEntireMessage&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;true&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt; 
           &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;logMalformedMessages&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;true&lt;/span&gt;"
&lt;span style="color: rgb(0,0,255)"&gt;           &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;logMessagesAtServiceLevel&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;true&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt; 
           &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;logMessagesAtTransportLevel&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;true&lt;/span&gt;"
&lt;span style="color: rgb(0,0,255)"&gt;           &lt;/span&gt;&lt;span style="color: rgb(255,0,0)"&gt;maxMessagesToLog&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;=&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt;3000&lt;/span&gt;"&lt;span style="color: rgb(0,0,255)"&gt; 
       /&amp;gt;
    &amp;lt;/&lt;/span&gt;&lt;span style="color: rgb(163,21,21)"&gt;diagnostics&lt;/span&gt;&lt;span style="color: rgb(0,0,255)"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, we have enabled several things here.  This produces a lot of good info about what is going on.  We see the entire message, both good and bad, at both the service and transport level.  You can trim this down.  As we run the service, it puts our tracing in our log file.  We could just open this file via Notepad, and brute force our way to knowledge, but guess what.  There is a better way.  svcTraceView.exe is part of the windows sdk.  This gives us nice formatted output.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;lt;MessageLogTraceRecord&amp;gt;&lt;br /&gt;&amp;lt;s:Envelope xmlns:s="&lt;a href="http://schemas.xmlsoap.org/soap/envelope/&amp;quot;"&gt;http://schemas.xmlsoap.org/soap/envelope/"&lt;/a&gt;&amp;gt;&lt;br /&gt;&amp;lt;s:Header&amp;gt;&lt;br /&gt;&amp;lt;Action s:mustUnderstand="1" xmlns="&lt;a href="http://schemas.microsoft.com/ws/2005/05/addressing/none&amp;quot;"&gt;http://schemas.microsoft.com/ws/2005/05/addressing/none"&lt;/a&gt;&amp;gt;MyService/IMyContractInterface/SayHelloResponse&amp;lt;/Action&amp;gt;&lt;br /&gt;&amp;lt;/s:Header&amp;gt;&lt;br /&gt;&amp;lt;s:Body&amp;gt;&lt;br /&gt;&amp;lt;SayHelloResponse xmlns="MyService"&amp;gt;&lt;br /&gt;&amp;lt;SayHelloResult&amp;gt;hello bob&amp;lt;/SayHelloResult&amp;gt;&lt;br /&gt;&amp;lt;/SayHelloResponse&amp;gt;&lt;br /&gt;&amp;lt;/s:Body&amp;gt;&lt;br /&gt;&amp;lt;/s:Envelope&amp;gt;&lt;br /&gt;&amp;lt;/MessageLogTraceRecord&amp;gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This is the message response from our "SayHello" method, which was given "bob" to append to the word "Hello ".   Not bad.&lt;/p&gt;
&lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:02eb86fd-8765-4170-8d3a-cc49caad0bdf" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/WCF" rel="tag"&gt;WCF&lt;/a&gt;, &lt;a href="http://technorati.com/tags/visual%20studio" rel="tag"&gt;visual studio&lt;/a&gt;, &lt;a href="http://technorati.com/tags/dot%20net" rel="tag"&gt;dot net&lt;/a&gt;&lt;/div&gt;
&lt;p&gt;We will come back to this took and logging periodically to view the effects of binding and hosting changes...
&lt;/p&gt;&lt;p&gt;For now....&lt;/p&gt;&lt;p&gt;&lt;a href="http://www.pheedo.com/click.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=113466"&gt;&lt;img src="http://www.pheedo.com/img.phdo?x=6cda6ad746d942b9a1110d0715a4fa12&amp;u=113466" border="0"/&gt;&lt;/a&gt;&lt;/p&gt;&lt;iframe src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;PageID=31016&amp;amp;SiteID=1" width=1 height=1 Marginwidth=0 Marginheight=0 Hspace=0 Vspace=0 Frameborder=0 Scrolling=No&gt;
&lt;script language='javascript1.1' src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Browser=NETSCAPE4&amp;amp;NoCache=True&amp;PageID=31016&amp;amp;SiteID=1"&gt;&lt;/script&gt;
&lt;noscript&gt;&lt;a href="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Click&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" target="_blank"&gt;
&lt;img src="http://ads.geekswithblogs.net/a.aspx?ZoneID=5&amp;amp;Task=Get&amp;amp;Mode=HTML&amp;amp;SiteID=1&amp;amp;PageID=31016" width="1" height="1" border="0"  alt=""&gt;&lt;/a&gt;
&lt;/noscript&gt;
&lt;/iframe&gt;
&lt;img src="http://geekswithblogs.net/TheSenator/aggbug/113466.aspx" width="1" height="1" /&gt;</description>
            <dc:creator>Steve Loethen</dc:creator>
            <guid>http://geekswithblogs.net/TheSenator/archive/2007/06/26/With-all-these-messages-flying-about-what-do-they-look.aspx</guid>
            <pubDate>Tue, 26 Jun 2007 18:16:45 GMT</pubDate>
            <wfw:comment>http://geekswithblogs.net/TheSenator/comments/113466.aspx</wfw:comment>
            <comments>http://geekswithblogs.net/TheSenator/archive/2007/06/26/With-all-these-messages-flying-about-what-do-they-look.aspx#feedback</comments>
            <slash:comments>3</slash:comments>
            <wfw:commentRss>http://geekswithblogs.net/TheSenator/comments/commentRss/113466.aspx</wfw:commentRss>
            <trackback:ping>http://geekswithblogs.net/TheSenator/services/trackbacks/113466.aspx</trackback:ping>
        </item>
    </channel>
</rss>