<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" version="2.0">
  <channel>
    <title>Clemens Vasters - Technology|Indigo</title>
    <link>http://vasters.com/clemensv/</link>
    <description>Cloud Development and Alien Abductions</description>
    <language>en-us</language>
    <copyright>Clemens Vasters</copyright>
    <lastBuildDate>Wed, 22 Aug 2007 17:20:05 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.9.7067.0</generator>
    <managingEditor>cvasters@guhhome.com</managingEditor>
    <webMaster>cvasters@guhhome.com</webMaster>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=3cc59a29-0e1a-487d-8b45-10ea559ef30d</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,3cc59a29-0e1a-487d-8b45-10ea559ef30d.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,3cc59a29-0e1a-487d-8b45-10ea559ef30d.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=3cc59a29-0e1a-487d-8b45-10ea559ef30d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We're all sinners. Lots of the authentication mechanisms on the Web are not even "best
effort", but rather just cleartext transmissions of usernames and passwords that are
easily intercepted and not secure at all. We're security sinners by using them and
even more so by allowing this. However, the reality is that there's very
likely more authentication on the Web done in an insecure fashion and in cleartext
than using any other mechanism. So if you are building WCF apps and you decide "that's
good enough" what to do?
</p>
        <p>
WCF is - rightfully - taking a pretty hard stance on these matters. If you try
to use any of the more advanced in-message authN and authZ mechnanisms such
as the <a href="http://msdn2.microsoft.com/en-us/library/ms731049.aspx">integration
with the ASP.NET membership</a>/<a href="http://msdn2.microsoft.com/en-us/library/aa702542.aspx">role
provider</a> models, you'll find yourself in security territory and our security designers
took very good care that you are not creating a config that results in the cleartext
transmission of credentials. And for that you'll need certificates and you'll
also find that it requires full trust (even in 3.5) to use that level of robust on-wire
security. 
</p>
        <p>
dasBlog has (we're sinners, too) a stance on authentication that's about as lax
as everyone else's stance in blog-land. There are not many MetaWeblog API
endpoints running over https (as they rather should) that I've seen. 
</p>
        <p>
So what I need for a bare minimum dasBlog install where the user isn't willing to
get an https certificate for their site is a very simple, <strong>consciously insecure</strong>,
bare-bones authentication and authorization mechanism for WCF services that uses the
ASP.NET membership/role model (dasBlog will use that model as we switch to the .NET
Framework 3.5 later this year). The It also needs to get completely out of the way
when the service is configured with any real AuthN/AuthZ mechanism. 
</p>
        <p>
So here's a behavior (some C# 3.0 syntax, but easy to fix) that you can add to channel
factories (client) and service endpoints (server) that will do just that. <strong>If
you care about confidentiality of credentials on the wire don't use it</strong>. For
this to work, you need to put the behavior on both ends. The behavior
will do nothing (as intended) when the binding isn't the <em>BasicHttpBinding</em> with <em>BasicHttpSecurityMode.None</em>).
The header will not show up in WSDL. 
</p>
        <p>
On the client, you simply add the behavior and otherwise set the credentials
as you would usually do for UserName authentication. This makes sure that the client
code stays compatible when you upgrade the wire protocol to a more secure
(yet still username-based) binding via config.
</p>
        <font size="4">
          <p>
          </p>
        </font>
        <font face="Courier New">
          <font color="#2b91af">MyClient</font> remoteService
= <font color="#0000ff">new</font><font color="#2b91af">MyClient</font>();<br />
remoteService.ChannelFactory.Endpoint.Behaviors.Add(<font color="#0000ff">new</font><font color="#2b91af">SimpleAuthenticationBehavior</font>());<br />
remoteService.ClientCredentials.UserName.UserName = <font color="#a31515">"admin"</font>;<br />
remoteService.ClientCredentials.UserName.Password = <font color="#a31515">"!adminadmin"</font>;</font>
        <p>
On the server, you just configure your ASP.NET membership and role database. With
that in place, you can even use role-based security attributes or any other authorization
mechnanism you are accustomed to in ASP.NET. Just as on the client, the behavior
goes out of the way and gives way for the "real thing" once you turn on security.
</p>
        <p>
          <span style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">using</span>
          <span style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes">
            <font color="#000000"> System.Runtime.Serialization;<br /></font>
            <span style="COLOR: blue">using</span>
            <font color="#000000"> System.ServiceModel;<br /></font>
            <span style="COLOR: blue">using</span>
            <font color="#000000"> System.ServiceModel.Channels;<br /></font>
            <span style="COLOR: blue">using</span>
            <font color="#000000"> System.ServiceModel.Description;<br /></font>
            <span style="COLOR: blue">using</span>
            <font color="#000000"> System.ServiceModel.Dispatcher;<br /></font>
            <span style="COLOR: blue">using</span>
            <font color="#000000"> System.ServiceModel.Security;<br /></font>
            <span style="COLOR: blue">using</span>
            <font color="#000000"> System.Threading;<br /></font>
            <span style="COLOR: blue">using</span>
            <font color="#000000"> System.Web.Security;<br /></font>
            <span style="COLOR: blue">using</span>
            <font color="#000000"> System.Xml.Serialization;<br /><br /></font>
            <span style="COLOR: blue">namespace</span>
            <font color="#000000"> dasBlog.Storage<br />
{<br /><span style="mso-spacerun: yes">    </span>[</font>
            <span style="COLOR: #2b91af">DataContract</span>
            <font color="#000000">(Namespace
= </font>
            <span style="COLOR: #2b91af">Names</span>
            <font color="#000000">.DataContractNamespace)]<br /></font>
            <font color="#000000">
              <span style="mso-spacerun: yes">   </span>
              <span style="mso-spacerun: yes"> </span>
            </font>
            <span style="COLOR: blue">class</span>
            <font color="#000000">
            </font>
            <span style="COLOR: #2b91af">SimpleAuthenticationHeader<br /></span>
            <font color="#000000">
              <span style="mso-spacerun: yes">    </span>{<br /><span style="mso-spacerun: yes">        </span>[</font>
            <span style="COLOR: #2b91af">DataMember</span>
            <font color="#000000">]<br /><span style="mso-spacerun: yes">        </span></font>
            <span style="COLOR: blue">public</span>
            <font color="#000000">
            </font>
            <span style="COLOR: blue">string</span>
            <font color="#000000"> UserName;<br /><span style="mso-spacerun: yes">        </span>[</font>
            <span style="COLOR: #2b91af">DataMember</span>
            <font color="#000000">]<br /><span style="mso-spacerun: yes">        </span></font>
            <span style="COLOR: blue">public</span>
            <font color="#000000">
            </font>
            <span style="COLOR: blue">string</span>
            <font color="#000000"> Password;<br /><span style="mso-spacerun: yes">    </span>}<br /><br /><span style="mso-spacerun: yes">    </span></font>
            <span style="COLOR: blue">public</span>
            <font color="#000000">
            </font>
            <span style="COLOR: blue">class</span>
            <font color="#000000">
            </font>
            <span style="COLOR: #2b91af">SimpleAuthenticationBehavior</span>
            <font color="#000000"> : </font>
            <span style="COLOR: #2b91af">IEndpointBehavior<br /></span>
            <font color="#000000">
              <span style="mso-spacerun: yes">    </span>{<br /></font>
            <span style="COLOR: blue">
              <span style="mso-spacerun: yes">        </span>#region</span>
            <font color="#000000"> IEndpointBehavior
Members<br /><br /><span style="mso-spacerun: yes">        </span></font>
            <span style="COLOR: blue">public</span>
            <font color="#000000">
            </font>
            <span style="COLOR: blue">void</span>
            <font color="#000000"> AddBindingParameters(</font>
            <span style="COLOR: #2b91af">ServiceEndpoint</span>
            <font color="#000000"> endpoint, <br />
                                         </font>
            <span style="COLOR: #2b91af">BindingParameterCollection</span>
            <font color="#000000"> bindingParameters)<br /><span style="mso-spacerun: yes">        </span>{<br /><span style="mso-spacerun: yes">            </span><br /><span style="mso-spacerun: yes">        </span>}<br /><br /><span style="mso-spacerun: yes">        </span></font>
            <span style="COLOR: blue">public</span>
            <font color="#000000">
            </font>
            <span style="COLOR: blue">void</span>
            <font color="#000000"> ApplyClientBehavior(</font>
            <span style="COLOR: #2b91af">ServiceEndpoint</span>
            <font color="#000000"> endpoint, <br />
                                        </font>
            <span style="COLOR: #2b91af">ClientRuntime</span>
            <font color="#000000"> clientRuntime)<br /><span style="mso-spacerun: yes">        </span>{<br /><span style="mso-spacerun: yes">            </span></font>
            <span style="COLOR: blue">if</span>
            <font color="#000000"> (endpoint.Binding </font>
            <span style="COLOR: blue">is</span>
            <font color="#000000">
            </font>
            <span style="COLOR: #2b91af">BasicHttpBinding</span>
            <font color="#000000"> &amp;&amp;<br /><span style="mso-spacerun: yes">                </span>((</font>
            <span style="COLOR: #2b91af">BasicHttpBinding</span>
            <font color="#000000">)endpoint.Binding).Security.Mode
== </font>
            <span style="COLOR: #2b91af">BasicHttpSecurityMode</span>
            <font color="#000000">.None
)<br /><span style="mso-spacerun: yes">            </span>{<br /><span style="mso-spacerun: yes">                </span></font>
            <span style="COLOR: blue">var</span>
            <font color="#000000"> credentials
= endpoint.Behaviors.Find&lt;</font>
            <span style="COLOR: #2b91af">ClientCredentials</span>
            <font color="#000000">&gt;();<br /><span style="mso-spacerun: yes">                </span></font>
            <span style="COLOR: blue">if</span>
            <font color="#000000"> (credentials
!= </font>
            <span style="COLOR: blue">null</span>
            <font color="#000000"> &amp;&amp; credentials.UserName
!= </font>
            <span style="COLOR: blue">null</span>
            <font color="#000000"> &amp;&amp; credentials.UserName.UserName
!= </font>
            <span style="COLOR: blue">null</span>
            <font color="#000000">)<br /><span style="mso-spacerun: yes">                </span>{<br /><span style="mso-spacerun: yes">                    </span>clientRuntime.MessageInspectors.Add(</font>
            <span style="COLOR: blue">new</span>
            <font color="#000000">
            </font>
            <span style="COLOR: #2b91af">ClientMessageInspector</span>
            <font color="#000000">(credentials.UserName));<span style="mso-spacerun: yes">                    </span><br /><span style="mso-spacerun: yes">                </span>}<br /><span style="mso-spacerun: yes">            </span>}<br /><span style="mso-spacerun: yes">        </span>}<br /><br /><span style="mso-spacerun: yes">        </span></font>
            <span style="COLOR: blue">public</span>
            <font color="#000000">
            </font>
            <span style="COLOR: blue">void</span>
            <font color="#000000"> ApplyDispatchBehavior(</font>
            <span style="COLOR: #2b91af">ServiceEndpoint</span>
            <font color="#000000"> endpoint,
System.ServiceModel.Dispatcher.</font>
            <span style="COLOR: #2b91af">EndpointDispatcher</span>
            <font color="#000000"> endpointDispatcher)<br /><span style="mso-spacerun: yes">        </span>{<br /><span style="mso-spacerun: yes">            </span></font>
            <span style="COLOR: blue">if</span>
            <font color="#000000"> (endpoint.Binding </font>
            <span style="COLOR: blue">is</span>
            <font color="#000000">
            </font>
            <span style="COLOR: #2b91af">BasicHttpBinding</span>
            <font color="#000000"> &amp;&amp;<br /><span style="mso-spacerun: yes">                </span>((</font>
            <span style="COLOR: #2b91af">BasicHttpBinding</span>
            <font color="#000000">)endpoint.Binding).Security.Mode
== </font>
            <span style="COLOR: #2b91af">BasicHttpSecurityMode</span>
            <font color="#000000">.None)<br /><span style="mso-spacerun: yes">            </span>{<br /><span style="mso-spacerun: yes">                </span>endpointDispatcher.DispatchRuntime.MessageInspectors.Add(</font>
            <span style="COLOR: blue">new</span>
            <font color="#000000">
            </font>
            <span style="COLOR: #2b91af">DispatchMessageInspector</span>
            <font color="#000000">());<br /><span style="mso-spacerun: yes">            </span>}<br /><span style="mso-spacerun: yes">        </span>}<br /><br /><span style="mso-spacerun: yes">        </span></font>
            <span style="COLOR: blue">public</span>
            <font color="#000000">
            </font>
            <span style="COLOR: blue">void</span>
            <font color="#000000"> Validate(</font>
            <span style="COLOR: #2b91af">ServiceEndpoint</span>
            <font color="#000000"> endpoint)<br /><span style="mso-spacerun: yes">        </span>{<br /><span style="mso-spacerun: yes">            </span><br /><span style="mso-spacerun: yes">        </span>}<br /><br /></font>
            <span style="COLOR: blue">
              <span style="mso-spacerun: yes">        </span>#endregion<br /><br /></span>
            <span style="mso-spacerun: yes">
              <font color="#000000">        </font>
            </span>
            <span style="COLOR: blue">class</span>
            <font color="#000000">
            </font>
            <span style="COLOR: #2b91af">DispatchMessageInspector</span>
            <font color="#000000"> : </font>
            <span style="COLOR: #2b91af">IDispatchMessageInspector<br /></span>
            <font color="#000000">
              <span style="mso-spacerun: yes">        </span>{<br /></font>
            <span style="COLOR: blue">
              <span style="mso-spacerun: yes">            </span>#region</span>
            <font color="#000000"> IDispatchMessageInspector
Members<br /><br /><span style="mso-spacerun: yes">            </span></font>
            <span style="COLOR: blue">public</span>
            <font color="#000000">
            </font>
            <span style="COLOR: blue">object</span>
            <font color="#000000"> AfterReceiveRequest(</font>
            <span style="COLOR: blue">ref</span>
            <font color="#000000">
            </font>
            <span style="COLOR: #2b91af">Message</span>
            <font color="#000000"> request, </font>
            <span style="COLOR: #2b91af">IClientChannel</span>
            <font color="#000000"> channel, </font>
            <span style="COLOR: #2b91af">InstanceContext</span>
            <font color="#000000"> instanceContext)<br /><span style="mso-spacerun: yes">            </span>{<br /><span style="mso-spacerun: yes">                </span></font>
            <span style="COLOR: blue">int</span>
            <font color="#000000"> headerIndex
= request.Headers.FindHeader(</font>
            <span style="COLOR: #a31515">"simpleAuthenticationHeader"</span>
            <font color="#000000">, </font>
            <span style="COLOR: #a31515">"http://dasblog.info/2007/08/security"</span>
            <font color="#000000">);<br /><span style="mso-spacerun: yes">                </span></font>
            <span style="COLOR: blue">if</span>
            <font color="#000000"> (headerIndex
&gt;= 0)<br /><span style="mso-spacerun: yes">                </span>{<br /><span style="mso-spacerun: yes">                    </span></font>
            <span style="COLOR: blue">var</span>
            <font color="#000000"> header
= request.Headers.GetHeader&lt;</font>
            <span style="COLOR: #2b91af">SimpleAuthenticationHeader</span>
            <font color="#000000">&gt;(headerIndex);<br /><span style="mso-spacerun: yes">                    </span>request.Headers.RemoveAt(headerIndex);<br /><span style="mso-spacerun: yes">                    </span></font>
            <span style="COLOR: blue">if</span>
            <font color="#000000"> ( </font>
            <span style="COLOR: #2b91af">Membership</span>
            <font color="#000000">.ValidateUser(header.UserName,
header.Password) )<br /><span style="mso-spacerun: yes">                    </span>{<br /><span style="mso-spacerun: yes">                        </span></font>
            <span style="COLOR: blue">var</span>
            <font color="#000000"> identity
= </font>
            <span style="COLOR: blue">new</span>
            <font color="#000000">
            </font>
            <span style="COLOR: #2b91af">FormsIdentity</span>
            <font color="#000000">(</font>
            <span style="COLOR: blue">new</span>
            <font color="#000000">
            </font>
            <span style="COLOR: #2b91af">FormsAuthenticationTicket</span>
            <font color="#000000">(header.UserName, </font>
            <span style="COLOR: blue">false</span>
            <font color="#000000">,
15));<br /><span style="mso-spacerun: yes">                        </span></font>
            <span style="COLOR: #2b91af">Thread</span>
            <font color="#000000">.CurrentPrincipal
= </font>
            <span style="COLOR: blue">new</span>
            <font color="#000000">
            </font>
            <span style="COLOR: #2b91af">RolePrincipal</span>
            <font color="#000000">(identity);<br /><span style="mso-spacerun: yes">                    </span>}<br /><span style="mso-spacerun: yes">                </span>}<br /><span style="mso-spacerun: yes">                </span></font>
            <span style="COLOR: blue">return</span>
            <font color="#000000">
            </font>
            <span style="COLOR: blue">null</span>
            <font color="#000000">;<br /><span style="mso-spacerun: yes">            </span>}<br /><br /><span style="mso-spacerun: yes">            </span></font>
            <span style="COLOR: blue">public</span>
            <font color="#000000">
            </font>
            <span style="COLOR: blue">void</span>
            <font color="#000000"> BeforeSendReply(</font>
            <span style="COLOR: blue">ref</span>
            <font color="#000000"> System.ServiceModel.Channels.</font>
            <span style="COLOR: #2b91af">Message</span>
            <font color="#000000"> reply, </font>
            <span style="COLOR: blue">object</span>
            <font color="#000000"> correlationState)<br /><span style="mso-spacerun: yes">            </span>{<br /><span style="mso-spacerun: yes">                </span><br /><span style="mso-spacerun: yes">            </span>}<br /><br /></font>
            <span style="COLOR: blue">
              <span style="mso-spacerun: yes">            </span>#endregion<br /></span>
            <font color="#000000">
              <span style="mso-spacerun: yes">        </span>}<br /><br /><span style="mso-spacerun: yes">        </span></font>
            <span style="COLOR: blue">class</span>
            <font color="#000000">
            </font>
            <span style="COLOR: #2b91af">ClientMessageInspector</span>
            <font color="#000000"> : </font>
            <span style="COLOR: #2b91af">IClientMessageInspector<br /></span>
            <font color="#000000">
              <span style="mso-spacerun: yes">        </span>{<br /></font>
            <span style="COLOR: blue">
              <span style="mso-spacerun: yes">            </span>#region</span>
            <font color="#000000"> IClientMessageInspector
Members<br /><br /><span style="mso-spacerun: yes">            </span></font>
            <span style="COLOR: #2b91af">UserNamePasswordClientCredential</span>
            <font color="#000000"> creds;<br /><br /><span style="mso-spacerun: yes">            </span></font>
            <span style="COLOR: blue">public</span>
            <font color="#000000"> ClientMessageInspector(</font>
            <span style="COLOR: #2b91af">UserNamePasswordClientCredential</span>
            <font color="#000000"> creds)<br /><span style="mso-spacerun: yes">            </span>{<br /><span style="mso-spacerun: yes">                </span></font>
            <span style="COLOR: blue">this</span>
            <font color="#000000">.creds
= creds;<br /><span style="mso-spacerun: yes">            </span>}<br /><br /><span style="mso-spacerun: yes">            </span></font>
            <span style="COLOR: blue">public</span>
            <font color="#000000">
            </font>
            <span style="COLOR: blue">void</span>
            <font color="#000000"> AfterReceiveReply(</font>
            <span style="COLOR: blue">ref</span>
            <font color="#000000"> System.ServiceModel.Channels.</font>
            <span style="COLOR: #2b91af">Message</span>
            <font color="#000000"> reply, </font>
            <span style="COLOR: blue">object</span>
            <font color="#000000"> correlationState)<br /><span style="mso-spacerun: yes">            </span>{<br /><span style="mso-spacerun: yes">                </span><br /><span style="mso-spacerun: yes">            </span>}<br /><br /><span style="mso-spacerun: yes">            </span></font>
            <span style="COLOR: blue">public</span>
            <font color="#000000">
            </font>
            <span style="COLOR: blue">object</span>
            <font color="#000000"> BeforeSendRequest(</font>
            <span style="COLOR: blue">ref</span>
            <font color="#000000"> System.ServiceModel.Channels.</font>
            <span style="COLOR: #2b91af">Message</span>
            <font color="#000000"> request, </font>
            <span style="COLOR: #2b91af">IClientChannel</span>
            <font color="#000000"> channel)<br /><span style="mso-spacerun: yes">            </span>{<br /><span style="mso-spacerun: yes">                </span>request.Headers.Add(</font>
            <span style="COLOR: #2b91af">MessageHeader</span>
            <font color="#000000">.CreateHeader(</font>
            <span style="COLOR: #a31515">"simpleAuthenticationHeader"</span>
            <font color="#000000">, </font>
            <span style="COLOR: #a31515">
              <a href="http://dasblog.info/2007/08/security">http://dasblog.info/2007/08/security</a>
            </span>
            <font color="#000000">, 
<br /></font>
            <span style="COLOR: blue">                                   
new</span>
            <font color="#000000">
            </font>
            <span style="COLOR: #2b91af">SimpleAuthenticationHeader</span>
            <font color="#000000">{
UserName = creds.UserName, Password = creds.Password }));<br /><span style="mso-spacerun: yes">               </span><span style="mso-spacerun: yes"> </span></font>
            <span style="COLOR: blue">return</span>
            <font color="#000000">
            </font>
            <span style="COLOR: blue">null</span>
            <font color="#000000">;<br /><span style="mso-spacerun: yes">            </span>}<br /><br /></font>
            <span style="COLOR: blue">
              <span style="mso-spacerun: yes">            </span>#endregion<br /></span>
            <font color="#000000">
              <span style="mso-spacerun: yes">        </span>}<br /><span style="mso-spacerun: yes">    </span>}<br />
}</font>
          </span>
        </p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3cc59a29-0e1a-487d-8b45-10ea559ef30d" />
      </body>
      <title>Sin, Sin, Sin: How to do Simple, Webby, and Completely Insecure ASP.NET Membership Authentication and Role Authorization with WCF</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,3cc59a29-0e1a-487d-8b45-10ea559ef30d.aspx</guid>
      <link>http://vasters.com/clemensv/2007/08/22/Sin+Sin+Sin+How+To+Do+Simple+Webby+And+Completely+Insecure+ASPNET+Membership+Authentication+And+Role+Authorization+With+WCF.aspx</link>
      <pubDate>Wed, 22 Aug 2007 17:20:05 GMT</pubDate>
      <description>&lt;p&gt;
We're all sinners. Lots of the authentication mechanisms on the Web are not even "best
effort", but rather just cleartext transmissions of usernames and passwords that are
easily intercepted and not secure at all. We're security sinners by using them and
even more so by allowing this.&amp;nbsp;However,&amp;nbsp;the reality is that there's very
likely more authentication on the Web done in an insecure fashion and in&amp;nbsp;cleartext
than using any other mechanism. So if you are building WCF apps and you decide "that's
good enough" what to do?
&lt;/p&gt;
&lt;p&gt;
WCF is - rightfully - taking a pretty hard stance on these matters.&amp;nbsp;If you try
to use any of the&amp;nbsp;more advanced&amp;nbsp;in-message authN and authZ mechnanisms such
as the &lt;a href="http://msdn2.microsoft.com/en-us/library/ms731049.aspx"&gt;integration
with the ASP.NET membership&lt;/a&gt;/&lt;a href="http://msdn2.microsoft.com/en-us/library/aa702542.aspx"&gt;role
provider&lt;/a&gt; models, you'll find yourself in security territory and our security designers
took very good care that you are not creating a config that&amp;nbsp;results in the cleartext
transmission of credentials.&amp;nbsp;And for that you'll need certificates and you'll
also find that it requires full trust (even in 3.5) to use that level of robust on-wire
security. 
&lt;/p&gt;
&lt;p&gt;
dasBlog has (we're sinners, too)&amp;nbsp;a stance on authentication that's about as lax
as everyone else's stance in blog-land.&amp;nbsp;There are not many&amp;nbsp;MetaWeblog API
endpoints running over https (as&amp;nbsp;they rather&amp;nbsp;should) that I've seen.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
So what I need for a bare minimum dasBlog install where the user isn't willing to
get an https certificate for their site is a very simple, &lt;strong&gt;consciously insecure&lt;/strong&gt;,
bare-bones authentication and authorization mechanism for WCF services that uses the
ASP.NET membership/role model (dasBlog will use that model as we switch to the .NET
Framework 3.5 later this year). The It also needs to get completely out of the way
when the service is configured with any real AuthN/AuthZ mechanism. 
&lt;/p&gt;
&lt;p&gt;
So here's a behavior (some C# 3.0 syntax, but easy to fix) that you can add to channel
factories (client) and service endpoints (server) that will do just that. &lt;strong&gt;If
you care about confidentiality of credentials on the wire don't use it&lt;/strong&gt;. For
this to work, you need to put&amp;nbsp;the behavior&amp;nbsp;on both ends.&amp;nbsp;The behavior
will do nothing (as intended) when the binding isn't the &lt;em&gt;BasicHttpBinding&lt;/em&gt; with &lt;em&gt;BasicHttpSecurityMode.None&lt;/em&gt;).
The header will&amp;nbsp;not show up in WSDL. 
&lt;/p&gt;
&lt;p&gt;
On the client, you simply&amp;nbsp;add the behavior and otherwise set the credentials
as you would usually do for UserName authentication. This makes sure that the client
code stays compatible when you upgrade the wire protocol to&amp;nbsp;a&amp;nbsp;more secure
(yet still username-based)&amp;nbsp;binding via config.
&lt;/p&gt;
&lt;font size=4&gt; 
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#2b91af&gt;MyClient&lt;/font&gt;&amp;nbsp;remoteService
= &lt;font color=#0000ff&gt;new&lt;/font&gt; &lt;font color=#2b91af&gt;MyClient&lt;/font&gt;();&lt;br&gt;
remoteService.ChannelFactory.Endpoint.Behaviors.Add(&lt;font color=#0000ff&gt;new&lt;/font&gt; &lt;font color=#2b91af&gt;SimpleAuthenticationBehavior&lt;/font&gt;());&lt;br&gt;
remoteService.ClientCredentials.UserName.UserName = &lt;font color=#a31515&gt;"admin"&lt;/font&gt;;&lt;br&gt;
remoteService.ClientCredentials.UserName.Password = &lt;font color=#a31515&gt;"!adminadmin"&lt;/font&gt;;&lt;/font&gt;&gt;
&lt;p&gt;
On the server, you just configure your ASP.NET membership and role database. With
that in place, you can even use role-based security attributes&amp;nbsp;or any other authorization
mechnanism you are accustomed to in ASP.NET. Just&amp;nbsp;as on the client, the behavior
goes out of the way and gives way for the "real thing" once you turn on security.
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;font color=#000000&gt; System.Runtime.Serialization;&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt;&lt;font color=#000000&gt; System.ServiceModel;&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt;&lt;font color=#000000&gt; System.ServiceModel.Channels;&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt;&lt;font color=#000000&gt; System.ServiceModel.Description;&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt;&lt;font color=#000000&gt; System.ServiceModel.Dispatcher;&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt;&lt;font color=#000000&gt; System.ServiceModel.Security;&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt;&lt;font color=#000000&gt; System.Threading;&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt;&lt;font color=#000000&gt; System.Web.Security;&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt;&lt;font color=#000000&gt; System.Xml.Serialization;&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt;&lt;font color=#000000&gt; dasBlog.Storage&lt;br&gt;
{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;DataContract&lt;/span&gt;&lt;font color=#000000&gt;(Namespace
= &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;Names&lt;/span&gt;&lt;font color=#000000&gt;.DataContractNamespace)]&lt;br&gt;
&lt;/font&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;class&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;SimpleAuthenticationHeader&lt;br&gt;
&lt;/span&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;DataMember&lt;/span&gt;&lt;font color=#000000&gt;]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&lt;font color=#000000&gt; UserName;&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;DataMember&lt;/span&gt;&lt;font color=#000000&gt;]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&lt;font color=#000000&gt; Password;&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;class&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;SimpleAuthenticationBehavior&lt;/span&gt;&lt;font color=#000000&gt; : &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;IEndpointBehavior&lt;br&gt;
&lt;/span&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#region&lt;/span&gt;&lt;font color=#000000&gt; IEndpointBehavior
Members&lt;br&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;void&lt;/span&gt;&lt;font color=#000000&gt; AddBindingParameters(&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;ServiceEndpoint&lt;/span&gt;&lt;font color=#000000&gt; endpoint,&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;BindingParameterCollection&lt;/span&gt;&lt;font color=#000000&gt; bindingParameters)&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;void&lt;/span&gt;&lt;font color=#000000&gt; ApplyClientBehavior(&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;ServiceEndpoint&lt;/span&gt;&lt;font color=#000000&gt; endpoint,&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;ClientRuntime&lt;/span&gt;&lt;font color=#000000&gt; clientRuntime)&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt;&lt;font color=#000000&gt; (endpoint.Binding &lt;/font&gt;&lt;span style="COLOR: blue"&gt;is&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;BasicHttpBinding&lt;/span&gt;&lt;font color=#000000&gt; &amp;amp;&amp;amp;&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;((&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;BasicHttpBinding&lt;/span&gt;&lt;font color=#000000&gt;)endpoint.Binding).Security.Mode
== &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;BasicHttpSecurityMode&lt;/span&gt;&lt;font color=#000000&gt;.None
)&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt;&lt;font color=#000000&gt; credentials
= endpoint.Behaviors.Find&amp;lt;&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;ClientCredentials&lt;/span&gt;&lt;font color=#000000&gt;&amp;gt;();&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt;&lt;font color=#000000&gt; (credentials
!= &lt;/font&gt;&lt;span style="COLOR: blue"&gt;null&lt;/span&gt;&lt;font color=#000000&gt; &amp;amp;&amp;amp; credentials.UserName
!= &lt;/font&gt;&lt;span style="COLOR: blue"&gt;null&lt;/span&gt;&lt;font color=#000000&gt; &amp;amp;&amp;amp; credentials.UserName.UserName
!= &lt;/font&gt;&lt;span style="COLOR: blue"&gt;null&lt;/span&gt;&lt;font color=#000000&gt;)&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;clientRuntime.MessageInspectors.Add(&lt;/font&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;ClientMessageInspector&lt;/span&gt;&lt;font color=#000000&gt;(credentials.UserName));&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;void&lt;/span&gt;&lt;font color=#000000&gt; ApplyDispatchBehavior(&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;ServiceEndpoint&lt;/span&gt;&lt;font color=#000000&gt; endpoint,
System.ServiceModel.Dispatcher.&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;EndpointDispatcher&lt;/span&gt;&lt;font color=#000000&gt; endpointDispatcher)&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt;&lt;font color=#000000&gt; (endpoint.Binding &lt;/font&gt;&lt;span style="COLOR: blue"&gt;is&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;BasicHttpBinding&lt;/span&gt;&lt;font color=#000000&gt; &amp;amp;&amp;amp;&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;((&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;BasicHttpBinding&lt;/span&gt;&lt;font color=#000000&gt;)endpoint.Binding).Security.Mode
== &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;BasicHttpSecurityMode&lt;/span&gt;&lt;font color=#000000&gt;.None)&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;endpointDispatcher.DispatchRuntime.MessageInspectors.Add(&lt;/font&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;DispatchMessageInspector&lt;/span&gt;&lt;font color=#000000&gt;());&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;void&lt;/span&gt;&lt;font color=#000000&gt; Validate(&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;ServiceEndpoint&lt;/span&gt;&lt;font color=#000000&gt; endpoint)&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#endregion&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;class&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;DispatchMessageInspector&lt;/span&gt;&lt;font color=#000000&gt; : &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;IDispatchMessageInspector&lt;br&gt;
&lt;/span&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#region&lt;/span&gt;&lt;font color=#000000&gt; IDispatchMessageInspector
Members&lt;br&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;object&lt;/span&gt;&lt;font color=#000000&gt; AfterReceiveRequest(&lt;/font&gt;&lt;span style="COLOR: blue"&gt;ref&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;Message&lt;/span&gt;&lt;font color=#000000&gt; request, &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;IClientChannel&lt;/span&gt;&lt;font color=#000000&gt; channel, &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;InstanceContext&lt;/span&gt;&lt;font color=#000000&gt; instanceContext)&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;&lt;font color=#000000&gt; headerIndex
= request.Headers.FindHeader(&lt;/font&gt;&lt;span style="COLOR: #a31515"&gt;"simpleAuthenticationHeader"&lt;/span&gt;&lt;font color=#000000&gt;, &lt;/font&gt;&lt;span style="COLOR: #a31515"&gt;"http://dasblog.info/2007/08/security"&lt;/span&gt;&lt;font color=#000000&gt;);&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt;&lt;font color=#000000&gt; (headerIndex
&amp;gt;= 0)&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt;&lt;font color=#000000&gt; header
= request.Headers.GetHeader&amp;lt;&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;SimpleAuthenticationHeader&lt;/span&gt;&lt;font color=#000000&gt;&amp;gt;(headerIndex);&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;request.Headers.RemoveAt(headerIndex);&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt;&lt;font color=#000000&gt; ( &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;Membership&lt;/span&gt;&lt;font color=#000000&gt;.ValidateUser(header.UserName,
header.Password) )&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;var&lt;/span&gt;&lt;font color=#000000&gt; identity
= &lt;/font&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;FormsIdentity&lt;/span&gt;&lt;font color=#000000&gt;(&lt;/font&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;FormsAuthenticationTicket&lt;/span&gt;&lt;font color=#000000&gt;(header.UserName, &lt;/font&gt;&lt;span style="COLOR: blue"&gt;false&lt;/span&gt;&lt;font color=#000000&gt;,
15));&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;Thread&lt;/span&gt;&lt;font color=#000000&gt;.CurrentPrincipal
= &lt;/font&gt;&lt;span style="COLOR: blue"&gt;new&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;RolePrincipal&lt;/span&gt;&lt;font color=#000000&gt;(identity);&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;null&lt;/span&gt;&lt;font color=#000000&gt;;&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;void&lt;/span&gt;&lt;font color=#000000&gt; BeforeSendReply(&lt;/font&gt;&lt;span style="COLOR: blue"&gt;ref&lt;/span&gt;&lt;font color=#000000&gt; System.ServiceModel.Channels.&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;Message&lt;/span&gt;&lt;font color=#000000&gt; reply, &lt;/font&gt;&lt;span style="COLOR: blue"&gt;object&lt;/span&gt;&lt;font color=#000000&gt; correlationState)&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#endregion&lt;br&gt;
&lt;/span&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;class&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;ClientMessageInspector&lt;/span&gt;&lt;font color=#000000&gt; : &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;IClientMessageInspector&lt;br&gt;
&lt;/span&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#region&lt;/span&gt;&lt;font color=#000000&gt; IClientMessageInspector
Members&lt;br&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;UserNamePasswordClientCredential&lt;/span&gt;&lt;font color=#000000&gt; creds;&lt;br&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; ClientMessageInspector(&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;UserNamePasswordClientCredential&lt;/span&gt;&lt;font color=#000000&gt; creds)&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;&lt;font color=#000000&gt;.creds
= creds;&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;void&lt;/span&gt;&lt;font color=#000000&gt; AfterReceiveReply(&lt;/font&gt;&lt;span style="COLOR: blue"&gt;ref&lt;/span&gt;&lt;font color=#000000&gt; System.ServiceModel.Channels.&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;Message&lt;/span&gt;&lt;font color=#000000&gt; reply, &lt;/font&gt;&lt;span style="COLOR: blue"&gt;object&lt;/span&gt;&lt;font color=#000000&gt; correlationState)&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;object&lt;/span&gt;&lt;font color=#000000&gt; BeforeSendRequest(&lt;/font&gt;&lt;span style="COLOR: blue"&gt;ref&lt;/span&gt;&lt;font color=#000000&gt; System.ServiceModel.Channels.&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;Message&lt;/span&gt;&lt;font color=#000000&gt; request, &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;IClientChannel&lt;/span&gt;&lt;font color=#000000&gt; channel)&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;request.Headers.Add(&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;MessageHeader&lt;/span&gt;&lt;font color=#000000&gt;.CreateHeader(&lt;/font&gt;&lt;span style="COLOR: #a31515"&gt;"simpleAuthenticationHeader"&lt;/span&gt;&lt;font color=#000000&gt;, &lt;/font&gt;&lt;span style="COLOR: #a31515"&gt;&lt;a href="http://dasblog.info/2007/08/security"&gt;http://dasblog.info/2007/08/security&lt;/a&gt;&lt;/span&gt;&lt;font color=#000000&gt;, 
&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
new&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;SimpleAuthenticationHeader&lt;/span&gt;&lt;font color=#000000&gt;{
UserName = creds.UserName, Password = creds.Password }));&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;null&lt;/span&gt;&lt;font color=#000000&gt;;&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;br&gt;
&lt;/font&gt;&lt;span style="COLOR: blue"&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;#endregion&lt;br&gt;
&lt;/span&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
}&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3cc59a29-0e1a-487d-8b45-10ea559ef30d" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,3cc59a29-0e1a-487d-8b45-10ea559ef30d.aspx</comments>
      <category>Technology/Indigo</category>
      <category>Technology/WCF</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=9677a491-9037-4b79-baa3-bcf093737957</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,9677a491-9037-4b79-baa3-bcf093737957.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,9677a491-9037-4b79-baa3-bcf093737957.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=9677a491-9037-4b79-baa3-bcf093737957</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <strong>
            <font color="#ff1493">UPDATE:</font> The code has been updated. Ignore this
post and <a href="http://vasters.com/clemensv/PermaLink,guid,679ca50b-c907-4831-81c4-369ef7b85839.aspx">go
here</a>.</strong>
        </p>
        <p>
I'm writing lots of code lately. I've rejoined the dasBlog community and I'm
busy writing a prototype for the .NET Framework 3.5 version of dasBlog (we just
released the 2.0 version, see <a href="http://www.dasblog.info/">http://www.dasblog.info/</a>).
</p>
        <p>
One of the goals of the prototype, which we'll eventually merge into the main
codebase once the .NET Framework 3.5 is available at hosting sites is to standardize
on WCF for all non-HTML endpoints. Since lots of the relevant inter-blog and blogging
tool APIs are still based on XML-RPC, that called for an implementation of XML-RPC
on WCF. I've just isolated that code and <a href="http://wcf.netfx3.com/files/folders/creating_and_using_custom_bindings/entry11943.aspx">put
it up on wcf.netfx3.com</a>.
</p>
        <p>
My XML-RPC implementation is a binding with a special encoder and a set of behaviors.
The Service Model programming experience is completely "normal" with no special extension
attributes. That means you can also expose the XML-RPC contracts as SOAP endpoints
with all the advanced WCF bindings and features if you like. 
</p>
        <p>
The binding supports client and service side and is completely config enabled. Here's
a snippet from the MetaWeblog contract:
</p>
        <font size="4">
          <p>
          </p>
        </font>
        <font face="Courier New">[<font color="#2b91af">ServiceContract</font>(Namespace
= <font color="#a31515"><a href="http://www.xmlrpc.com/metaWeblogApi">http://www.xmlrpc.com/metaWeblogApi</a></font>)]<br /><font color="#0000ff">public</font><font color="#0000ff">interface</font><font color="#2b91af">IMetaWeblog</font> :
Microsoft.ServiceModel.Samples.XmlRpc.Contracts.Blogger.</font>
        <font face="Courier New">
          <font color="#2b91af">IBlogger<br /></font>{<br />
   [<font color="#2b91af">OperationContract</font>(Action=<font color="#a31515">"metaWeblog.editPost"</font>)]<br /><font color="#0000ff">   bool</font> metaweblog_editPost(<font color="#0000ff">string</font> postid,<br /><font color="#0000ff">                            
string</font> username,<br /><font color="#0000ff">                             string</font> password,<br /><font color="#2b91af">                             Post</font> post,<br /><font color="#0000ff">                            
bool</font> publish);</font>
        <p>
          <font face="Courier New">   [<font color="#2b91af">OperationContract</font>(Action=<font color="#a31515">"metaWeblog.getCategories"</font>)]<br /><font color="#2b91af">   CategoryInfo</font>[] metaweblog_getCategories(<font color="#0000ff"> string</font> blogid,<br /><font color="#0000ff">                                     
      string</font> username,<br /><font color="#0000ff">                                     
      string</font> password);<br />
    ...<br /></font>
          <font face="Courier New">}</font>
        </p>
        <p>
For your convenience I've included complete Blogger, MetaWeblog, and MovableType
API contracts along with the respective data types in the test application. The test
app is a small in-memory blog that you can use with the blogging function of Word
2007 as a client or some other blogging client for testing. 
</p>
        <p>
Of the other interesting XML-RPC APIs, the <a href="http://www.hixie.ch/specs/pingback/pingback">Pingback
API</a> has the following contract:
</p>
        <p>
          <span style="LINE-HEIGHT: 115%; FONT-FAMILY: Consolas; FONT-SIZE: 8pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-no-proof: yes">
            <font size="2">
              <font face="Courier New">
                <font color="#000000">
                  <span style="mso-spacerun: yes">    </span>[</font>
                <span style="COLOR: #2b91af">ServiceContract</span>
                <font color="#000000">(Namespace=</font>
                <span style="COLOR: #a31515">"http://www.hixie.ch/specs/pingback/pingback"</span>
              </font>
            </font>
            <font size="2">
              <font face="Courier New">
                <font color="#000000">)]<br /><span style="mso-spacerun: yes">    </span></font>
                <span style="COLOR: blue">public</span>
                <font color="#000000">
                </font>
                <span style="COLOR: blue">interface</span>
                <font color="#000000">
                </font>
              </font>
            </font>
            <span style="COLOR: #2b91af">
              <font size="2" face="Courier New">IPingback<br /></font>
            </span>
            <font size="2">
              <font face="Courier New">
                <font color="#000000">
                  <span style="mso-spacerun: yes">    </span>{<br /><span style="mso-spacerun: yes">        </span>[</font>
                <span style="COLOR: #2b91af">OperationContract</span>
                <font color="#000000">(Action=</font>
                <span style="COLOR: #a31515">"pingback.ping"</span>
              </font>
            </font>
            <font size="2">
              <font face="Courier New">
                <font color="#000000">)]<br /><span style="mso-spacerun: yes">        </span></font>
                <span style="COLOR: blue">string</span>
                <font color="#000000"> ping(</font>
                <span style="COLOR: blue">string</span>
                <font color="#000000"> sourceUri, </font>
                <span style="COLOR: blue">string</span>
              </font>
            </font>
            <font size="2">
              <font face="Courier New">
                <font color="#000000"> targetUri);<br /><span style="mso-spacerun: yes">    </span>}</font>
              </font>
            </font>
          </span>
        </p>
        <p>
          <span style="LINE-HEIGHT: 115%; FONT-FAMILY: Consolas; FONT-SIZE: 8pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-no-proof: yes">
            <font size="2" face="Verdana">and
the <a href="http://www.xmlrpc.com/weblogsCom">WeblogUpdates API</a> looks like this:</font>
          </span>
        </p>
        <span style="LINE-HEIGHT: 115%; FONT-FAMILY: Consolas; FONT-SIZE: 8pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-no-proof: yes">
          <p style="MARGIN: 0in 0in 10pt" class="MsoNormal">
            <span style="LINE-HEIGHT: 115%; FONT-FAMILY: Consolas; FONT-SIZE: 8pt; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes">
              <font face="Courier New">
                <font size="2">
                  <font color="#000000">   
[</font>
                  <span style="COLOR: #2b91af">DataContract</span>
                </font>
              </font>
              <font face="Courier New">
                <font size="2">
                  <font color="#000000">]<br /><span style="mso-spacerun: yes">    </span></font>
                  <span style="COLOR: blue">public</span>
                  <font color="#000000">
                  </font>
                  <span style="COLOR: blue">struct</span>
                  <font color="#000000">
                  </font>
                </font>
              </font>
              <span style="COLOR: #2b91af">
                <font size="2" face="Courier New">WeblogUpdatesReply<br /></font>
              </span>
              <font face="Courier New">
                <font size="2">
                  <font color="#000000">
                    <span style="mso-spacerun: yes">    </span>{<br /><span style="mso-spacerun: yes">        </span>[</font>
                  <span style="COLOR: #2b91af">DataMember</span>
                </font>
              </font>
              <font face="Courier New">
                <font size="2">
                  <font color="#000000">]<br /><span style="mso-spacerun: yes">        </span></font>
                  <span style="COLOR: blue">public</span>
                  <font color="#000000">
                  </font>
                  <span style="COLOR: blue">bool</span>
                </font>
              </font>
              <font face="Courier New">
                <font size="2">
                  <font color="#000000"> flerror;<br /><span style="mso-spacerun: yes">        </span>[</font>
                  <span style="COLOR: #2b91af">DataMember</span>
                </font>
              </font>
              <font face="Courier New">
                <font size="2">
                  <font color="#000000">]<br /><span style="mso-spacerun: yes">        </span></font>
                  <span style="COLOR: blue">public</span>
                  <font color="#000000">
                  </font>
                  <span style="COLOR: blue">string</span>
                </font>
              </font>
              <font face="Courier New">
                <font size="2">
                  <font color="#000000"> message;<br /><span style="mso-spacerun: yes">    </span>}<br /><br /><span style="mso-spacerun: yes">    </span>[</font>
                  <span style="COLOR: #2b91af">ServiceContract</span>
                </font>
              </font>
              <font face="Courier New">
                <font size="2">
                  <font color="#000000">]<br /><span style="mso-spacerun: yes">    </span></font>
                  <span style="COLOR: blue">public</span>
                  <font color="#000000">
                  </font>
                  <span style="COLOR: blue">interface</span>
                  <font color="#000000">
                  </font>
                </font>
              </font>
              <span style="COLOR: #2b91af">
                <font size="2" face="Courier New">IWeblogUpdates<br /></font>
              </span>
              <font face="Courier New">
                <font size="2">
                  <font color="#000000">
                    <span style="mso-spacerun: yes">    </span>{<br /><span style="mso-spacerun: yes">        </span>[</font>
                  <span style="COLOR: #2b91af">OperationContract</span>
                  <font color="#000000">(Action
= </font>
                  <span style="COLOR: #a31515">"weblogUpdates.extendedPing"</span>
                </font>
              </font>
              <font face="Courier New">
                <font size="2">
                  <font color="#000000">)]<br /><span style="mso-spacerun: yes">        </span></font>
                  <span style="COLOR: #2b91af">WeblogUpdatesReply</span>
                  <font color="#000000"> ExtendedPing(</font>
                  <span style="COLOR: blue">string</span>
                  <font color="#000000"> weblogName, </font>
                  <span style="COLOR: blue">string</span>
                  <font color="#000000"> weblogUrl, </font>
                  <span style="COLOR: blue">string</span>
                  <font color="#000000"> checkUrl, </font>
                  <span style="COLOR: blue">string</span>
                </font>
              </font>
              <font face="Courier New">
                <font size="2">
                  <font color="#000000"> rssUrl);<br /><span style="mso-spacerun: yes">        </span>[</font>
                  <span style="COLOR: #2b91af">OperationContract</span>
                  <font color="#000000">(Action=</font>
                  <span style="COLOR: #a31515">"weblogUpdates.ping"</span>
                </font>
              </font>
              <font face="Courier New">
                <font size="2">
                  <font color="#000000">)]<br /><span style="mso-spacerun: yes">        </span></font>
                  <span style="COLOR: #2b91af">WeblogUpdatesReply</span>
                  <font color="#000000"> Ping(</font>
                  <span style="COLOR: blue">string</span>
                  <font color="#000000"> weblogName, </font>
                  <span style="COLOR: blue">string</span>
                </font>
              </font>
              <font color="#000000" size="2" face="Courier New"> weblogUrl);<br /><span style="mso-spacerun: yes">    </span>}</font>
            </span>
          </p>
          <p>
          </p>
        </span>I'm expecting some interop bugs since I've done a clean implementation
from the specs, so if you find any please let me know.
<p>
The code is subject to the Microsoft samples license, which means that you can put
it into your (blogging) apps. Enjoy.
</p><img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=9677a491-9037-4b79-baa3-bcf093737957" /></body>
      <title>XML-RPC with WCF</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,9677a491-9037-4b79-baa3-bcf093737957.aspx</guid>
      <link>http://vasters.com/clemensv/2007/08/21/XMLRPC+With+WCF.aspx</link>
      <pubDate>Tue, 21 Aug 2007 07:46:33 GMT</pubDate>
      <description>&lt;p&gt;
&lt;strong&gt;&lt;font color=#ff1493&gt;UPDATE:&lt;/font&gt; The code has been updated. Ignore this
post and &lt;a href="http://vasters.com/clemensv/PermaLink,guid,679ca50b-c907-4831-81c4-369ef7b85839.aspx"&gt;go
here&lt;/a&gt;.&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
I'm writing lots of code&amp;nbsp;lately. I've rejoined the dasBlog community and I'm
busy&amp;nbsp;writing a prototype for the .NET Framework 3.5 version of dasBlog (we just
released the 2.0 version, see &lt;a href="http://www.dasblog.info/"&gt;http://www.dasblog.info/&lt;/a&gt;).
&lt;/p&gt;
&lt;p&gt;
One of the&amp;nbsp;goals of the prototype, which we'll eventually merge into the main
codebase once&amp;nbsp;the .NET Framework 3.5 is available at hosting sites is to standardize
on WCF for all non-HTML endpoints. Since lots of the relevant inter-blog and blogging
tool APIs&amp;nbsp;are still based on XML-RPC, that called for an implementation of XML-RPC
on WCF. I've just isolated that code and &lt;a href="http://wcf.netfx3.com/files/folders/creating_and_using_custom_bindings/entry11943.aspx"&gt;put
it up on wcf.netfx3.com&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
My XML-RPC implementation is a binding with a special encoder and a set of behaviors.
The Service Model programming experience is completely "normal" with no special extension
attributes. That means you can also expose the XML-RPC contracts as SOAP endpoints
with all the advanced WCF bindings and features if you like. 
&lt;/p&gt;
&lt;p&gt;
The binding&amp;nbsp;supports client and service side and is completely config enabled.&amp;nbsp;Here's
a snippet from the MetaWeblog contract:
&lt;/p&gt;
&lt;font size=4&gt; 
&lt;p&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;[&lt;font color=#2b91af&gt;ServiceContract&lt;/font&gt;(Namespace
= &lt;font color=#a31515&gt;&lt;a href="http://www.xmlrpc.com/metaWeblogApi"&gt;http://www.xmlrpc.com/metaWeblogApi&lt;/a&gt;&lt;/font&gt;)]&lt;br&gt;
&lt;font color=#0000ff&gt;public&lt;/font&gt; &lt;font color=#0000ff&gt;interface&lt;/font&gt; &lt;font color=#2b91af&gt;IMetaWeblog&lt;/font&gt; :
Microsoft.ServiceModel.Samples.XmlRpc.Contracts.Blogger.&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font color=#2b91af&gt;IBlogger&lt;br&gt;
&lt;/font&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; [&lt;font color=#2b91af&gt;OperationContract&lt;/font&gt;(Action=&lt;font color=#a31515&gt;"metaWeblog.editPost"&lt;/font&gt;)]&lt;br&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp; bool&lt;/font&gt; metaweblog_editPost(&lt;font color=#0000ff&gt;string&lt;/font&gt; postid,&lt;br&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
string&lt;/font&gt; username,&lt;br&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string&lt;/font&gt; password,&lt;br&gt;
&lt;font color=#2b91af&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Post&lt;/font&gt; post,&lt;br&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
bool&lt;/font&gt; publish);&lt;/font&gt;&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&amp;nbsp;&amp;nbsp; [&lt;font color=#2b91af&gt;OperationContract&lt;/font&gt;(Action=&lt;font color=#a31515&gt;"metaWeblog.getCategories"&lt;/font&gt;)]&lt;br&gt;
&lt;font color=#2b91af&gt;&amp;nbsp;&amp;nbsp; CategoryInfo&lt;/font&gt;[] metaweblog_getCategories(&lt;font color=#0000ff&gt; string&lt;/font&gt; blogid,&lt;br&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string&lt;/font&gt; username,&lt;br&gt;
&lt;font color=#0000ff&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; string&lt;/font&gt; password);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; ...&lt;br&gt;
&lt;/font&gt;&lt;font face="Courier New"&gt;}&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
For your convenience I've included&amp;nbsp;complete Blogger, MetaWeblog, and MovableType
API contracts along with the respective data types in the test application. The test
app is a small in-memory blog that you can use with the blogging function of Word
2007 as a client or some other blogging client for testing. 
&lt;/p&gt;
&lt;p&gt;
Of the other interesting XML-RPC APIs, the &lt;a href="http://www.hixie.ch/specs/pingback/pingback"&gt;Pingback
API&lt;/a&gt; has the following contract:
&lt;/p&gt;
&lt;p&gt;
&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: Consolas; FONT-SIZE: 8pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-no-proof: yes"&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;ServiceContract&lt;/span&gt;&lt;font color=#000000&gt;(Namespace=&lt;/font&gt;&lt;span style="COLOR: #a31515"&gt;"http://www.hixie.ch/specs/pingback/pingback"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt;)]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;interface&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;&lt;font size=2 face="Courier New"&gt;IPingback&lt;br&gt;
&lt;/font&gt;&lt;/span&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;&lt;font color=#000000&gt;(Action=&lt;/font&gt;&lt;span style="COLOR: #a31515"&gt;"pingback.ping"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt;)]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&lt;font color=#000000&gt; ping(&lt;/font&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&lt;font color=#000000&gt; sourceUri, &lt;/font&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;font face="Courier New"&gt;&lt;font color=#000000&gt; targetUri);&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: Consolas; FONT-SIZE: 8pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-no-proof: yes"&gt;&lt;font size=2 face=Verdana&gt;and
the &lt;a href="http://www.xmlrpc.com/weblogsCom"&gt;WeblogUpdates API&lt;/a&gt; looks like this:&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: Consolas; FONT-SIZE: 8pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA; mso-no-proof: yes"&gt; 
&lt;p style="MARGIN: 0in 0in 10pt" class=MsoNormal&gt;
&lt;span style="LINE-HEIGHT: 115%; FONT-FAMILY: Consolas; FONT-SIZE: 8pt; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes"&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color=#000000&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;DataContract&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color=#000000&gt;]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;struct&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;&lt;font size=2 face="Courier New"&gt;WeblogUpdatesReply&lt;br&gt;
&lt;/font&gt;&lt;/span&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;DataMember&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color=#000000&gt;]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;bool&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color=#000000&gt; flerror;&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;DataMember&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color=#000000&gt;]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color=#000000&gt; message;&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;br&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;ServiceContract&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color=#000000&gt;]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;span style="COLOR: blue"&gt;interface&lt;/span&gt;&lt;font color=#000000&gt; &lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;&lt;font size=2 face="Courier New"&gt;IWeblogUpdates&lt;br&gt;
&lt;/font&gt;&lt;/span&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color=#000000&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;&lt;font color=#000000&gt;(Action
= &lt;/font&gt;&lt;span style="COLOR: #a31515"&gt;"weblogUpdates.extendedPing"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color=#000000&gt;)]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;WeblogUpdatesReply&lt;/span&gt;&lt;font color=#000000&gt; ExtendedPing(&lt;/font&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&lt;font color=#000000&gt; weblogName, &lt;/font&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&lt;font color=#000000&gt; weblogUrl, &lt;/font&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&lt;font color=#000000&gt; checkUrl, &lt;/font&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color=#000000&gt; rssUrl);&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;&lt;font color=#000000&gt;(Action=&lt;/font&gt;&lt;span style="COLOR: #a31515"&gt;"weblogUpdates.ping"&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font face="Courier New"&gt;&lt;font size=2&gt;&lt;font color=#000000&gt;)]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/font&gt;&lt;span style="COLOR: #2b91af"&gt;WeblogUpdatesReply&lt;/span&gt;&lt;font color=#000000&gt; Ping(&lt;/font&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&lt;font color=#000000&gt; weblogName, &lt;/font&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;&lt;/font&gt;&lt;/font&gt;&lt;font color=#000000 size=2 face="Courier New"&gt; weblogUrl);&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;}&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/span&gt;I'm expecting some interop bugs since I've done a clean implementation from
the specs, so if you find any please let me know.&gt;
&lt;p&gt;
The code is subject to the Microsoft samples license, which means that you can put
it into your (blogging) apps. Enjoy.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=9677a491-9037-4b79-baa3-bcf093737957" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,9677a491-9037-4b79-baa3-bcf093737957.aspx</comments>
      <category>MSDN</category>
      <category>Technology/Indigo</category>
      <category>Technology/WCF</category>
      <category>Technology/Weblogs</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=cd61e19d-df0d-47ff-8040-d0b4bb77e10c</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,cd61e19d-df0d-47ff-8040-d0b4bb77e10c.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,cd61e19d-df0d-47ff-8040-d0b4bb77e10c.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=cd61e19d-df0d-47ff-8040-d0b4bb77e10c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I've posted the current <a href="http://wcf.netfx3.com/content/WindowsCommunicationFoundationTrainingProviders.aspx">WCF
Training Providers</a> list on wcf.netfx3.com this weekend. All of these folks are
running custom-built training classes for WCF and until we here at MS come out with
the "official" Microsoft Official Curriculum" for WCF and the other .NET Framework
3.0 technologies (which will take several months from when Vista ships), these offerings
are indeed our preferred option for you to get WCF training. 
</p>
        <p>
One event that I'll personally highlight and happily and shamelessly advertise
is <a href="http://www.newtelligence.com/PermaLink.aspx?guid=75b55828-ecf0-45d2-adf7-a438b02f41b2">a
cooperation by my ex-firm newtelligence and my friends at IDesign</a>, because it's
coming up very soon. One of the coolest aspect of <a href="http://www.tornadocamp.net/WCF/">that
class</a> is that it is scheduled to take place in Europe's #1 vacation spot Mallorca,
which means that cheap flights should be available from anywhere and the weather is
nice, too. <a href="http://www.tornadocamp.net/wcf/SignUp.aspx">Registration is open</a> and
my understanding is that it closes this week! I wish I could go.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=cd61e19d-df0d-47ff-8040-d0b4bb77e10c" />
      </body>
      <title>Shameless WCF Training Plug</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,cd61e19d-df0d-47ff-8040-d0b4bb77e10c.aspx</guid>
      <link>http://vasters.com/clemensv/2006/09/25/Shameless+WCF+Training+Plug.aspx</link>
      <pubDate>Mon, 25 Sep 2006 23:51:10 GMT</pubDate>
      <description>&lt;p&gt;
I've posted the current&amp;nbsp;&lt;a href="http://wcf.netfx3.com/content/WindowsCommunicationFoundationTrainingProviders.aspx"&gt;WCF
Training Providers&lt;/a&gt; list on wcf.netfx3.com this weekend. All of these folks are
running custom-built training classes for WCF and until we here at MS come out with
the "official" Microsoft Official Curriculum" for WCF and the other .NET Framework
3.0 technologies (which will take several months from when Vista ships), these&amp;nbsp;offerings
are indeed&amp;nbsp;our preferred option for you to get WCF training. 
&lt;/p&gt;
&lt;p&gt;
One event that I'll personally highlight and happily and shamelessly&amp;nbsp;advertise
is &lt;a href="http://www.newtelligence.com/PermaLink.aspx?guid=75b55828-ecf0-45d2-adf7-a438b02f41b2"&gt;a
cooperation by my ex-firm newtelligence and my friends at IDesign&lt;/a&gt;, because it's
coming up very soon. One of the coolest aspect of &lt;a href="http://www.tornadocamp.net/WCF/"&gt;that
class&lt;/a&gt; is that it is scheduled to take place in Europe's #1 vacation spot Mallorca,
which means that cheap flights should be available from anywhere and the weather is
nice, too. &lt;a href="http://www.tornadocamp.net/wcf/SignUp.aspx"&gt;Registration is open&lt;/a&gt; and
my understanding is that it closes this week! I wish I could go.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=cd61e19d-df0d-47ff-8040-d0b4bb77e10c" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,cd61e19d-df0d-47ff-8040-d0b4bb77e10c.aspx</comments>
      <category>Technology/Indigo</category>
      <category>Technology/WCF</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=6a2590f3-f735-4b29-8241-45d94acad149</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,6a2590f3-f735-4b29-8241-45d94acad149.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,6a2590f3-f735-4b29-8241-45d94acad149.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=6a2590f3-f735-4b29-8241-45d94acad149</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <strike>Indigo</strike> The Windows Communication Foundation's RC1 bits are now live.
RC means "Release Candidate" and our team is really, really serious about this
release being as close to what we intend to ship as we can ever get. Our database
view with unresolved code-defects is essentially empty (there is a not more of a handful
of small fixes for very esoteric scenarios that we're still doing for RTM). The time
of breaking changes is absolutely and finally over for "WCF Version 1".
</p>
        <p>
The team is very excited about this. There's lots of joy in the hallways. We're getting
close to being done. Remember when you saw the first WS-* specs popping up out there
some 6 years ago? That's when this thing was started. You can just imagine how pumped
the testers, developers and program managers are around here. And even though I
am new to the family, I get to celebrate a little too. Greatness.
</p>
        <p>
Get the RC1 for the .NET Framework 3.0 with the WCF bits from here:<br /><span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"><a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=19E21845-F5E3-4387-95FF-66788825C1AF&amp;displaylang=en"><font color="#0000ff">http://www.microsoft.com/downloads/details.aspx?FamilyId=19E21845-F5E3-4387-95FF-66788825C1AF&amp;displaylang=en</font></a></span> 
</p>
        <p>
There's one little issue with the Visual Studio Tools aligned with that version, so
it will take another day or so until those get uploaded.
</p>
        <p>
As always, if you find problems, tell us: <a href="http://connect.microsoft.com/wcf">http://connect.microsoft.com/wcf</a></p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=6a2590f3-f735-4b29-8241-45d94acad149" />
      </body>
      <title>"Indigo is live."</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,6a2590f3-f735-4b29-8241-45d94acad149.aspx</guid>
      <link>http://vasters.com/clemensv/2006/09/01/Indigo+Is+Live.aspx</link>
      <pubDate>Fri, 01 Sep 2006 21:00:38 GMT</pubDate>
      <description>&lt;p&gt;
&lt;strike&gt;Indigo&lt;/strike&gt; The Windows Communication Foundation's RC1 bits are now live.
RC means "Release Candidate" and&amp;nbsp;our team is really, really serious about this
release being as close to what we intend to ship as we can ever get. Our database
view with unresolved code-defects is essentially empty (there is a not more of a handful
of small fixes for very esoteric scenarios that we're still doing for RTM). The time
of breaking changes is absolutely and finally over for "WCF Version 1".
&lt;/p&gt;
&lt;p&gt;
The team is very excited about this. There's lots of joy in the hallways. We're getting
close to being done. Remember when you saw the first WS-* specs popping up out there
some 6 years ago? That's when this thing was started. You can just imagine how pumped
the testers, developers and program managers are around here. And even though&amp;nbsp;I
am new to the family, I get to celebrate a little too. Greatness.
&lt;/p&gt;
&lt;p&gt;
Get the RC1 for the .NET Framework 3.0 with the WCF bits from here:&lt;br&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: 'Arial','sans-serif'; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=19E21845-F5E3-4387-95FF-66788825C1AF&amp;amp;displaylang=en"&gt;&lt;font color=#0000ff&gt;http://www.microsoft.com/downloads/details.aspx?FamilyId=19E21845-F5E3-4387-95FF-66788825C1AF&amp;amp;displaylang=en&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
There's one little issue with the Visual Studio Tools aligned with that version, so
it will take another day or so until those get uploaded.
&lt;/p&gt;
&lt;p&gt;
As always, if you find problems, tell us: &lt;a href="http://connect.microsoft.com/wcf"&gt;http://connect.microsoft.com/wcf&lt;/a&gt; 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=6a2590f3-f735-4b29-8241-45d94acad149" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,6a2590f3-f735-4b29-8241-45d94acad149.aspx</comments>
      <category>Technology/Indigo</category>
      <category>Technology/WCF</category>
      <category>Technology/Web Services</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=1d54f6d7-4860-4e7e-a020-6cab738770b0</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,1d54f6d7-4860-4e7e-a020-6cab738770b0.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,1d54f6d7-4860-4e7e-a020-6cab738770b0.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=1d54f6d7-4860-4e7e-a020-6cab738770b0</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Cool. I hadn't even seen this demo until now, even though we already have it for a
while. Our technical evangelist Craig McMurtry posted the <a href="http://wcf.netfx3.com/files/48/distributed_applications/entry2977.aspx">"Digital
Fortress"</a> demo, which is an implementation of the computer systems that play major
roles in Dan Brown's novel "Digital Fortress". There are several reasons why
I find this demo interesting and pretty amusing.
</p>
        <p>
First of all, it has a "Hollywood-Style UI", which is funny. It's got the huge full-screen
login screen with a "sort-of-looks-like-the-NSA" logo, a big count-down clock and
a "control screen" (below) with the gratuitous graphics and big buttons one might
expect. The other thing that's very interesting is that it is a <em>management
tools demo</em> (of all things). The key to bust the evil conspiracy is to trace
suspicious network activity across many nodes on the network and the script packaged
with the demo shows you how to get that done using the built-in WCF tracing facilities. <a href="http://wcf.netfx3.com/files/48/distributed_applications/entry2977.aspx">Download.</a></p>
        <p align="center">
          <img src="http://friends.newtelligence.net/clemensv/content/binary/fortress.jpg" border="0" />
        </p>
        <p>
 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=1d54f6d7-4860-4e7e-a020-6cab738770b0" />
      </body>
      <title>WCF Goes To Hollywood.</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,1d54f6d7-4860-4e7e-a020-6cab738770b0.aspx</guid>
      <link>http://vasters.com/clemensv/2006/06/21/WCF+Goes+To+Hollywood.aspx</link>
      <pubDate>Wed, 21 Jun 2006 08:39:35 GMT</pubDate>
      <description>&lt;p&gt;
Cool. I hadn't even seen this demo until now, even though we already have it for a
while.&amp;nbsp;Our technical evangelist Craig McMurtry posted the &lt;a href="http://wcf.netfx3.com/files/48/distributed_applications/entry2977.aspx"&gt;"Digital
Fortress"&lt;/a&gt; demo, which is an implementation of&amp;nbsp;the computer systems that play&amp;nbsp;major
roles in Dan Brown's novel "Digital Fortress". There are several&amp;nbsp;reasons&amp;nbsp;why
I find this demo interesting and pretty amusing.
&lt;/p&gt;
&lt;p&gt;
First of all, it has a "Hollywood-Style UI", which is funny. It's got the huge full-screen
login screen with a "sort-of-looks-like-the-NSA" logo, a big count-down clock and
a "control screen" (below) with the gratuitous graphics and big buttons one might
expect. The other thing that's very interesting is that&amp;nbsp;it is a &lt;em&gt;management
tools demo&lt;/em&gt; (of all things).&amp;nbsp;The key to bust the evil conspiracy is to trace
suspicious network activity across many nodes on the network and the script packaged
with the demo shows you how to get that done using the built-in WCF tracing facilities. &lt;a href="http://wcf.netfx3.com/files/48/distributed_applications/entry2977.aspx"&gt;Download.&lt;/a&gt;
&lt;/p&gt;
&lt;p align=center&gt;
&lt;img src="http://friends.newtelligence.net/clemensv/content/binary/fortress.jpg" border=0&gt;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=1d54f6d7-4860-4e7e-a020-6cab738770b0" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,1d54f6d7-4860-4e7e-a020-6cab738770b0.aspx</comments>
      <category>MSDN</category>
      <category>Technology/Indigo</category>
      <category>Technology/WCF</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=6059315f-0d8e-4671-a883-9e6d15a48b02</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,6059315f-0d8e-4671-a883-9e6d15a48b02.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,6059315f-0d8e-4671-a883-9e6d15a48b02.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=6059315f-0d8e-4671-a883-9e6d15a48b02</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <em>[Note to self: Schedule the video taping session early in a bound-to-be-stressful
week, not 2 hours before you need to leave for the airport on Friday.]</em>
        </p>
        <p>
MSDN TV has a <a href="http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20060615WCFCV/manifest.xml">new
episode</a> featuring <a href="http://dictionary.reference.com/browse/yours truly">yours
truly</a> speaking about WCF bindings (and what they cause in the channel stack).
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=6059315f-0d8e-4671-a883-9e6d15a48b02" />
      </body>
      <title>MSDN TV: WCF Bindings.</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,6059315f-0d8e-4671-a883-9e6d15a48b02.aspx</guid>
      <link>http://vasters.com/clemensv/2006/06/18/MSDN+TV+WCF+Bindings.aspx</link>
      <pubDate>Sun, 18 Jun 2006 12:56:50 GMT</pubDate>
      <description>&lt;p&gt;
&lt;em&gt;[Note to self: Schedule the video taping session early in a bound-to-be-stressful
week, not 2 hours before you need to leave for the airport on Friday.]&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
MSDN TV has a &lt;a href="http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20060615WCFCV/manifest.xml"&gt;new
episode&lt;/a&gt; featuring &lt;a href="http://dictionary.reference.com/browse/yours truly"&gt;yours
truly&lt;/a&gt; speaking about WCF bindings (and what they cause in the channel stack).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=6059315f-0d8e-4671-a883-9e6d15a48b02" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,6059315f-0d8e-4671-a883-9e6d15a48b02.aspx</comments>
      <category>MSDN</category>
      <category>Technology/Indigo</category>
      <category>Technology/WCF</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=57b03894-e197-4512-b9ea-648105890103</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,57b03894-e197-4512-b9ea-648105890103.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,57b03894-e197-4512-b9ea-648105890103.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=57b03894-e197-4512-b9ea-648105890103</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was sad when "Indigo" and "Avalon" went away. It'd be great if we'd have
a pool of cool legal-approved code-names for which we own the trademark rights and
which we could stick to. Think Delphi or Safari. "Indigo" was cool insofar as
it was very handy to refer to the technology set, but was removed far enough
from the specifics that it doesn't create a sharply defined, product-like island
within the larger managed-code landscape or has legacy connotations like "ADO.NET".
 Also, my talks these days could be 10 minutes shorter if I could refer to Indigo
instead of "Windows Communications Foundation". Likewise, my job title wouldn't have
to have a line wrap on the business card of I ever spelled it out in full.
</p>
        <p>
However, when I learned about the WinFX name going away (several weeks before the
public announcement) and the new "Vista Wave" technologies (WPF/WF/WCF/WCS) being rolled
up under the <a href="http://msdn.microsoft.com/winfx/">.NET Framework</a> brand,
I was quite happy. Ever since it became clear in 2004 that the grand plan to put
a complete, covers-all-and-everything managed API on top (and on quite a
bit of the bottom) of everything Windows would have to wait until siginificantly after
Vista and that therefore the Win16&gt;Win32&gt;WinFX continuity would not
tell the true story, that name made only limited sense to stick to. The .NET Framework
is the #1 choice for business applications and a well established brand. People refer
to themselves as being "dotnet" developers. But even though the .NET Framework covers
a lot of ground and "Indigo", "Avalon", "InfoCard", and "Workflow" are overwhelmingly
(or exclusively) managed-code based, there are still quite a few things in Windows
Vista that still require using P/Invoke or COM/Interop from managed code or unmanaged
code outright. That's not a problem. Something has to manage the managed code
and there's no urgent need to rewrite entire subsystems to managed code if you
only want to add or revise features. 
</p>
        <p>
So now all the new stuff is now part of the .NET Framework. That is a good, good,
good change. This says what it all is. 
</p>
        <p>
Admittedly confusing is the "3.0" bit. What we'll ship is a Framework 3.0 that rides
on top of the 2.0 CLR and includes the 2.0 versions of the Base-Class Library, Windows
Forms, and ASP.NET. It doesn't include the formerly-announced-as-to-be-part-of-3.0
technologies like VB9 (there you have the version number consistency flying out
the window outright), C# 3.0, and LINQ. Personally, I think that it might be
a tiny bit less confusing if the Framework had a version-number neutral name such
as ".NET Framework 2006" which would allow doing what we do now with less potential
for confusion, but only a tiny bit. Certainly not enough to stage a war
over "2006" vs. "3.0".
</p>
        <p>
It's a matter of project management reality and also one of platform predictability
that the ASP.NET, or Windows Forms teams do not and should not ship a full
major-version revision of their bits every year. They shipped Whidbey (2.0) in late
2005 and hence it's healthy for them to have boarded the scheduled-to-arrive-in-2007
boat heading to Orcas. We (the "WinFX" teams) subscribed to the Vista ship docking later
this year and we bring great innovation which will be preinstalled on every copy of
it. LINQ as well as VB9 and C# incorporating it on a language-level are
very obviously Visual Studio bound and hence they are on the Orcas ferry as well.
The .NET Framework is a steadily growing development platform that spans technologies
from the Developer Division, Connected Systems, Windows Server, Windows Client, SQL
Server, and other groups, and my gut feeling is that it will become the norm that
it will be extended off-cycle from the Developer Division's Visual Studio and
CLR releases. Whenever a big ship docks in the port, may it be Office, SQL, BizTalk,
Windows Server, or Windows Client, and as more and more of the still-unmanaged Win32/Win64
surface area gets wrapped, augmented or replaced by managed-code APIs over time and
entirely new things are added, there might be bits that fit into and update the
Framework.  
</p>
        <p>
So one sane way to think about the .NET Framework version number is that it merely
labels the overall package and not the individual assemblies and components included
within it. Up to 2.0 everything was pretty synchronized, but given the ever-increasing
scale of the thing, it's good to think of that being a lucky (even if intended) coindicence
of scheduling. This surely <a href="http://en.wikipedia.org/wiki/Microsoft_BackOffice">isn't
the first time</a> that packages were versioned independently of their components.
There was and is no reason for the ASP.NET team to gratuitously recompile their existing
bits with a new version number just to have the GAC look pretty and to create the
illusion that everything is new - and to break Visual Studio compatibility in the
process.
</p>
        <p>
Of course, once we cover 100% of the Win32 surface area, we can rename it all into
WinFX again ;-)  (just kidding)
</p>
        <p>
[All the usual "personal opinion" disclaimers apply to this post]
</p>
        <p>
          <font size="1">
            <em>Update:</em> Removed reference to "Win64".</font>
        </p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=57b03894-e197-4512-b9ea-648105890103" />
      </body>
      <title>Code-Name WinFX vs .NET Framework 3.0</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,57b03894-e197-4512-b9ea-648105890103.aspx</guid>
      <link>http://vasters.com/clemensv/2006/06/18/CodeName+WinFX+Vs+NET+Framework+30.aspx</link>
      <pubDate>Sun, 18 Jun 2006 12:39:48 GMT</pubDate>
      <description>&lt;p&gt;
I was sad when "Indigo" and "Avalon" went away. It'd be great&amp;nbsp;if we'd&amp;nbsp;have
a pool of cool legal-approved code-names for which we own the trademark rights and
which we could stick to.&amp;nbsp;Think Delphi or Safari. "Indigo" was cool insofar as
it was very handy to refer to the technology set, but&amp;nbsp;was removed&amp;nbsp;far&amp;nbsp;enough
from the specifics that it doesn't&amp;nbsp;create a sharply defined, product-like island
within the larger managed-code landscape or has legacy connotations&amp;nbsp;like "ADO.NET".
&amp;nbsp;Also, my talks these days could be 10 minutes shorter if I could refer to Indigo
instead of "Windows Communications Foundation". Likewise, my job title wouldn't have
to&amp;nbsp;have a line wrap on the business card of I ever spelled it out in full.
&lt;/p&gt;
&lt;p&gt;
However, when I learned about the WinFX name going away (several weeks before the
public announcement) and the new "Vista Wave" technologies (WPF/WF/WCF/WCS) being&amp;nbsp;rolled
up&amp;nbsp;under the&amp;nbsp;&lt;a href="http://msdn.microsoft.com/winfx/"&gt;.NET Framework&lt;/a&gt;&amp;nbsp;brand,
I was&amp;nbsp;quite happy. Ever since it became clear in 2004 that the grand plan to&amp;nbsp;put
a complete,&amp;nbsp;covers-all-and-everything&amp;nbsp;managed API on top (and on quite a
bit of the bottom) of everything Windows would have to wait until siginificantly after
Vista and that&amp;nbsp;therefore&amp;nbsp;the Win16&amp;gt;Win32&amp;gt;WinFX continuity would not
tell the true story, that name made only limited sense to stick to. The .NET Framework
is the #1 choice for business applications and a well established brand. People refer
to themselves as being "dotnet" developers. But even though the .NET Framework covers
a lot of ground and "Indigo", "Avalon", "InfoCard", and "Workflow" are&amp;nbsp;overwhelmingly
(or exclusively) managed-code based, there are still quite a few things in Windows
Vista that still require using P/Invoke or COM/Interop from managed code or unmanaged
code outright. That's not a problem.&amp;nbsp;Something has to manage the managed code
and there's no urgent need to rewrite entire subsystems to managed code if&amp;nbsp;you
only want to add or revise features.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
So now all the new stuff is now part of the .NET Framework. That is a good, good,
good&amp;nbsp;change. This says what it all is. 
&lt;/p&gt;
&lt;p&gt;
Admittedly confusing is the "3.0" bit. What we'll ship is a Framework 3.0 that rides
on top of the 2.0 CLR and includes the 2.0 versions of the Base-Class Library, Windows
Forms,&amp;nbsp;and ASP.NET. It doesn't include the formerly-announced-as-to-be-part-of-3.0
technologies like VB9 (there&amp;nbsp;you have the version number consistency flying out
the window outright), C# 3.0, and&amp;nbsp;LINQ. Personally, I think&amp;nbsp;that it might&amp;nbsp;be
a tiny bit less confusing if the Framework had a version-number neutral name such
as ".NET Framework 2006" which would allow&amp;nbsp;doing what we do now with less potential
for confusion, but only a tiny bit.&amp;nbsp;Certainly not enough to&amp;nbsp;stage a war
over "2006" vs. "3.0".
&lt;/p&gt;
&lt;p&gt;
It's a matter of project management&amp;nbsp;reality and also one of platform predictability
that the ASP.NET, or Windows Forms&amp;nbsp;teams&amp;nbsp;do not and should not ship a full
major-version revision of their bits every year. They shipped Whidbey (2.0) in late
2005 and hence&amp;nbsp;it's healthy for them&amp;nbsp;to&amp;nbsp;have boarded the scheduled-to-arrive-in-2007
boat heading to Orcas. We (the "WinFX" teams) subscribed to the Vista ship&amp;nbsp;docking&amp;nbsp;later
this year and we bring great innovation which will be preinstalled on every copy of
it. LINQ&amp;nbsp;as well as&amp;nbsp;VB9 and C# incorporating it on a language-level are
very obviously Visual Studio bound and hence they are on the Orcas ferry as well.
The .NET Framework is a steadily growing development platform that spans technologies
from the Developer Division, Connected Systems, Windows Server, Windows Client, SQL
Server, and other groups, and my gut feeling is that it will become the norm that
it will be extended off-cycle from the Developer Division's&amp;nbsp;Visual Studio and
CLR releases. Whenever a big ship docks in the port, may it be Office, SQL, BizTalk,
Windows Server, or Windows Client, and as more and more of the still-unmanaged Win32/Win64
surface area gets wrapped, augmented or replaced by managed-code APIs over time and
entirely new things are added, there might be bits that&amp;nbsp;fit into and update the
Framework. &amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
So one sane way to think about the .NET Framework version number is that&amp;nbsp;it merely
labels the overall package and not the individual assemblies and components included
within it. Up to 2.0&amp;nbsp;everything was pretty synchronized, but&amp;nbsp;given the ever-increasing
scale of the thing, it's good to think of that being a lucky (even if intended) coindicence
of scheduling. This surely &lt;a href="http://en.wikipedia.org/wiki/Microsoft_BackOffice"&gt;isn't
the first time&lt;/a&gt; that&amp;nbsp;packages were versioned independently of their components.
There was and is no reason for the ASP.NET team to gratuitously recompile their existing
bits with a new version number just to have the GAC look pretty and to create the
illusion that everything is new - and to break Visual Studio compatibility in the
process.
&lt;/p&gt;
&lt;p&gt;
Of course, once we cover 100% of the Win32 surface area, we can rename it all into
WinFX again ;-)&amp;nbsp; (just kidding)
&lt;/p&gt;
&lt;p&gt;
[All the usual&amp;nbsp;"personal opinion" disclaimers apply to this post]
&lt;/p&gt;
&lt;p&gt;
&lt;font size=1&gt;&lt;em&gt;Update:&lt;/em&gt; Removed reference to "Win64".&lt;/font&gt; 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=57b03894-e197-4512-b9ea-648105890103" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,57b03894-e197-4512-b9ea-648105890103.aspx</comments>
      <category>IT Strategy</category>
      <category>Technology</category>
      <category>Technology/ASP.NET</category>
      <category>Technology/Avalon</category>
      <category>Technology/CLR</category>
      <category>Technology/Indigo</category>
      <category>Technology/Longhorn</category>
      <category>Technology/WCF</category>
      <category>Technology/Windows</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=1e863a78-33d6-4a85-b5e2-f7d241b423d9</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,1e863a78-33d6-4a85-b5e2-f7d241b423d9.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,1e863a78-33d6-4a85-b5e2-f7d241b423d9.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=1e863a78-33d6-4a85-b5e2-f7d241b423d9</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.mcateer-roarty.info/blogs/the_roarty_blog/archive/2006/06/16/290.aspx">I've
been quoted</a> as to have said so at TechEd and I'll happily repeat it: "XML is the
assembly language of Web 2.0", even though some (and likely some more) disagree. <a href="http://www.codenameindigo.net/PermaLink.aspx?guid=a806afa2-2415-4e86-8ea4-88a312b1823b">James
Speer</a> writes <em>"<font face="MS Reference Sans Serif">Besides, Assembly
Language is hard, XML isn’t."</font></em> , which I have to disagree with. 
</p>
        <p>
True, throwing together some angle brackets isn't the hardest thing in the world,
but beating things into the right shape is hard and probably even harder than
in assembly. Yes, one can totally, after immersing oneself in the intricacies of Schema,
write complex types and ponder for days and months about the right use of attributes
and elements. It's absolutely within reach for a WSDL zealot to code up messages,
portTypes and operations by hand. But please, if you think that's the right way to
do things, I also demand that you write and apply your <a href="http://msdn.microsoft.com/ws/2005/07/ws-security-policy/">security
policy</a> in angle bracket notation from the top of your head and generate WCF config
from that using svcutil instead of just throwing a binding together, because
XML is so easy. Oh? Too hard? Well, it turns out that except for our developers
and testers who are focusing on getting these mappings right, nobody on our product
team would probably ever even want to try writing such a beast by hand for any code
that sits above the deep-down guts of our stack. This isn't the fault of the specifications
(or people here being ignorant), but it's a function of security being hard and the
related metadata being complex. Similar things, even though the complexity isn't
quite as extreme there, can be said about the other extensions to the policy
framework such as <a href="http://msdn.microsoft.com/library/en-us/dnglobspec/html/WS-RMPolicy.pdf">WS-RM
Policy</a> or those for <a href="http://msdn.microsoft.com/ws/2005/08/ws-atomictransaction/">WS-AT</a>. 
</p>
        <p>
As we're getting to the point where full range of functionality covered by WS-* specifications
is due to hit the mainstream by us releasing WCF and our valued competitors releasing
their respective implementations, hand-crafted contracts will become increasingly
meaningless, because it's beyond the capacity of anyone whose job it is to build solutions
for their customers to write complete set of contracts that not only ensures simple
data interop but also protocol interop. Just as there were days that all you
needed was assembly and INT21h to write a DOS program (yikes) or knowledge
of "C" alongside stdio.h and fellows to write anything for everthing, things
are changing now in the same way in Web Services land. Command of XSD and WSDL is
no longer sufficient, all the other stuff is just as important to make things work. 
</p>
        <p>
Our WCF [DataContract] doesn't support attributes. That's a deliberate choice because
we want to enforce simplicity and enhance interoperability of schemas. We put
an abstraction over XSD and limit the control over it, because we want to simplify
the stuff that goes across the wire. We certainly allow everyone to use the XmlSerializer
with all of it's attribute based fine-grained control over schema, even though there
are quite a few Schema constructs that even that doesn't support when building schema
from such metadata. If you choose to, you can just ignore all of our serialization
magic and fiddle with the XML Infoset outright and supply your own schema. However,
XML and Schema are specifications that everyone and their dog wanted to get features
into and Schema is hopelessly overengineered. Ever since we all (the industry, not
only MS) boarded the SOAP/WS train, we're debating how to constrain the features
of that monster to a reasonable subset that makes sense and the debate doesn't want
to end.
</p>
        <p>
James writes that he <em>"</em><font face="MS Reference Sans Serif"><em>take</em>[s]<em> a
lot of care in terms of elements vs. attributes and mak</em>[es]<em> sure the structure
of the XML is business-document-like", </em>which only really makes sense if XML documents
used in WS scenarios were meant for immediate human consumption, which they're not. </font></p>
        <p>
          <font face="Verdana">We want to promote a model that is simple and consistent to serialize
to and from on any platform and that things like the differentiation between
attributes and elements doesn't stand in the way of allowing a 1:1 mapping into alternate,
non-XML serialization formats such as JSON or what-have-you (most of which
don't care about that sort of differentiation).  </font>
          <font face="MS Reference Sans Serif">James'
statement about "business-document-like" structures is also interesting considering
EDIFACT, X.12 or SWIFT, all of which only know records, fields and values,
and don't care about that sort of subtle element/attribute differentation, either.
(Yes, no of those might be "hip" any more, but they are implemented and power a considerable
chunk of the world economy's data exchange).</font>
        </p>
        <p>
          <font face="MS Reference Sans Serif">By now, XML is the foundation for everything
that happens on the web, and I surely don't want to have it go away. But have arrived at
the point where matters have gotten so complicated that a layer of abstraction over
pretty much all things XML has become a necessity for everyone who makes their money
building customer solutions and not by teaching or writing about XML. In
my last session at TechEd, I asked a room of about 200 people "Who of you hand-writes
XSLT transforms?" 4 hands. "Who of you <em>used to</em> hand-write XSLT transforms?"
40+ hands. I think it's safe to assume that a bunch of those folks who have sworn
off masochism and no longer hand-code XSLT are now using tools like the BizTalk Mapper
or Altova's MapForce, which means that XSL/T is alive and kicking, but only downstairs
in the basement. However, the abstractions that these tools provide also allow
bypassing XSLT altogether and generate the transformation logic straight into compiled
C++, Java, or C# code, which is what MapForce offers. </font>
          <font face="MS Reference Sans Serif">WSDL
is already walking down that path.</font>
        </p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=1e863a78-33d6-4a85-b5e2-f7d241b423d9" />
      </body>
      <title>XML is the assembly language of Web 2.0</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,1e863a78-33d6-4a85-b5e2-f7d241b423d9.aspx</guid>
      <link>http://vasters.com/clemensv/2006/06/18/XML+Is+The+Assembly+Language+Of+Web+20.aspx</link>
      <pubDate>Sun, 18 Jun 2006 10:24:01 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.mcateer-roarty.info/blogs/the_roarty_blog/archive/2006/06/16/290.aspx"&gt;I've
been quoted&lt;/a&gt; as to have said so at TechEd and I'll happily repeat it: "XML is the
assembly language of Web 2.0", even though some (and likely some more) disagree. &lt;a href="http://www.codenameindigo.net/PermaLink.aspx?guid=a806afa2-2415-4e86-8ea4-88a312b1823b"&gt;James
Speer&lt;/a&gt;&amp;nbsp;writes&amp;nbsp;&lt;em&gt;"&lt;font face="MS Reference Sans Serif"&gt;Besides, Assembly
Language is hard, XML isn’t."&lt;/font&gt;&lt;/em&gt; ,&amp;nbsp;which I have to disagree with. 
&lt;/p&gt;
&lt;p&gt;
True, throwing together some angle brackets isn't the hardest thing in the world,
but beating things into the right&amp;nbsp;shape is hard and probably even harder than
in assembly. Yes, one can totally, after immersing oneself in the intricacies of Schema,
write complex types and ponder for days and months about the right use of attributes
and elements. It's absolutely within reach for a WSDL zealot to code up messages,
portTypes and operations by hand. But please, if you think that's the right way to
do things, I also demand that you write and apply your &lt;a href="http://msdn.microsoft.com/ws/2005/07/ws-security-policy/"&gt;security
policy&lt;/a&gt; in angle bracket notation from the top of your head and generate WCF config
from that using&amp;nbsp;svcutil instead of just throwing a binding together, because
XML is so easy.&amp;nbsp;Oh? Too hard? Well, it turns out that except for our developers
and testers who are focusing on getting these mappings right, nobody on our product
team would probably ever even want to try writing such a beast by hand for any code
that sits above the deep-down guts of our stack. This isn't the fault of the specifications
(or people here being ignorant), but it's a function of security being hard and the
related metadata being complex.&amp;nbsp;Similar things, even though the complexity isn't
quite as extreme there,&amp;nbsp;can be said about the&amp;nbsp;other extensions to the policy
framework such as &lt;a href="http://msdn.microsoft.com/library/en-us/dnglobspec/html/WS-RMPolicy.pdf"&gt;WS-RM
Policy&lt;/a&gt;&amp;nbsp;or those for&amp;nbsp;&lt;a href="http://msdn.microsoft.com/ws/2005/08/ws-atomictransaction/"&gt;WS-AT&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
As we're getting to the point where full range of functionality covered by WS-* specifications
is due to hit the mainstream by us releasing WCF and our valued competitors releasing
their respective implementations, hand-crafted contracts will become increasingly
meaningless, because it's beyond the capacity of anyone whose job it is to build solutions
for their customers to write complete set of contracts that not only ensures simple
data interop but also protocol interop.&amp;nbsp;Just as there were days that all you
needed was assembly and INT21h&amp;nbsp;to write a DOS program (yikes) or&amp;nbsp;knowledge
of "C"&amp;nbsp;alongside stdio.h and fellows to write anything for everthing, things
are changing now in the same way in Web Services land. Command of XSD and WSDL&amp;nbsp;is
no longer sufficient, all the other stuff is just as important to make things work. 
&lt;/p&gt;
&lt;p&gt;
Our WCF [DataContract] doesn't support attributes. That's a deliberate choice because
we want to enforce simplicity and enhance interoperability&amp;nbsp;of schemas. We put
an abstraction over XSD and limit the control over it, because we want to simplify
the stuff that goes across the wire. We certainly allow&amp;nbsp;everyone to use the XmlSerializer
with all of it's attribute based fine-grained control over schema, even though there
are quite a few Schema constructs that even that doesn't support when building schema
from such metadata. If you choose to, you can just ignore all of our serialization
magic and fiddle with the XML Infoset outright and supply your own schema. However,
XML and Schema are specifications that everyone and their dog wanted to get features
into and Schema is hopelessly overengineered. Ever since we all (the industry, not
only MS)&amp;nbsp;boarded the SOAP/WS train, we're debating how to constrain the features
of that monster to a reasonable subset that makes sense and the debate doesn't want
to end.
&lt;/p&gt;
&lt;p&gt;
James writes that he &lt;em&gt;"&lt;/em&gt;&lt;font face="MS Reference Sans Serif"&gt;&lt;em&gt;take&lt;/em&gt;[s]&lt;em&gt; a
lot of care in terms of elements vs. attributes and mak&lt;/em&gt;[es]&lt;em&gt; sure the structure
of the XML is business-document-like", &lt;/em&gt;which only really makes sense if XML documents
used in WS scenarios were meant for immediate human consumption, which they're not. &lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face=Verdana&gt;We want to promote a model that is simple and consistent to serialize
to and from on any platform and that&amp;nbsp;things like&amp;nbsp;the differentiation between
attributes and elements doesn't stand in the way of allowing a 1:1 mapping into&amp;nbsp;alternate,
non-XML&amp;nbsp;serialization formats such as JSON or what-have-you&amp;nbsp;(most of which
don't&amp;nbsp;care about that sort of differentiation).&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font face="MS Reference Sans Serif"&gt;James'
statement about "business-document-like" structures is also interesting&amp;nbsp;considering
EDIFACT, X.12&amp;nbsp;or SWIFT, all of which&amp;nbsp;only know records, fields and values,
and don't care about that sort of subtle element/attribute differentation, either.
(Yes, no of those might be "hip" any more, but they are implemented and power a considerable
chunk of the world economy's data exchange).&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="MS Reference Sans Serif"&gt;By now, XML is the foundation for everything
that happens on the web, and I surely don't want to have it go away. But have arrived&amp;nbsp;at
the point where matters have gotten so complicated that a layer of abstraction over
pretty much all things XML has become a necessity for everyone who makes their money
building customer solutions and not by&amp;nbsp;teaching or writing about XML.&amp;nbsp;In
my last session at TechEd, I asked a room of about 200 people "Who of you&amp;nbsp;hand-writes
XSLT transforms?" 4 hands. "Who of you &lt;em&gt;used to&lt;/em&gt;&amp;nbsp;hand-write XSLT transforms?"
40+ hands. I think it's safe to assume that a bunch of those folks who&amp;nbsp;have sworn
off masochism and no longer hand-code XSLT are now using tools like the BizTalk Mapper
or Altova's MapForce, which means that XSL/T is alive and kicking, but&amp;nbsp;only downstairs
in the basement.&amp;nbsp;However, the abstractions that these tools provide also allow
bypassing XSLT altogether and generate the transformation logic straight into compiled
C++, Java, or C# code, which is what MapForce offers.&amp;nbsp;&lt;/font&gt;&lt;font face="MS Reference Sans Serif"&gt;WSDL
is already walking down that path.&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=1e863a78-33d6-4a85-b5e2-f7d241b423d9" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,1e863a78-33d6-4a85-b5e2-f7d241b423d9.aspx</comments>
      <category>Talks/TechEd US</category>
      <category>Technology/Indigo</category>
      <category>Technology/WCF</category>
      <category>Technology/Web Services</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=479cc904-6008-4d1d-ae2a-c53d5d101ce6</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,479cc904-6008-4d1d-ae2a-c53d5d101ce6.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,479cc904-6008-4d1d-ae2a-c53d5d101ce6.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=479cc904-6008-4d1d-ae2a-c53d5d101ce6</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
My first of two sessions this week here at TechEd is on Thursday, at 2:45pm in room
153ABC on "Designing Bindings and Contracts". 
</p>
        <p>
I realize that the title sounds a bit abstract and a different way to put this would
be "How to choose the correct bindings and what to consider about contracts in a variety
of architectual scenarios", but that would have been a bit long as a title. in the
talk I'll explain the system-defined bindings that we ship in the product so that
we've got stuff to work with and then I'll get out the tablet pen and draw up a bunch
of scenarios and how our bindings (read: communication options) make sense in those.
What's the best choice for N-Tier inside and outside of the corporate perimeter, what
do you do for queueing-style apps, how do you implement volatile or durable 1:1 pub/sub,
how do you implement broadcasts and where do they make sense, etc. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=479cc904-6008-4d1d-ae2a-c53d5d101ce6" />
      </body>
      <title>TechEd: What I am going to talk about on Thursday</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,479cc904-6008-4d1d-ae2a-c53d5d101ce6.aspx</guid>
      <link>http://vasters.com/clemensv/2006/06/13/TechEd+What+I+Am+Going+To+Talk+About+On+Thursday.aspx</link>
      <pubDate>Tue, 13 Jun 2006 16:09:57 GMT</pubDate>
      <description>&lt;p&gt;
My first of two sessions this week here at TechEd is on Thursday, at 2:45pm in room
153ABC on "Designing Bindings and Contracts". 
&lt;/p&gt;
&lt;p&gt;
I realize that the title sounds a bit abstract and a different way to put this would
be "How to choose the correct bindings and what to consider about contracts in a variety
of architectual scenarios", but that would have been a bit long as a title. in the
talk I'll explain the system-defined bindings that we ship in the product so that
we've got stuff to work with and then I'll get out the tablet pen and draw up a bunch
of scenarios and how our bindings (read: communication options) make sense in those.
What's the best choice for N-Tier inside and outside of the corporate perimeter, what
do you do for queueing-style apps, how do you implement volatile or durable 1:1 pub/sub,
how do you implement broadcasts and where do they make sense, etc. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=479cc904-6008-4d1d-ae2a-c53d5d101ce6" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,479cc904-6008-4d1d-ae2a-c53d5d101ce6.aspx</comments>
      <category>Architecture</category>
      <category>Technology/Indigo</category>
      <category>Technology/WCF</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=ca3a1146-4d0e-45a5-9369-9a74ffdeda71</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,ca3a1146-4d0e-45a5-9369-9a74ffdeda71.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,ca3a1146-4d0e-45a5-9369-9a74ffdeda71.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=ca3a1146-4d0e-45a5-9369-9a74ffdeda71</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
We've just released the "<a href="http://wcf.netfx3.com/files/folders/encoders/entry3262.aspx">Windows
Communication Foundation RSS Toolkit</a>" on our new community site. This toolkit,
which comes with complete source code, illustrates how to expose ATOM and RSS
feeds through WCF endpoints. I will discuss the toolkit in my session <strong>CON339,
Room 107ABC, Friday 10:45am</strong> here at TechEd. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=ca3a1146-4d0e-45a5-9369-9a74ffdeda71" />
      </body>
      <title>TechEd: WCF RSS Toolkit released</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,ca3a1146-4d0e-45a5-9369-9a74ffdeda71.aspx</guid>
      <link>http://vasters.com/clemensv/2006/06/13/TechEd+WCF+RSS+Toolkit+Released.aspx</link>
      <pubDate>Tue, 13 Jun 2006 14:23:12 GMT</pubDate>
      <description>&lt;p&gt;
We've just released the "&lt;a href="http://wcf.netfx3.com/files/folders/encoders/entry3262.aspx"&gt;Windows
Communication Foundation RSS Toolkit&lt;/a&gt;" on our new community site. This toolkit,
which comes with complete source code,&amp;nbsp;illustrates how to expose ATOM and RSS
feeds through WCF endpoints. I will discuss the toolkit in my session &lt;strong&gt;CON339,
Room 107ABC, Friday 10:45am&lt;/strong&gt; here at TechEd. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=ca3a1146-4d0e-45a5-9369-9a74ffdeda71" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,ca3a1146-4d0e-45a5-9369-9a74ffdeda71.aspx</comments>
      <category>Talks/TechEd US</category>
      <category>Technology/Indigo</category>
      <category>Technology/WCF</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=62b10909-f329-4cc6-8a7e-a9123559a7b9</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,62b10909-f329-4cc6-8a7e-a9123559a7b9.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,62b10909-f329-4cc6-8a7e-a9123559a7b9.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=62b10909-f329-4cc6-8a7e-a9123559a7b9</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Just so that you know: In addition to the regular breakout sessions, we have a number
of interactive <a href="http://wcf.netfx3.com/content/TechEd2006ChalkTalkSchedule.aspx">chalk
talks</a> scheduled here at the Connected Systems Technical Learning Center in the
Expo Hall. Come by.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=62b10909-f329-4cc6-8a7e-a9123559a7b9" />
      </body>
      <title>TechEd: WCF and Workflow Chalk Talks</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,62b10909-f329-4cc6-8a7e-a9123559a7b9.aspx</guid>
      <link>http://vasters.com/clemensv/2006/06/12/TechEd+WCF+And+Workflow+Chalk+Talks.aspx</link>
      <pubDate>Mon, 12 Jun 2006 14:38:15 GMT</pubDate>
      <description>&lt;p&gt;
Just so that you know: In addition to the regular breakout sessions, we have a number
of interactive &lt;a href="http://wcf.netfx3.com/content/TechEd2006ChalkTalkSchedule.aspx"&gt;chalk
talks&lt;/a&gt; scheduled here at the Connected Systems Technical Learning Center in the
Expo Hall. Come by.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=62b10909-f329-4cc6-8a7e-a9123559a7b9" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,62b10909-f329-4cc6-8a7e-a9123559a7b9.aspx</comments>
      <category>Talks/TechEd US</category>
      <category>Technology</category>
      <category>Technology/Indigo</category>
      <category>Technology/WCF</category>
      <category>Technology/Workflow</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=76e10b03-8d1a-4e17-82c8-32a14f8debae</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,76e10b03-8d1a-4e17-82c8-32a14f8debae.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,76e10b03-8d1a-4e17-82c8-32a14f8debae.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=76e10b03-8d1a-4e17-82c8-32a14f8debae</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This is my first TechEd! - as a Microsoft employee. It's of course not my first tech
event in my new job (Egypt, Jordan, UK, France, Switzerland, Holland, Belgium, Denmark,
Las Vegas/USA, Slovenia, and Israel are on the year-to-date list - on top
of three long-distance commutes to Redmond), but the big TechEds are always special.
It'll be fun. Come by the Connected Systems area in the exhibition hall and find me
to chat if you are here in Boston.
</p>
        <p>
Frankly, I didn't expect a Sunday night keynote to be nearly as well attended as it
was, but it looks that experiment mostly worked. The theme of the keynote were <a href="http://www.microsoft.com/presspass/features/2006/jun06/06-11Promises.mspx">Microsoft's
4 Core Promises</a> for IT Pros and Developers nicely wrapped into a video story based
on the TV show "24" and with that show's IT superwoman Chloe O'Brian (actress <a href="http://imdb.com/name/nm0707476/">Mary
Lynn Rajskub</a>) up on stage with Bob Muglia (our team's VP far up above in my chain
of command), who acted as the MC for the show. Finally we got an apology
from a Hollywood character for all the IT idiocy the put up on screen. Thanks, Chloe.
</p>
        <p>
Our team has a lot of very cool stuff to talk about at this show. The first highlight
is John Justice's WCF Intro talk (Session CON208, Room 157ABC) <strong>today at 5:00pm</strong> with
a "meet the team" panel Q&amp;A session at the end. Block the time.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=76e10b03-8d1a-4e17-82c8-32a14f8debae" />
      </body>
      <title>TechEd 2006 U.S. Kicks Off</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,76e10b03-8d1a-4e17-82c8-32a14f8debae.aspx</guid>
      <link>http://vasters.com/clemensv/2006/06/12/TechEd+2006+US+Kicks+Off.aspx</link>
      <pubDate>Mon, 12 Jun 2006 12:48:51 GMT</pubDate>
      <description>&lt;p&gt;
This is my first TechEd! - as a Microsoft employee. It's of course not my first tech
event in my new job (Egypt, Jordan, UK, France, Switzerland, Holland, Belgium, Denmark,
Las Vegas/USA, Slovenia, and Israel&amp;nbsp;are on the year-to-date list -&amp;nbsp;on top
of&amp;nbsp;three long-distance commutes to Redmond), but the big TechEds are always special.
It'll be fun. Come by the Connected Systems area in the exhibition hall and find me
to chat if you are here in Boston.
&lt;/p&gt;
&lt;p&gt;
Frankly, I didn't expect a Sunday night keynote to be nearly as well attended as it
was, but it looks that experiment mostly worked. The theme of the keynote were&amp;nbsp;&lt;a href="http://www.microsoft.com/presspass/features/2006/jun06/06-11Promises.mspx"&gt;Microsoft's
4 Core Promises&lt;/a&gt; for IT Pros and Developers nicely wrapped into a video story based
on the TV show "24" and with that show's&amp;nbsp;IT superwoman&amp;nbsp;Chloe O'Brian (actress &lt;a href="http://imdb.com/name/nm0707476/"&gt;Mary
Lynn Rajskub&lt;/a&gt;) up on stage with Bob Muglia (our team's VP far up above in my chain
of command), who&amp;nbsp;acted as&amp;nbsp;the MC for the show. Finally we got an apology
from a Hollywood character for all the IT idiocy the put up on screen. Thanks, Chloe.
&lt;/p&gt;
&lt;p&gt;
Our team has a lot of very cool stuff to&amp;nbsp;talk about at this show. The first highlight
is John Justice's WCF Intro talk (Session CON208, Room 157ABC) &lt;strong&gt;today at 5:00pm&lt;/strong&gt; with
a "meet the team" panel Q&amp;amp;A session at the end.&amp;nbsp;Block the time.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=76e10b03-8d1a-4e17-82c8-32a14f8debae" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,76e10b03-8d1a-4e17-82c8-32a14f8debae.aspx</comments>
      <category>Technology</category>
      <category>Technology/Indigo</category>
      <category>Technology/WCF</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=47add500-56af-4611-83f1-b13c8068a6f8</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,47add500-56af-4611-83f1-b13c8068a6f8.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,47add500-56af-4611-83f1-b13c8068a6f8.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=47add500-56af-4611-83f1-b13c8068a6f8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Late last night, my colleague <a href="http://blogs.msdn.com/jamescon/default.aspx">James
Conard</a>, who has worked and worked and worked tirelessly on this for the past
few months and has shown great patience with a big group of people pulling into
all sorts of directions as we got this together has flipped the switch to turn
on the new .NET Framework 3.0 community portal family at <a href="http://www.netfx3.com/">netfx3.com</a></p>
        <p>
The new Windows Communication Foundation community home is at <a href="http://wcf.netfx3.com/">http://wcf.netfx3.com</a> and
it's a great improvement over the small, hastily-thown-together site that we used
to have. There'll be a number of news bits and announcements throughout and after
TechEd at the new site, so it might be a good idea to subscribe to <a href="http://wcf.netfx3.com/blogs/news_and_announcements/rss.aspx">the
feed</a> now. 
</p>
        <p>
My official "Welcome!" post over on the new site is <a href="http://wcf.netfx3.com/blogs/news_and_announcements/archive/2006/06/12/Come-on-in_2100_-Welcome-to-our-new-home_2100_.aspx">here</a>,
the James' site-wide welcome message can be found <a href="http://www.netfx3.com/blogs/news_and_announcements/archive/2006/06/11/Welcome-to-NetFx3.com.aspx">here</a>.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=47add500-56af-4611-83f1-b13c8068a6f8" />
      </body>
      <title>A New Home on the Web for the Windows Communication Foundation and the .NET Framework 3.0</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,47add500-56af-4611-83f1-b13c8068a6f8.aspx</guid>
      <link>http://vasters.com/clemensv/2006/06/12/A+New+Home+On+The+Web+For+The+Windows+Communication+Foundation+And+The+NET+Framework+30.aspx</link>
      <pubDate>Mon, 12 Jun 2006 12:03:33 GMT</pubDate>
      <description>&lt;p&gt;
Late last night, my colleague &lt;a href="http://blogs.msdn.com/jamescon/default.aspx"&gt;James
Conard&lt;/a&gt;, who has worked and worked&amp;nbsp;and worked tirelessly on this for the&amp;nbsp;past
few months&amp;nbsp;and has shown great patience with a big group of people pulling into
all sorts of directions as we got this together&amp;nbsp;has flipped the switch to turn
on the new .NET Framework 3.0 community portal family at &lt;a href="http://www.netfx3.com/"&gt;netfx3.com&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The new Windows Communication Foundation community home is at &lt;a href="http://wcf.netfx3.com/"&gt;http://wcf.netfx3.com&lt;/a&gt; and
it's a great improvement over the small, hastily-thown-together site that we used
to have. There'll be a number of news bits and announcements throughout and after
TechEd at the new site, so it might be a good idea to subscribe to &lt;a href="http://wcf.netfx3.com/blogs/news_and_announcements/rss.aspx"&gt;the
feed&lt;/a&gt;&amp;nbsp;now.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
My official "Welcome!" post over on the new site is &lt;a href="http://wcf.netfx3.com/blogs/news_and_announcements/archive/2006/06/12/Come-on-in_2100_-Welcome-to-our-new-home_2100_.aspx"&gt;here&lt;/a&gt;,
the James' site-wide welcome message can be found &lt;a href="http://www.netfx3.com/blogs/news_and_announcements/archive/2006/06/11/Welcome-to-NetFx3.com.aspx"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=47add500-56af-4611-83f1-b13c8068a6f8" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,47add500-56af-4611-83f1-b13c8068a6f8.aspx</comments>
      <category>Technology/Indigo</category>
      <category>Technology/WCF</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=24a2c6a4-e043-464c-8c60-189ecea3460d</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,24a2c6a4-e043-464c-8c60-189ecea3460d.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,24a2c6a4-e043-464c-8c60-189ecea3460d.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=24a2c6a4-e043-464c-8c60-189ecea3460d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
My PM colleague <a href="http://blogs.msdn.com/drnick">Nicholas Allen</a> is certainly
on my list for "best blogging newcomer of 2006".  He started in February, got
hooked, and I am not sure whether he actually did leave the keyboard since then.
</p>
        <p>
Nicholas just started a blog series that explains the system-defined (formely known
as: standard-) bindings that we ship with WCF. He's got three of them explained
now and my guess is that there are more to follow:
</p>
        <ul>
          <li>
            <a href="http://blogs.msdn.com/drnick/archive/2006/06/01/612672.aspx">BasicHttpBinding</a> </li>
          <li>
            <a href="http://blogs.msdn.com/drnick/archive/2006/06/05/617703.aspx">NetTcpBinding</a>
          </li>
          <li>
            <a href="http://blogs.msdn.com/drnick/archive/2006/06/06/618445.aspx">NetNamedPipeBinding</a>
          </li>
        </ul>
        <p>
While you are there, make sure to subscribe to Nicholas' <a href="http://blogs.msdn.com/drnick/rss.aspx">feed</a> and
also take a look around and look at earlier posts. His <a href="http://blogs.msdn.com/drnick/archive/category/12220.aspx">channel
category</a> is a gold mine and the same can be said of the <a href="http://blogs.msdn.com/drnick/archive/category/13324.aspx">transports</a> and
... everything there is fabulous stuff.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=24a2c6a4-e043-464c-8c60-189ecea3460d" />
      </body>
      <title>The System-Defined Bindings in WCF: Nicholas Allen explains it all</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,24a2c6a4-e043-464c-8c60-189ecea3460d.aspx</guid>
      <link>http://vasters.com/clemensv/2006/06/06/The+SystemDefined+Bindings+In+WCF+Nicholas+Allen+Explains+It+All.aspx</link>
      <pubDate>Tue, 06 Jun 2006 20:50:22 GMT</pubDate>
      <description>&lt;p&gt;
My PM colleague &lt;a href="http://blogs.msdn.com/drnick"&gt;Nicholas Allen&lt;/a&gt; is certainly
on my list for "best blogging newcomer of 2006". &amp;nbsp;He started in February, got
hooked, and I am not sure whether he actually did&amp;nbsp;leave the keyboard since then.
&lt;/p&gt;
&lt;p&gt;
Nicholas just started a blog series that explains the system-defined (formely known
as: standard-) bindings&amp;nbsp;that we ship with WCF. He's got three of them&amp;nbsp;explained
now and my guess is that there are more to follow:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://blogs.msdn.com/drnick/archive/2006/06/01/612672.aspx"&gt;BasicHttpBinding&lt;/a&gt;&amp;nbsp;&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://blogs.msdn.com/drnick/archive/2006/06/05/617703.aspx"&gt;NetTcpBinding&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://blogs.msdn.com/drnick/archive/2006/06/06/618445.aspx"&gt;NetNamedPipeBinding&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
While you are there, make sure to subscribe to Nicholas' &lt;a href="http://blogs.msdn.com/drnick/rss.aspx"&gt;feed&lt;/a&gt; and
also take a look around and look at earlier posts. His &lt;a href="http://blogs.msdn.com/drnick/archive/category/12220.aspx"&gt;channel
category&lt;/a&gt; is a gold mine and the same can be said of the &lt;a href="http://blogs.msdn.com/drnick/archive/category/13324.aspx"&gt;transports&lt;/a&gt; and
... everything there is fabulous stuff.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=24a2c6a4-e043-464c-8c60-189ecea3460d" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,24a2c6a4-e043-464c-8c60-189ecea3460d.aspx</comments>
      <category>Technology/Indigo</category>
      <category>Technology/WCF</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=069972fe-b2f9-4c6f-83f8-b61e7e310cc7</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,069972fe-b2f9-4c6f-83f8-b61e7e310cc7.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,069972fe-b2f9-4c6f-83f8-b61e7e310cc7.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=069972fe-b2f9-4c6f-83f8-b61e7e310cc7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <em>Christian Weyer stars in a new episode of the </em>
          <a href="http://www.dotnetpro.de/articles/webarticle13.aspx">
            <em>German
dotnetproTV series</em>
          </a>
          <em> and masterfully explains the Windows Communication
Foundation. If you don't understand German, you may still enjoy Christian's flip-chart
skills and overall good looks. ;-)</em>
        </p>
        <p>
          <a href="http://blogs.thinktecture.com/cweyer/">Christian Weyer</a> – Microsoft Regional
Director und allgemein anerkannter und geschätzter Web Services Erklärbar – ist
der  Star der neuesten dotnetproTV Episode zum Thema Windows Communication Foundation.
Ich habe mir die Episode gerade angesehen und … Holla die Waldfee! … das ist einer
der besten Überblicke zu WCF, die ich bisher gesehen habe! Und der Dialog mit <a href="http://weblogs.asp.net/ralfw">Ralf
Westphal</a> ist natürlich kurzweilig und interessant wie immer. Hut ab!
</p>
        <p>
Und weil mir das Thema natürlich am Herzen liegt bin ich sehr froh, daß dotnetpro
für diese Folge nicht nur einen „Teaser“ zur Verfügung stellt, sondern Christians
ganze Show in der ganzen 370MB großen Herrlichkeit (der Link zum Video ist in der
orangefarbenen Kiste <a href="http://www.dotnetpro.de/articles/webarticle13.aspx">hier
auf der Seite</a>). Runterladen! Gucken! 
<br /></p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=069972fe-b2f9-4c6f-83f8-b61e7e310cc7" />
      </body>
      <title>Christian Weyer explains WCF (... in German)</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,069972fe-b2f9-4c6f-83f8-b61e7e310cc7.aspx</guid>
      <link>http://vasters.com/clemensv/2006/06/06/Christian+Weyer+Explains+WCF+In+German.aspx</link>
      <pubDate>Tue, 06 Jun 2006 18:12:59 GMT</pubDate>
      <description>&lt;p&gt;
&lt;em&gt;Christian Weyer stars in a new episode of the &lt;/em&gt;&lt;a href="http://www.dotnetpro.de/articles/webarticle13.aspx"&gt;&lt;em&gt;German
dotnetproTV series&lt;/em&gt;&lt;/a&gt;&lt;em&gt;&amp;nbsp;and masterfully explains the Windows Communication
Foundation. If you don't understand German, you may still enjoy Christian's flip-chart
skills and overall good looks. ;-)&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://blogs.thinktecture.com/cweyer/"&gt;Christian Weyer&lt;/a&gt; – Microsoft Regional
Director und allgemein anerkannter&amp;nbsp;und geschätzter Web Services Erklärbar – ist
der&amp;nbsp; Star der neuesten dotnetproTV Episode zum Thema Windows Communication Foundation.
Ich habe mir die Episode gerade angesehen und … Holla die Waldfee! … das ist einer
der besten Überblicke zu WCF, die ich bisher gesehen habe! Und der Dialog mit &lt;a href="http://weblogs.asp.net/ralfw"&gt;Ralf
Westphal&lt;/a&gt; ist natürlich kurzweilig und interessant wie immer. Hut ab!
&lt;/p&gt;
&lt;p&gt;
Und weil mir das Thema natürlich am Herzen liegt bin ich sehr froh, daß dotnetpro
für diese Folge nicht nur einen „Teaser“ zur Verfügung stellt, sondern Christians
ganze Show in der ganzen 370MB großen Herrlichkeit (der Link zum Video ist in der
orangefarbenen Kiste &lt;a href="http://www.dotnetpro.de/articles/webarticle13.aspx"&gt;hier
auf der Seite&lt;/a&gt;). Runterladen! Gucken! 
&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=069972fe-b2f9-4c6f-83f8-b61e7e310cc7" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,069972fe-b2f9-4c6f-83f8-b61e7e310cc7.aspx</comments>
      <category>Technology/Indigo</category>
      <category>Technology/WCF</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=b78973da-fe9e-4d65-8720-c41b69e8aaf8</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,b78973da-fe9e-4d65-8720-c41b69e8aaf8.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,b78973da-fe9e-4d65-8720-c41b69e8aaf8.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=b78973da-fe9e-4d65-8720-c41b69e8aaf8</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
(via <a href="http://windowscommunication.net">http://windowscommunication.net</a>) 
</p>
        <p>
The WCF Documentation Team has started to release biweekly (!) documentation updates.
The updates are made available as a set of .CHM files. 
</p>
        <p>
Mind that these files do not integrate directly into Visual Studio as the WinFX Windows
SDK files do. Since VS integration requires quite a bit of setup work, the VS integrated
help files can only ship with the regular WinFX Windows SDK CTPs. Nevertheless, the
feedback from all customers we asked told us loud and clear that
we should ship the documentation in this form irrespective of this minor
usability inconvenience and therefore we do.
</p>
        <p>
If you have feedback on the documentation, please use the "Send comments about this
topic to Microsoft" email links below each documentation entry to provide feedback.
Due to the volume that our team receives, you might not always get an answer, but
your input is most definitely read and considered.
</p>
        <p>
You can download the first (April 15) Documentation CTP directly <a href="http://windowscommunication.net/collateral/downloads/wcfdocctp-20060415.exe">using
this link</a> (20MB).
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=b78973da-fe9e-4d65-8720-c41b69e8aaf8" />
      </body>
      <title>Windows Communication Foundation "Documentation CTP"</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,b78973da-fe9e-4d65-8720-c41b69e8aaf8.aspx</guid>
      <link>http://vasters.com/clemensv/2006/04/17/Windows+Communication+Foundation+Documentation+CTP.aspx</link>
      <pubDate>Mon, 17 Apr 2006 10:24:05 GMT</pubDate>
      <description>&lt;p&gt;
(via &lt;a href="http://windowscommunication.net"&gt;http://windowscommunication.net&lt;/a&gt;) 
&lt;/p&gt;
&lt;p&gt;
The WCF Documentation Team has started to release biweekly (!) documentation updates.
The updates&amp;nbsp;are made available as a set of .CHM files. 
&lt;/p&gt;
&lt;p&gt;
Mind that these files do not integrate directly into Visual Studio as the WinFX Windows
SDK files do. Since VS integration requires quite a bit of setup work, the VS integrated
help files can only ship with the regular WinFX Windows SDK CTPs. Nevertheless, the
feedback&amp;nbsp;from all&amp;nbsp;customers we asked&amp;nbsp;told us loud and clear&amp;nbsp;that
we should ship the documentation in this form&amp;nbsp;irrespective of&amp;nbsp;this minor
usability inconvenience and&amp;nbsp;therefore we do.
&lt;/p&gt;
&lt;p&gt;
If you have feedback on the documentation, please use the "Send comments about this
topic to Microsoft" email links below each documentation entry to provide feedback.
Due to the volume that our team receives, you might not always get an answer, but
your input is most definitely read and considered.
&lt;/p&gt;
&lt;p&gt;
You can download the first (April 15) Documentation CTP directly &lt;a href="http://windowscommunication.net/collateral/downloads/wcfdocctp-20060415.exe"&gt;using
this link&lt;/a&gt;&amp;nbsp;(20MB).
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=b78973da-fe9e-4d65-8720-c41b69e8aaf8" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,b78973da-fe9e-4d65-8720-c41b69e8aaf8.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=6a04b1ca-97ce-4ab9-a68c-adbcc2ac11be</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,6a04b1ca-97ce-4ab9-a68c-adbcc2ac11be.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,6a04b1ca-97ce-4ab9-a68c-adbcc2ac11be.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=6a04b1ca-97ce-4ab9-a68c-adbcc2ac11be</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://hyperthink.net/blog/2006/04/12/Checkin+1383521.aspx">Checked in.</a>
        </p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=6a04b1ca-97ce-4ab9-a68c-adbcc2ac11be" />
      </body>
      <title>POX just got the WCF Permanent Residence Visa.</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,6a04b1ca-97ce-4ab9-a68c-adbcc2ac11be.aspx</guid>
      <link>http://vasters.com/clemensv/2006/04/13/POX+Just+Got+The+WCF+Permanent+Residence+Visa.aspx</link>
      <pubDate>Thu, 13 Apr 2006 08:07:08 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://hyperthink.net/blog/2006/04/12/Checkin+1383521.aspx"&gt;Checked in.&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=6a04b1ca-97ce-4ab9-a68c-adbcc2ac11be" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,6a04b1ca-97ce-4ab9-a68c-adbcc2ac11be.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=b9a1d71d-9214-4816-8da0-9a33aef61b59</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,b9a1d71d-9214-4816-8da0-9a33aef61b59.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,b9a1d71d-9214-4816-8da0-9a33aef61b59.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=b9a1d71d-9214-4816-8da0-9a33aef61b59</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://kennyw.com/indigo/112">As Kenny points out</a>, the WCF Core Communications
team put together a <a href="http://windowscommunication.net/customchannels/customchannels.htm">great
set of resources with documentation and samples for writing custom channels for
WCF</a>. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=b9a1d71d-9214-4816-8da0-9a33aef61b59" />
      </body>
      <title>Resources for Custom Channel Authors</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,b9a1d71d-9214-4816-8da0-9a33aef61b59.aspx</guid>
      <link>http://vasters.com/clemensv/2006/04/09/Resources+For+Custom+Channel+Authors.aspx</link>
      <pubDate>Sun, 09 Apr 2006 10:43:49 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://kennyw.com/indigo/112"&gt;As Kenny points out&lt;/a&gt;, the WCF Core Communications
team put together a &lt;a href="http://windowscommunication.net/customchannels/customchannels.htm"&gt;great
set of resources with documentation and samples&amp;nbsp;for writing custom channels for
WCF&lt;/a&gt;. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=b9a1d71d-9214-4816-8da0-9a33aef61b59" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,b9a1d71d-9214-4816-8da0-9a33aef61b59.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=0890e4b4-52cf-4447-8c18-629a28ad6355</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,0890e4b4-52cf-4447-8c18-629a28ad6355.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,0890e4b4-52cf-4447-8c18-629a28ad6355.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=0890e4b4-52cf-4447-8c18-629a28ad6355</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Matias Woloski writes about <a href="http://staff.southworks.net/blogs/matiaswoloski/archive/2006/04/06/ClickonceWCF.aspx">ClickOnce
and WCF</a> and provides a complete solution path for setting it up and also
talks about our "Full Trust" constraint that I <a href="http://friends.newtelligence.net/clemensv/PermaLink,guid,b99db04c-f2d0-4850-8d9f-8048608ea7cd.aspx">explained</a> a
few weeks ago.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=0890e4b4-52cf-4447-8c18-629a28ad6355" />
      </body>
      <title>WCF &amp; ClickOnce</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,0890e4b4-52cf-4447-8c18-629a28ad6355.aspx</guid>
      <link>http://vasters.com/clemensv/2006/04/09/WCF+ClickOnce.aspx</link>
      <pubDate>Sun, 09 Apr 2006 08:57:30 GMT</pubDate>
      <description>&lt;p&gt;
Matias Woloski writes about &lt;a href="http://staff.southworks.net/blogs/matiaswoloski/archive/2006/04/06/ClickonceWCF.aspx"&gt;ClickOnce
and WCF&lt;/a&gt;&amp;nbsp;and provides a complete solution path for setting it up and also
talks&amp;nbsp;about our "Full Trust" constraint that I&amp;nbsp;&lt;a href="http://friends.newtelligence.net/clemensv/PermaLink,guid,b99db04c-f2d0-4850-8d9f-8048608ea7cd.aspx"&gt;explained&lt;/a&gt; a
few weeks ago.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=0890e4b4-52cf-4447-8c18-629a28ad6355" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,0890e4b4-52cf-4447-8c18-629a28ad6355.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=6fed9c00-fdfa-436c-8a51-192b1f48634d</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,6fed9c00-fdfa-436c-8a51-192b1f48634d.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,6fed9c00-fdfa-436c-8a51-192b1f48634d.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=6fed9c00-fdfa-436c-8a51-192b1f48634d</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
My grand boss ... if someone had told me this a year back ... but it turns out
that it is a great blessing ... anyways .... My grand boss, the magnificient Doug
Purdy <a href="http://www.douglasp.com/blog/PermaLink.aspx?guid=0cc78757-ae6c-4ead-b8c0-93ef69f56234">points
to</a> our <strong>best kept secret</strong>: You can actually do Remoting-style
distributed objects with WCF as <a href="http://blogs.msdn.com/sowmy/archive/2006/03/26/561188.aspx">Sowmy</a> and <a href="http://blogs.msdn.com/mjm/archive/2005/05/12/417035.aspx">Michael</a> explain.
</p>
        <p>
          <em>Update:</em> Tomas Restrepo <a href="http://www.winterdom.com/weblog/2006/04/08/RemotingStyleDistributedObjectsWithWCF.aspx">asks</a> why
that is good. Let me clarify: I think the transparent, distributed objects
way of doing things is very problematic, but there are some scenarios where they are
a feasible solution and there are migration scenarios where you don't have much of
a choice. As a platform provider, we have a mainstream path (SO) that we prefer and
that's represented in our turnkey scenarios, but we cannot and will not be as dogmatic
as to shut the door on different architecture styles. We don't do that on REST/POX
on one side and we don't do that on distributed objects on the other side of the spectrum.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=6fed9c00-fdfa-436c-8a51-192b1f48634d" />
      </body>
      <title>Remoting Style Distributed Objects with WCF</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,6fed9c00-fdfa-436c-8a51-192b1f48634d.aspx</guid>
      <link>http://vasters.com/clemensv/2006/04/08/Remoting+Style+Distributed+Objects+With+WCF.aspx</link>
      <pubDate>Sat, 08 Apr 2006 11:37:12 GMT</pubDate>
      <description>&lt;p&gt;
My grand boss ... if someone had told me this&amp;nbsp;a year back ... but it turns out
that&amp;nbsp;it is a great blessing ... anyways .... My grand boss, the magnificient&amp;nbsp;Doug
Purdy &lt;a href="http://www.douglasp.com/blog/PermaLink.aspx?guid=0cc78757-ae6c-4ead-b8c0-93ef69f56234"&gt;points
to&lt;/a&gt;&amp;nbsp;our &lt;strong&gt;best kept secret&lt;/strong&gt;: You can actually do Remoting-style
distributed objects with WCF as &lt;a href="http://blogs.msdn.com/sowmy/archive/2006/03/26/561188.aspx"&gt;Sowmy&lt;/a&gt; and &lt;a href="http://blogs.msdn.com/mjm/archive/2005/05/12/417035.aspx"&gt;Michael&lt;/a&gt; explain.
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;Update:&lt;/em&gt; Tomas Restrepo &lt;a href="http://www.winterdom.com/weblog/2006/04/08/RemotingStyleDistributedObjectsWithWCF.aspx"&gt;asks&lt;/a&gt; why
that is good. Let me clarify:&amp;nbsp;I think the transparent,&amp;nbsp;distributed objects
way of doing things is very problematic, but there are some scenarios where they are
a feasible solution and there are migration scenarios where you don't have much of
a choice. As a platform provider, we have a mainstream path (SO) that we prefer and
that's represented in our turnkey scenarios, but we cannot and will not be as dogmatic
as to shut the door on different architecture styles. We don't do that on REST/POX
on one side and we don't do that on distributed objects on the other side of the spectrum.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=6fed9c00-fdfa-436c-8a51-192b1f48634d" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,6fed9c00-fdfa-436c-8a51-192b1f48634d.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=a7a3cdee-9919-4d4d-8594-c77cba5481ee</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,a7a3cdee-9919-4d4d-8594-c77cba5481ee.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,a7a3cdee-9919-4d4d-8594-c77cba5481ee.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=a7a3cdee-9919-4d4d-8594-c77cba5481ee</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The WinFX Tour is coming to Europe! 
</p>
        <p>
Mark it in your calendar and, if you can, <a href="http://www.microsoft.com/emea/msdn/event_winfxtour.aspx">sign
up!</a> Locations: Rotterdam (20 Apr), Nice (25 Apr), Zurich (2 May), Copenhagen (4
May), London (9 May), Eilat/IL (9 May), Reading/UK (10 May), Cairo (15 May), Moscow
(19 May) 
</p>
        <p>
I'll be speaking at the Zurich, Copenhagen, and Eilat (TechEd Israel) events.
</p>
        <p>
[If the event near you does not have a sign-up page linked, watch your local MSDN
portal or MSDN newsletters for updates]
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=a7a3cdee-9919-4d4d-8594-c77cba5481ee" />
      </body>
      <title>EMEA WinFX Tour </title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,a7a3cdee-9919-4d4d-8594-c77cba5481ee.aspx</guid>
      <link>http://vasters.com/clemensv/2006/04/08/EMEA+WinFX+Tour.aspx</link>
      <pubDate>Sat, 08 Apr 2006 11:09:30 GMT</pubDate>
      <description>&lt;p&gt;
The WinFX Tour is coming to Europe! 
&lt;/p&gt;
&lt;p&gt;
Mark it in&amp;nbsp;your calendar and, if you can,&amp;nbsp;&lt;a href="http://www.microsoft.com/emea/msdn/event_winfxtour.aspx"&gt;sign
up!&lt;/a&gt; Locations: Rotterdam (20 Apr), Nice (25 Apr), Zurich (2 May), Copenhagen (4
May), London (9 May), Eilat/IL (9 May), Reading/UK (10 May), Cairo (15 May), Moscow
(19 May) 
&lt;/p&gt;
&lt;p&gt;
I'll be speaking at the Zurich, Copenhagen, and Eilat (TechEd Israel) events.
&lt;/p&gt;
&lt;p&gt;
[If the event near you does not have a sign-up page linked, watch your local MSDN
portal or MSDN newsletters for updates]
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=a7a3cdee-9919-4d4d-8594-c77cba5481ee" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,a7a3cdee-9919-4d4d-8594-c77cba5481ee.aspx</comments>
      <category>Talks</category>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=e7fcee75-09c2-4e00-9b80-7c2986627b9a</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,e7fcee75-09c2-4e00-9b80-7c2986627b9a.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,e7fcee75-09c2-4e00-9b80-7c2986627b9a.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=e7fcee75-09c2-4e00-9b80-7c2986627b9a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I am sure that some want to fly under our radar, but I am also sure that a lot of
people are very interested to have a bit fat green spot showing up on our radar screen
when it comes to their blogs posts. Well, <a href="http://friends.newtelligence.net/clemensv/CommentView,guid,f281196c-410e-47ab-b59c-d4c1f77dfc7c.aspx">if
you look here</a> ... everyone who left a comment on that post is on my blogroll in RSS
Bandit and I am making every interesting and original post/thought/article visible
internally to make sure that your wishes/concerns/praise are heard and your contributions
to the community are acknowledged. 
</p>
        <p>
PS: Did I mention that I am involved in the MVP approval process? ;-)<br />
PS: Identity (InfoCard, Active Directory, MIIS), Workflow and BizTalk gurus are welcome
too. I will get your feed addresses to the right folks.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=e7fcee75-09c2-4e00-9b80-7c2986627b9a" />
      </body>
      <title>Getting on the WCF Product Group Radar Screen? Easy!</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,e7fcee75-09c2-4e00-9b80-7c2986627b9a.aspx</guid>
      <link>http://vasters.com/clemensv/2006/04/05/Getting+On+The+WCF+Product+Group+Radar+Screen+Easy.aspx</link>
      <pubDate>Wed, 05 Apr 2006 22:51:33 GMT</pubDate>
      <description>&lt;p&gt;
I am sure that some want to fly under our radar, but I am also sure that a lot of
people are very interested to have a bit fat green spot showing up on our radar screen
when it comes to their blogs posts. Well, &lt;a href="http://friends.newtelligence.net/clemensv/CommentView,guid,f281196c-410e-47ab-b59c-d4c1f77dfc7c.aspx"&gt;if
you look here&lt;/a&gt; ... everyone who left a comment on that post is on my blogroll in&amp;nbsp;RSS
Bandit and I am making every interesting and original post/thought/article visible
internally to make sure that your wishes/concerns/praise&amp;nbsp;are heard and your contributions
to the community are acknowledged. 
&lt;/p&gt;
&lt;p&gt;
PS: Did I mention that I am involved in the MVP approval process? ;-)&lt;br&gt;
PS: Identity (InfoCard, Active Directory, MIIS), Workflow and BizTalk gurus are welcome
too. I will get your&amp;nbsp;feed addresses to the right folks.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=e7fcee75-09c2-4e00-9b80-7c2986627b9a" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,e7fcee75-09c2-4e00-9b80-7c2986627b9a.aspx</comments>
      <category>Blog</category>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=95886948-066e-452f-95b8-2381ed70ad4e</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,95886948-066e-452f-95b8-2381ed70ad4e.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,95886948-066e-452f-95b8-2381ed70ad4e.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=95886948-066e-452f-95b8-2381ed70ad4e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Pablo Cibraro (who <a href="http://weblogs.asp.net/cibrax/archive/2006/04/04/441887.aspx">just received</a> the Connected
Systems Developer MVP award; Congratulations!) has built a <a href="http://weblogs.asp.net/cibrax/archive/2006/03/29/441398.aspx">compression
channel</a> for WCF. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=95886948-066e-452f-95b8-2381ed70ad4e" />
      </body>
      <title>Compression Channel for WCF</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,95886948-066e-452f-95b8-2381ed70ad4e.aspx</guid>
      <link>http://vasters.com/clemensv/2006/04/05/Compression+Channel+For+WCF.aspx</link>
      <pubDate>Wed, 05 Apr 2006 13:23:03 GMT</pubDate>
      <description>&lt;p&gt;
Pablo Cibraro (who &lt;a href="http://weblogs.asp.net/cibrax/archive/2006/04/04/441887.aspx"&gt;just&amp;nbsp;received&lt;/a&gt; the&amp;nbsp;Connected
Systems Developer MVP award; Congratulations!) has built a &lt;a href="http://weblogs.asp.net/cibrax/archive/2006/03/29/441398.aspx"&gt;compression
channel&lt;/a&gt; for WCF. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=95886948-066e-452f-95b8-2381ed70ad4e" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,95886948-066e-452f-95b8-2381ed70ad4e.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=133de49e-e6a9-469b-8ee7-08264699cd3e</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,133de49e-e6a9-469b-8ee7-08264699cd3e.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,133de49e-e6a9-469b-8ee7-08264699cd3e.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=133de49e-e6a9-469b-8ee7-08264699cd3e</wfw:commentRss>
      <slash:comments>6</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Blogland is big. I am currently trying to get a bit of an overview what people out
in blogland are doing with WCF. And while I've been doing that in addition to a bunch
of very long and (due to the time difference between Redmond and Germany) very late
evening meetings, Sabine has caught the Sudoku virus and keeps filling those
grids ...
</p>
        <p>
It turns out, there is convergence between WCF and Sudoku. ;-)
</p>
        <p>
I have seen a few people pointing it out already, but in case you haven't seen <a href="http://www.wintoolzone.com/clickonce/ws-sudoku/">Kumar
Gaurav Khanna's WS-Sudoku</a> (<a href="http://www.wintoolzone.com/blog/?p=114">blog
post</a>) game, you might want to take a look. It's ClickOnce installable (given you
have the WinFX Feb CTP) and lets a group of people solve a puzzle together. Very
nice demo. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=133de49e-e6a9-469b-8ee7-08264699cd3e" />
      </body>
      <title>WS-Sudoku</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,133de49e-e6a9-469b-8ee7-08264699cd3e.aspx</guid>
      <link>http://vasters.com/clemensv/2006/04/05/WSSudoku.aspx</link>
      <pubDate>Wed, 05 Apr 2006 12:52:02 GMT</pubDate>
      <description>&lt;p&gt;
Blogland is big. I am currently trying to get a bit of an overview what people out
in blogland are doing with WCF. And while I've been doing that in addition to a bunch
of very long and (due to the time difference between Redmond and Germany) very late
evening meetings, Sabine has&amp;nbsp;caught the Sudoku virus and keeps filling those
grids ...
&lt;/p&gt;
&lt;p&gt;
It turns out, there is convergence between WCF and Sudoku. ;-)
&lt;/p&gt;
&lt;p&gt;
I have seen a few people pointing it out already, but in case you haven't&amp;nbsp;seen &lt;a href="http://www.wintoolzone.com/clickonce/ws-sudoku/"&gt;Kumar
Gaurav Khanna's WS-Sudoku&lt;/a&gt; (&lt;a href="http://www.wintoolzone.com/blog/?p=114"&gt;blog
post&lt;/a&gt;) game, you might want to take a look. It's ClickOnce installable (given you
have the WinFX Feb CTP) and lets a group of people solve a puzzle together.&amp;nbsp;Very
nice demo. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=133de49e-e6a9-469b-8ee7-08264699cd3e" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,133de49e-e6a9-469b-8ee7-08264699cd3e.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=74664ef9-3eb3-408b-8fa3-69d36adf4fd7</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,74664ef9-3eb3-408b-8fa3-69d36adf4fd7.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,74664ef9-3eb3-408b-8fa3-69d36adf4fd7.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=74664ef9-3eb3-408b-8fa3-69d36adf4fd7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://www.markbaker.ca/2002/09/Blog/2006/04/02#2006-04-wish">Mark</a>, I
care deeply about the hobbyist who writes some code on the side, the programmer
who works from 9-5 and has a life and just as deeply about those who work 24/7 and
about everybody in between ;-) 
</p>
        <p>
That said: now that we're getting close to being done with the "this vs.
that" debate, we can most certainly figure out the "how can we optimize the programming
experience" story. For very many people I've talked to in the past 4 years or so,
reducing complexity is an important thing. I firmly believe that we can do enterprise
messaging and Web-Style/Lo-REST/POX with a single technology stack that
scales up and down in terms of its capabilities.  
</p>
        <p align="left">
Since I take that you are worried about code-bloat on the app-level, how would
you think about the following client-side one-liners?
</p>
        <ul>
          <li>
            <div align="left">T data = Pox.Get&lt;T&gt;("myCfg")
</div>
          </li>
          <li>
            <div align="left">T data = Pox.Get&lt;T&gt;("myCfg", new Uri("/customer/8929", UriKind.Relative));
</div>
          </li>
          <li>
            <div align="left">T data = Pox.Get&lt;T&gt;("myCfg", new Uri("http: //example.com/customer/8929"));
</div>
          </li>
          <li>
            <div align="left">T data = Pox.Get&lt;T&gt;(new Uri("http: //example.com/customer/8929")); 
</div>
          </li>
          <li>
            <div align="left">
              <div align="left">U reply = Pox.Put&lt;T,U&gt;( new Uri("http: //example.com/customer/8929"),
data, ref location));
</div>
            </div>
          </li>
          <li>
            <div align="left">
              <div align="left">U reply = Pox.Post&lt;T,U&gt;( new Uri("http: //example.com/customer/"),
data, out location));
</div>
            </div>
          </li>
          <li>
            <div align="left">
              <div align="left">Pox.Delete(settings, new Uri("http: //example.com/customer/8929"));
</div>
            </div>
          </li>
        </ul>
        <p>
Whereby <em>"myCfg"</em> refers to a set of config to specify security, proxies, and
so forth; <em>settings</em> would refer to an in-memory object with the same reusable
info. Our stack lets me code that sort of developer experience in a quite straightforward
fashion and I can throw SOAPish WS-Transfer under it and make the call flow
on a reliable, routed TCP session with binary encoding without changing the least
bit.
</p>
        <p>
If I am still missing your point in terms of ease of use and line count, make a wish,
Mark. :-)
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=74664ef9-3eb3-408b-8fa3-69d36adf4fd7" />
      </body>
      <title>POVs</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,74664ef9-3eb3-408b-8fa3-69d36adf4fd7.aspx</guid>
      <link>http://vasters.com/clemensv/2006/04/03/POVs.aspx</link>
      <pubDate>Mon, 03 Apr 2006 15:39:16 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://www.markbaker.ca/2002/09/Blog/2006/04/02#2006-04-wish"&gt;Mark&lt;/a&gt;, I
care deeply&amp;nbsp;about the hobbyist who writes some code on the side, the programmer
who works from 9-5 and has a life and just as deeply about those who work 24/7 and
about everybody in between ;-) 
&lt;/p&gt;
&lt;p&gt;
That said: now that we're getting close to&amp;nbsp;being done with&amp;nbsp;the "this vs.
that" debate, we can most certainly figure out the "how can we optimize the programming
experience" story. For very many people I've talked to in the past 4 years or so,
reducing complexity is an important thing. I firmly believe that we can do enterprise
messaging and Web-Style/Lo-REST/POX with a single&amp;nbsp;technology stack&amp;nbsp;that
scales&amp;nbsp;up and down in terms of its capabilities. &amp;nbsp;
&lt;/p&gt;
&lt;p align=left&gt;
Since&amp;nbsp;I take that&amp;nbsp;you are worried about code-bloat on the app-level, how&amp;nbsp;would
you think about the following client-side one-liners?
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div align=left&gt;T data&amp;nbsp;= Pox.Get&amp;lt;T&amp;gt;("myCfg")
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div align=left&gt;T data = Pox.Get&amp;lt;T&amp;gt;("myCfg", new Uri("/customer/8929", UriKind.Relative));
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div align=left&gt;T data&amp;nbsp;= Pox.Get&amp;lt;T&amp;gt;("myCfg", new Uri("http: //example.com/customer/8929"));
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div align=left&gt;T data&amp;nbsp;= Pox.Get&amp;lt;T&amp;gt;(new Uri("http: //example.com/customer/8929")); 
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div align=left&gt;
&lt;div align=left&gt;U reply = Pox.Put&amp;lt;T,U&amp;gt;( new Uri("http: //example.com/customer/8929"),
data, ref location));
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div align=left&gt;
&lt;div align=left&gt;U reply = Pox.Post&amp;lt;T,U&amp;gt;( new Uri("http: //example.com/customer/"),
data, out location));
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div align=left&gt;
&lt;div align=left&gt;Pox.Delete(settings, new Uri("http: //example.com/customer/8929"));
&lt;/div&gt;
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Whereby &lt;em&gt;"myCfg"&lt;/em&gt; refers to a set of config to specify security, proxies, and
so forth; &lt;em&gt;settings&lt;/em&gt; would refer to an in-memory object with the same reusable
info. Our stack lets me code that sort of developer experience&amp;nbsp;in a quite straightforward
fashion&amp;nbsp;and I can&amp;nbsp;throw SOAPish WS-Transfer under it and make the call flow
on a reliable, routed TCP session with binary encoding without changing the least
bit.
&lt;/p&gt;
&lt;p&gt;
If I am still missing your point in terms of ease of use and line count, make a wish,
Mark.&amp;nbsp;:-)
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=74664ef9-3eb3-408b-8fa3-69d36adf4fd7" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,74664ef9-3eb3-408b-8fa3-69d36adf4fd7.aspx</comments>
      <category>Technology/Indigo</category>
      <category>Technology/Web Services</category>
      <category>Technology/XML</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=7e1c3867-6126-478c-a9d9-bfebf0cd9f82</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,7e1c3867-6126-478c-a9d9-bfebf0cd9f82.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,7e1c3867-6126-478c-a9d9-bfebf0cd9f82.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=7e1c3867-6126-478c-a9d9-bfebf0cd9f82</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of the things I've learned quickly on our team is that the customer is everything.
That's not a marketing phrase but the literal truth. Up until January 31st I had great
personal powers to cause 11th hour changes in WCF and since the day I joined
up that power is gradually diminishing. That's not only because we're edging closer
to RTM, but also because it's more difficult to fill in the "business justification"
column for design changes that I would want to propose. There is a tension between
"more and better features" and "shipping" and of course also a huge difference between
a customer legitimately saying "I don't like that behavior" and "umm, so how do we
make Rocky happy?".
</p>
        <p>
It turns out that you (yes, you) have two very easy ways to make your suggestions
heard and quite directly contribute to our product planning and to file bugs on
things that don't work, things that you consider to be behaving in a strange way or
stuff you plainly don't like or consider to be missing.
</p>
        <p>
So if you think that we should have a [PatHelland] attribute that constrains the behavior
of a WCF service to the exact guidance along the lines of <a href="http://blogs.msdn.com/pathelland/default.aspx">Pat's</a> Fiefdoms
and Emissaries or Metropolis models we'd love to hear about it. <em>(Even
though the reply to that exact feature request would probably be an explanation of
how to build that on top of the WCF extensbility model - you can actually build
that attribute today ;-) </em></p>
        <p>
1. <strong><a href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=118&amp;SiteID=1">The
MSDN Forum.</a></strong> The forum is the place where all Program Managers on our
team listen. We get a daily report of unanswered questions and we have an internal
website where we can manage and assign the questions. So your questions do in fact
land in our inboxes. 
</p>
        <p>
2. <strong><a href="http://lab.msdn.microsoft.com/productfeedback/">The MSDN Product
Feedback Center.</a></strong> You can file bugs straight into our internal product
database (called "Product Studio"). That tool is the most powerful way for anyone
to submit bugs and feature requests. Whatever goes into the feedback center is an<strong> actual,
unresolved product bug</strong> until it's been on the table and has been given
serious consideration. We currently only have a tiny little number of bugs from the
product feedback center in the database and we are of the humble opinion that we can't
be that good ;-) 
</p>
        <p>
Filing bugs and suggesting features is <strong>always</strong> welcome. You shouldn't
be worrying that we have a cutoff point for features at some point before RTM. That's
our thing to do. There is always a next version and planning for that has actually
started.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=7e1c3867-6126-478c-a9d9-bfebf0cd9f82" />
      </body>
      <title>You have a bug! And you must implement the [PatHelland] attribute!</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,7e1c3867-6126-478c-a9d9-bfebf0cd9f82.aspx</guid>
      <link>http://vasters.com/clemensv/2006/04/01/You+Have+A+Bug+And+You+Must+Implement+The+PatHelland+Attribute.aspx</link>
      <pubDate>Sat, 01 Apr 2006 13:20:01 GMT</pubDate>
      <description>&lt;p&gt;
One of the things I've learned quickly on our team is that the customer is everything.
That's not a marketing phrase but the literal truth. Up until January 31st I had great
personal powers to cause 11th hour changes in WCF and since the day&amp;nbsp;I joined
up that power is gradually diminishing. That's not only because we're edging closer
to RTM, but also because it's more difficult to fill in the "business justification"
column for design changes that I would want to propose. There is a tension between
"more and better features" and "shipping" and of course also a huge difference between
a customer legitimately saying "I don't like that behavior" and "umm, so how do we
make Rocky happy?".
&lt;/p&gt;
&lt;p&gt;
It turns out that you (yes, you) have&amp;nbsp;two very easy ways&amp;nbsp;to make your suggestions
heard and quite directly contribute to our product planning and to file bugs&amp;nbsp;on
things that don't work, things that you consider to be behaving in a strange way or
stuff you plainly don't like or consider to be&amp;nbsp;missing.
&lt;/p&gt;
&lt;p&gt;
So if you think that we should have a [PatHelland] attribute that constrains the behavior
of a WCF service to the exact guidance along the lines of &lt;a href="http://blogs.msdn.com/pathelland/default.aspx"&gt;Pat's&lt;/a&gt; Fiefdoms
and Emissaries or Metropolis models&amp;nbsp;we'd love to hear&amp;nbsp;about it. &lt;em&gt;(Even
though the reply to that exact feature request would probably be an explanation of
how to build that on top of the WCF extensbility model -&amp;nbsp;you can actually build
that attribute today&amp;nbsp;;-) &lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
1. &lt;strong&gt;&lt;a href="http://forums.microsoft.com/MSDN/ShowForum.aspx?ForumID=118&amp;amp;SiteID=1"&gt;The
MSDN Forum.&lt;/a&gt;&lt;/strong&gt; The forum is the place where all Program Managers on our
team listen. We get a daily report of unanswered questions and we have an internal
website where we can manage and assign the questions. So your questions do in fact
land in our inboxes. 
&lt;/p&gt;
&lt;p&gt;
2. &lt;strong&gt;&lt;a href="http://lab.msdn.microsoft.com/productfeedback/"&gt;The MSDN Product
Feedback Center.&lt;/a&gt;&lt;/strong&gt; You can file bugs straight into our internal product
database (called "Product Studio"). That tool is the most powerful way for anyone
to submit bugs and feature requests. Whatever goes into the feedback center is an&lt;strong&gt; actual,
unresolved&amp;nbsp;product bug&lt;/strong&gt; until it's been on the table and has been given
serious consideration. We currently only have a tiny little number of bugs from the
product feedback center in the database and we are of the humble opinion that we can't
be that good ;-) 
&lt;/p&gt;
&lt;p&gt;
Filing bugs and suggesting features is &lt;strong&gt;always&lt;/strong&gt; welcome. You shouldn't
be worrying that we have a cutoff point for features at some point before RTM. That's
our thing to do. There is always a next version and planning for that has actually
started.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=7e1c3867-6126-478c-a9d9-bfebf0cd9f82" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,7e1c3867-6126-478c-a9d9-bfebf0cd9f82.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=253774c9-6b2a-433e-8c7c-0fe4f04fbea8</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,253774c9-6b2a-433e-8c7c-0fe4f04fbea8.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,253774c9-6b2a-433e-8c7c-0fe4f04fbea8.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=253774c9-6b2a-433e-8c7c-0fe4f04fbea8</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The fabulous Ed Pinto has blogged about out <a href="http://blogs.msdn.com/edpinto/archive/2006/02/22/537027.aspx">breaking
changes</a> for the February CTP. Exhaustive list <a href="http://windowscommunication.net/collateral/pages/BreakingChangesJanCTPToFebCTP.htm">here</a>.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=253774c9-6b2a-433e-8c7c-0fe4f04fbea8" />
      </body>
      <title>Indigo/WCF breaking changes for the February CTP</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,253774c9-6b2a-433e-8c7c-0fe4f04fbea8.aspx</guid>
      <link>http://vasters.com/clemensv/2006/02/22/IndigoWCF+Breaking+Changes+For+The+February+CTP.aspx</link>
      <pubDate>Wed, 22 Feb 2006 17:55:02 GMT</pubDate>
      <description>&lt;p&gt;
The fabulous Ed Pinto has blogged about out &lt;a href="http://blogs.msdn.com/edpinto/archive/2006/02/22/537027.aspx"&gt;breaking
changes&lt;/a&gt; for the February CTP. Exhaustive list &lt;a href="http://windowscommunication.net/collateral/pages/BreakingChangesJanCTPToFebCTP.htm"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=253774c9-6b2a-433e-8c7c-0fe4f04fbea8" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,253774c9-6b2a-433e-8c7c-0fe4f04fbea8.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=b9291c02-9326-43af-be06-03e0d448ebc4</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,b9291c02-9326-43af-be06-03e0d448ebc4.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,b9291c02-9326-43af-be06-03e0d448ebc4.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=b9291c02-9326-43af-be06-03e0d448ebc4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The WinFX Runtime Components February CTP and the SDK and the VS extensions
that go with them just hit the download sites. Go get it:
</p>
        <ul>
          <li>
            <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=F51C4D96-9AEA-474F-86D3-172BFA3B828B&amp;displaylang=en">WinFX
Runtime Components</a>
          </li>
          <li>
            <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=9BE1FC7F-0542-47F1-88DD-61E3EF88C402&amp;displaylang=en">Windows
SDK</a>
          </li>
          <li>
            <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=AD0CE56E-D7B6-44BC-910D-E91F3E370477&amp;displaylang=en">Microsoft
Visual Studio Code Name “Orcas” Community Technology Preview - Development Tools for
WinFX®</a>
          </li>
          <li>
            <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=A2151993-991D-4F58-A707-5883FF4C1DC2&amp;displaylang=en">VS
Extensions for Workflow</a>
          </li>
          <li>
            <a href="http://msdn.microsoft.com/windowsvista/support/relnotes/winfxfebctp/default.aspx">WinFX
RC February CTP “Readme”</a>: 
<br /></li>
        </ul>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=b9291c02-9326-43af-be06-03e0d448ebc4" />
      </body>
      <title>WinFX February CTP published</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,b9291c02-9326-43af-be06-03e0d448ebc4.aspx</guid>
      <link>http://vasters.com/clemensv/2006/02/22/WinFX+February+CTP+Published.aspx</link>
      <pubDate>Wed, 22 Feb 2006 17:37:15 GMT</pubDate>
      <description>&lt;p&gt;
The WinFX Runtime Components February CTP&amp;nbsp;and the SDK and the VS&amp;nbsp;extensions
that go with&amp;nbsp;them just hit the download sites. Go get it:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=F51C4D96-9AEA-474F-86D3-172BFA3B828B&amp;amp;displaylang=en"&gt;WinFX
Runtime Components&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=9BE1FC7F-0542-47F1-88DD-61E3EF88C402&amp;amp;displaylang=en"&gt;Windows
SDK&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=AD0CE56E-D7B6-44BC-910D-E91F3E370477&amp;amp;displaylang=en"&gt;Microsoft
Visual Studio Code Name “Orcas” Community Technology Preview - Development Tools for
WinFX®&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=A2151993-991D-4F58-A707-5883FF4C1DC2&amp;amp;displaylang=en"&gt;VS
Extensions for Workflow&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://msdn.microsoft.com/windowsvista/support/relnotes/winfxfebctp/default.aspx"&gt;WinFX
RC February CTP “Readme”&lt;/a&gt;: 
&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=b9291c02-9326-43af-be06-03e0d448ebc4" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,b9291c02-9326-43af-be06-03e0d448ebc4.aspx</comments>
      <category>Technology/Avalon</category>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=e75402c6-bdd6-438c-9bf2-31f64b8e0557</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,e75402c6-bdd6-438c-9bf2-31f64b8e0557.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,e75402c6-bdd6-438c-9bf2-31f64b8e0557.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=e75402c6-bdd6-438c-9bf2-31f64b8e0557</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I just got <a href="http://friends.newtelligence.net/clemensv/CommentView,guid,b99db04c-f2d0-4850-8d9f-8048608ea7cd.aspx">a
comment</a> from Oran about the lack of durable messaging in WCF and the need for
a respective extensibility point. Well... the thing is: Durable messaging is there;
use the MSMQ bindings. One of the obvious "problems" with durable messaging that's
only based on WS-ReliableMessaging is that that spec (intentionally) does not
make any assertions about the behavior of the respective endpoints. 
</p>
        <p>
There is no rule saying: "the received message MUST be written do disk". WS-ReliableMessaging
is as reliable (and unreliable in case of very long-lasting network failures or an
endpoint outright crashing) and plays the same role as TCP. The mapping is actually
pretty straightforward like this: WS-Addressing = IP, WS-ReliableMessaging = TCP. 
</p>
        <p>
So if you do durable messaging on one end and the other end doesn't do it, the sum
of the gained reliability doesn't add up to anything more than it was before. MSMQ
is fully in control of both ends of the wire and makes assertions about the endpoint
behavior and was therefore the logical choice for our durable messaging strategy in
V1, because it already ships with Windows and there is (as of yet) no agreed interoperable
set of behavioral assertions for WS-RM around how endpoints must deal with received
messages except ACKing them.
</p>
        <p>
See <a href="http://blogs.msdn.com/shycohen/archive/2006/02/20/535717.aspx">Shy's
comments</a>.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=e75402c6-bdd6-438c-9bf2-31f64b8e0557" />
      </body>
      <title>The case of the missing "durable messaging" feature</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,e75402c6-bdd6-438c-9bf2-31f64b8e0557.aspx</guid>
      <link>http://vasters.com/clemensv/2006/02/20/The+Case+Of+The+Missing+Durable+Messaging+Feature.aspx</link>
      <pubDate>Mon, 20 Feb 2006 20:13:32 GMT</pubDate>
      <description>&lt;p&gt;
I just got&amp;nbsp;&lt;a href="http://friends.newtelligence.net/clemensv/CommentView,guid,b99db04c-f2d0-4850-8d9f-8048608ea7cd.aspx"&gt;a
comment&lt;/a&gt; from Oran about the lack of durable messaging in WCF and the need for
a respective extensibility point. Well... the thing is: Durable messaging is there;
use the MSMQ bindings. One of the&amp;nbsp;obvious "problems"&amp;nbsp;with durable messaging&amp;nbsp;that's
only based on&amp;nbsp;WS-ReliableMessaging is that that spec (intentionally) does not
make any assertions about the behavior of the respective&amp;nbsp;endpoints. 
&lt;/p&gt;
&lt;p&gt;
There is no rule saying: "the received message MUST be written do disk". WS-ReliableMessaging
is as reliable (and unreliable in case of&amp;nbsp;very long-lasting&amp;nbsp;network failures&amp;nbsp;or&amp;nbsp;an
endpoint outright crashing)&amp;nbsp;and plays the same role as TCP. The mapping is actually
pretty straightforward like this: WS-Addressing = IP, WS-ReliableMessaging = TCP. 
&lt;/p&gt;
&lt;p&gt;
So if you do durable messaging on one end and the other end doesn't do it, the sum
of the gained reliability doesn't add up to anything more than it was before. MSMQ
is fully in control of both ends of the wire and makes assertions about the endpoint
behavior and was therefore the logical choice for our durable messaging strategy in
V1, because it already ships with Windows and&amp;nbsp;there is&amp;nbsp;(as of yet) no agreed&amp;nbsp;interoperable
set of behavioral assertions for WS-RM around how endpoints must deal with received
messages except ACKing them.
&lt;/p&gt;
&lt;p&gt;
See &lt;a href="http://blogs.msdn.com/shycohen/archive/2006/02/20/535717.aspx"&gt;Shy's
comments&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=e75402c6-bdd6-438c-9bf2-31f64b8e0557" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,e75402c6-bdd6-438c-9bf2-31f64b8e0557.aspx</comments>
      <category>Technology/Indigo</category>
      <category>Technology/MSMQ</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=b99db04c-f2d0-4850-8d9f-8048608ea7cd</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,b99db04c-f2d0-4850-8d9f-8048608ea7cd.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,b99db04c-f2d0-4850-8d9f-8048608ea7cd.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=b99db04c-f2d0-4850-8d9f-8048608ea7cd</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Just read this on <a href="http://weblogs.asp.net/rhurlbut/archive/2006/02/20/438584.aspx">Robert
Hurlbut's</a> blog (via <a href="http://www.leastprivilege.com/TheOfficialWordOnWCFAndPartialTrust.aspx">Dominick</a>,
source is <a href="http://www.douglasp.com/blog/PermaLink.aspx?guid=12a6b6d1-fc37-484b-b52e-92051a309b89">Doug</a>)
</p>
        <p>
As Doug indicates, the issue here is not "we don't want to do it", but that we need
to ship. 
</p>
        <p>
The problem is that partial trust is incredibly hard (and very time consuming) to
test for a communication platform that is supposed to have rock solid security (no
paradoxon here) and shall perform well. It's just as hard to provide meaningful exceptions
(and -messages) in case we'd stumble into a CAS exception. You wouldn't want us to
just bubble up some aribtrary security exception, but instead will want us
tell you what's causing the problem and how you could fix it. There are (give or take
some) 20 base permissions in the framework, most of them allow parameterization,
and the system is extensible with custom permissions as well. You can do the math
for where that takes you in terms of required combinations and test cases for achieving
satisfying test coverage across the whole of Indigo, let alone all the special casing
in the actual product code-base.
</p>
        <p>
I wonder how many applications written to support partial trust actually take
that complexity into account in their test strategy (hint, hint) ;-)
</p>
        <p>
That said, I will clarify once more that this doesn't mean "we will never do that".
It's just not possible to fit this into our V1 schedule in a way that we and you would find
the outcome acceptable. 
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=b99db04c-f2d0-4850-8d9f-8048608ea7cd" />
      </body>
      <title>WCF and Partial Trust</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,b99db04c-f2d0-4850-8d9f-8048608ea7cd.aspx</guid>
      <link>http://vasters.com/clemensv/2006/02/20/WCF+And+Partial+Trust.aspx</link>
      <pubDate>Mon, 20 Feb 2006 19:00:02 GMT</pubDate>
      <description>&lt;p&gt;
Just read this on &lt;a href="http://weblogs.asp.net/rhurlbut/archive/2006/02/20/438584.aspx"&gt;Robert
Hurlbut's&lt;/a&gt; blog (via &lt;a href="http://www.leastprivilege.com/TheOfficialWordOnWCFAndPartialTrust.aspx"&gt;Dominick&lt;/a&gt;,
source is &lt;a href="http://www.douglasp.com/blog/PermaLink.aspx?guid=12a6b6d1-fc37-484b-b52e-92051a309b89"&gt;Doug&lt;/a&gt;)
&lt;/p&gt;
&lt;p&gt;
As Doug indicates, the issue here is not "we don't want to do it", but that we need
to ship.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
The problem is that partial trust is incredibly hard (and very time consuming) to
test for a communication platform that is supposed to have rock solid security (no
paradoxon here) and shall perform well. It's just as hard to provide meaningful exceptions
(and -messages) in case we'd stumble into a CAS exception. You wouldn't want us to
just bubble up some aribtrary security exception, but instead&amp;nbsp;will want&amp;nbsp;us
tell you what's causing the problem and how you could fix it. There are (give or take
some)&amp;nbsp;20 base permissions in the framework, most of them allow parameterization,
and the system is extensible with custom permissions as well. You can do the math
for where that takes you in terms of required combinations and test cases for achieving
satisfying test coverage across the whole of Indigo, let alone all the special casing
in the actual product code-base.
&lt;/p&gt;
&lt;p&gt;
I wonder how many applications written to support partial trust actually&amp;nbsp;take
that complexity into account in their test strategy (hint, hint) ;-)
&lt;/p&gt;
&lt;p&gt;
That said, I will clarify once more that this doesn't mean "we will never do that".
It's just not possible to fit this into our V1 schedule in a way that we and you would&amp;nbsp;find
the outcome acceptable.&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=b99db04c-f2d0-4850-8d9f-8048608ea7cd" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,b99db04c-f2d0-4850-8d9f-8048608ea7cd.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=f281196c-410e-47ab-b59c-d4c1f77dfc7c</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,f281196c-410e-47ab-b59c-d4c1f77dfc7c.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,f281196c-410e-47ab-b59c-d4c1f77dfc7c.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=f281196c-410e-47ab-b59c-d4c1f77dfc7c</wfw:commentRss>
      <slash:comments>29</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you have a blog and you post stuff around WCF/Indigo and you think that I don't
have you in my aggregator, please <a href="http://friends.newtelligence.net/clemensv/CommentView,guid,f281196c-410e-47ab-b59c-d4c1f77dfc7c.aspx">post
a comment</a> below with your blog URL. And it totally doesn't matter whether you
blog in English, Italian, French, Spanish, Dutch, German, Arabic, Chinese, Russian,
or any other language ... I want to know.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=f281196c-410e-47ab-b59c-d4c1f77dfc7c" />
      </body>
      <title>Building a WCF Blog List ....</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,f281196c-410e-47ab-b59c-d4c1f77dfc7c.aspx</guid>
      <link>http://vasters.com/clemensv/2006/02/04/Building+A+WCF+Blog+List.aspx</link>
      <pubDate>Sat, 04 Feb 2006 10:37:51 GMT</pubDate>
      <description>&lt;p&gt;
If you have a blog and you post stuff around WCF/Indigo and you think that I don't
have you in my aggregator, please &lt;a href="http://friends.newtelligence.net/clemensv/CommentView,guid,f281196c-410e-47ab-b59c-d4c1f77dfc7c.aspx"&gt;post
a comment&lt;/a&gt; below with your blog URL. And it totally doesn't matter whether you
blog in English, Italian, French, Spanish, Dutch, German, Arabic, Chinese, Russian,
or any other language ... I want to know.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=f281196c-410e-47ab-b59c-d4c1f77dfc7c" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,f281196c-410e-47ab-b59c-d4c1f77dfc7c.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=8fc367b2-a4be-4588-8264-5455c268b94a</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,8fc367b2-a4be-4588-8264-5455c268b94a.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,8fc367b2-a4be-4588-8264-5455c268b94a.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=8fc367b2-a4be-4588-8264-5455c268b94a</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <div class="Section1">
          <p class="MsoNormal">
            <span lang="DE">
              <a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx">
                <span lang="EN-US">
                  <span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx">
                    <span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx">
                      <span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx">Part
1</span>
                    </span>
                  </span>
                </span>
              </a>
            </span>, <span lang="DE"><a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"><span lang="EN-US"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx">Part
2</span></span></span></span></a></span>, <span lang="DE"><a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx"><span lang="EN-US"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx">Part
3</span></span></span></span></a></span>, <span lang="DE"><a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx"><span lang="EN-US"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx">Part
4</span></span></span></span></a></span>, <a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx">Part
5</a>, <a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,51327201-07c7-4a30-b79c-53842cda1e77.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,51327201-07c7-4a30-b79c-53842cda1e77.aspx">Part
6</a>, <a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,e82c8423-f106-4105-81e4-14410a83315a.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,e82c8423-f106-4105-81e4-14410a83315a.aspx">Part
7</a>, <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,7465c74e-6001-4d08-93ae-ad7110dee188.aspx">Part
8</a><br />
If you are in a hurry and all you want is the code, scroll down to the bottom. ;)<br />
And for the few who are still reading: This is the 9<sup>th</sup> and final part of
this series, which turned out to be a little bigger than planned. And if you read
all parts up to here, you have meanwhile figured out that the extensions that I have
presented here are not only about REST and POX but primarily a demonstration of how
customizable Indigo is for your own needs.  Indigo – Indigo was really a cool
code-name. Just like many folks on the <s>Indigo</s> WCF team it’s a bit difficult
for me to trade it for a clunky moniker like WCF, and it seems that <a href="http://www.googlefight.com/index.php?lang=en_GB&amp;word1=Microsoft+Indigo&amp;word2=Microsoft+WCF">this
somewhat reflects public opinion</a>. Much less am I inclined to really spell out
“Windows Communication Foundation” in presentations, because that doesn’t exactly
roll off the tongue like a poem, does it? But, hey, there’s always the namespace name
and that doesn’t suck. “Service Model” is what everyone will be using in code. We
don’t need three-letter acronyms, or do we?<br />
But I digress. I’ve explained a complete set of extensions that outfit the <i>service
model</i> with the ability to receive and respond to HTTP requests with arbitrary
payloads and without SOAP envelopes and do so by dispatching to request handlers (method)
by matching the request URI and the HTTP method against metadata that we stick on
the methods using attributes. 
<br />
And now I’ll show you the “Hello World!” for the extensions and about the simplest
thing I can think of is a web server ;-)  In fact, you already have the complete
configuration file for this sample; I showed you that in <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,7465c74e-6001-4d08-93ae-ad7110dee188.aspx">Part
8</a>.<br />
Since things like “Hello World!” are supposed to be simple and it’s ok not to make
that a full coverage test case, we start with the following, very plain contract: 
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">[<span style="COLOR: teal">ServiceContract</span>, <span style="COLOR: teal">HttpMethodOperationSelector</span>]<br /><span style="COLOR: blue">interface</span><span style="COLOR: teal">IMyWebServer<br /></span>{<br />
    [<span style="COLOR: teal">OperationContract</span>, <span style="COLOR: teal">HttpMethod</span>(<span style="COLOR: maroon">"GET"</span>,
UriSuffix = <span style="COLOR: maroon">"/*"</span>)]<br />
    <span style="COLOR: teal">Message</span> Get(<span style="COLOR: teal">Message</span> msg);        
<br />
    [<span style="COLOR: teal">OperationContract</span>(Action = <span style="COLOR: maroon">"*"</span>)]<br />
    <span style="COLOR: teal">Message</span> UnknownMessage(<span style="COLOR: teal">Message</span> msg);<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p class="MsoNormal">
By now that should not need much explanation. The <i>Get()</i> method receives all
HTTP GET requests on the URI suffix “/*” whereby “*” is a wildcard. In other words,
all GET requests go to that method. 
<br />
The implementation of the service is pretty simple.  I am implementing it as
a singleton service that is constructed passing a directory name (path). 
<br />
The <i>Get()</i> implementation gets the URI of the incoming request from the <i>To</i> header
of the message’s <i>Headers</i> collection. (Note that the HTTP transport maps the
incoming request’s absolute URI to that header once the encoder has constructed the
message.)  
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">[<span style="COLOR: teal">ServiceBehavior</span>(InstanceContextMode=<span style="COLOR: teal">InstanceContextMode</span>.Single)]<br /><span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: teal">MyWebServer</span> : <span style="COLOR: teal">IMyWebServer<br /></span>{<br />
    <span style="COLOR: blue">string</span> directory;<br /><br />
    <span style="COLOR: blue">public</span> MyWebServer(<span style="COLOR: blue">string</span> directory)<br />
    {<br />
        <span style="COLOR: blue">this</span>.directory
= directory;<br />
    }<br /><br />
    <span style="COLOR: blue">public</span><span style="COLOR: teal">Message</span> Get(<span style="COLOR: teal">Message</span> msg)<br />
    {<br />
        <span style="COLOR: blue">string</span> requestPath
= msg.Headers.To.AbsolutePath;<br />
        <span style="COLOR: green">// get the path<br /></span>        <span style="COLOR: blue">if</span> (requestPath.Length
&gt; 0 &amp;&amp; requestPath[0] == <span style="COLOR: maroon">'/'</span>)<br />
        {<br />
            <span style="COLOR: green">//
if the path is just the "/", append "default.htm" as the 
<br /></span>            <span style="COLOR: green">//
default page.<br /></span>            <span style="COLOR: blue">if</span> (requestPath.Substring(1).Length
== 0)<br />
            {<br />
               
requestPath = <span style="COLOR: maroon">"/default.htm"</span>;<br />
            }<br />
            <span style="COLOR: green">//
otherwise check whether a file by the requested name exists<br /></span>            <span style="COLOR: blue">string</span> filePath
= <span style="COLOR: teal">Path</span>.Combine(directory, requestPath.Substring(1).Replace(<span style="COLOR: maroon">'/'</span>, <span style="COLOR: maroon">'\\'</span>));<br />
            <span style="COLOR: blue">if</span> (<span style="COLOR: teal">File</span>.Exists(filePath))<br />
            {<br />
                <span style="COLOR: green">//
and return a file message<br /></span>                <span style="COLOR: blue">return</span><span style="COLOR: teal">PoxMessages</span>.CreateFileReplyMessage(filePath, <span style="COLOR: teal">PoxMessages</span>.<span style="COLOR: teal">ReplyOptions</span>.None);<br />
            }<br />
        }<br />
        <span style="COLOR: green">// if all fails,
send a 404<br /></span>        <span style="COLOR: blue">return</span><span style="COLOR: teal">PoxMessages</span>.CreateErrorMessage(<span style="COLOR: teal">HttpStatusCode</span>.NotFound);<br />
    }<br /><br />
    
<br />
    <span style="COLOR: blue">public</span><span style="COLOR: teal">Message</span> UnknownMessage(<span style="COLOR: teal">Message</span> msg)<br />
    {<br />
        <span style="COLOR: blue">return</span><span style="COLOR: teal">PoxMessages</span>.CreateErrorMessage(<span style="COLOR: teal">HttpStatusCode</span>.NotImplemented);<br />
    }<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p class="MsoNormal">
Once we’ve done a few checks on the URIs path portion, we construct a file path from
the base directory and the URI path, check whether such a file exists, and if it does
we create a message for that file and return it. If we can’t find the resulting file
name, we construct a 404 “not found” error message. The <i>UnknownMessage()</i> method
receives all requests with HTTP methods other than GET and appropriately returns a
501 “not implemented” message. Web server done.<br />
Well, ok. The actual messages are constructed in a helper class <i>PoxMessages</i> that
aids in constructing the most common reply messages. The class is part of the extension
assembly code you can download and therefore I just quote the relevant methods that
are used above. We’ll start with <i>PoxMessages.CreateErrorMessage(), </i>because
that its very simple: 
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">public</span>
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">
                      <span style="COLOR: blue">static</span>
                      <span style="COLOR: teal">Message</span> CreateErrorMessage(System.Net.<span style="COLOR: teal">HttpStatusCode</span> code)<br />
{<br />
   <span style="COLOR: teal">Message</span> reply = <span style="COLOR: teal">Message</span>.CreateMessage(<span style="COLOR: maroon">"urn:reply"</span>);<br />
   <span style="COLOR: teal">HttpResponseMessageProperty</span> responseProperty
= <span style="COLOR: blue">new</span><span style="COLOR: teal">HttpResponseMessageProperty</span>();<br />
   responseProperty.StatusCode = code;<br />
   reply.Properties.Add(<span style="COLOR: teal">HttpResponseMessageProperty</span>.Name,
responseProperty);<br />
   <span style="COLOR: blue">return</span> reply;<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p class="MsoNormal">
We create a plain, empty service model <i>Message</i>, create an <i>HttpResponseMessageProperty</i> instance,
set the <i>StatusCode</i> to the status code we want and add the property to the message.
Return, done. 
<br />
The <i>PoxMessages.CreateFileReplyMessage()</i> method is a bit more complex, because
it, well, involves opening files. I am not showing you the exact overload that’s used
in the above example but the one that’s being delegated to:  
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">public</span>
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">
                      <span style="COLOR: blue">static</span>
                      <span style="COLOR: teal">Message</span> CreateFileReplyMessage(<span style="COLOR: blue">string</span> fileName, <span style="COLOR: blue">long</span> rangeOffset, <span style="COLOR: blue">long</span> rangeLength, <span style="COLOR: teal">ReplyOptions</span> options)<br />
{<br />
   <span style="COLOR: blue">string</span> contentType = GetContentTypeFromFileName(fileName);<br />
   <span style="COLOR: blue">try<br /></span>   {<br />
      <span style="COLOR: teal">FileStream</span> fileStream
= <span style="COLOR: blue">new</span><span style="COLOR: teal">FileStream</span>(fileName, <span style="COLOR: teal">FileMode</span>.Open, <span style="COLOR: teal">FileAccess</span>.Read, <span style="COLOR: teal">FileShare</span>.Read);<br />
      <span style="COLOR: blue">if</span> (rangeOffset !=
-1 &amp;&amp; rangeLength != -1)<br />
      {<br />
         <span style="COLOR: teal">SegmentStream</span> segmentStream
= <span style="COLOR: blue">new</span><span style="COLOR: teal">SegmentStream</span>(fileStream,
rangeOffset, rangeLength, <span style="COLOR: blue">true</span>);<br />
         <span style="COLOR: blue">return</span><span style="COLOR: teal">PoxMessages</span>.CreateRawReplyMessage(segmentStream,
contentType, rangeOffset, rangeLength, fileStream.Length, <span style="COLOR: teal">Path</span>.GetFileName(fileName),
options);<br />
      }<br />
      <span style="COLOR: blue">else<br /></span>      {<br />
         <span style="COLOR: blue">return</span><span style="COLOR: teal">PoxMessages</span>.CreateRawReplyMessage(fileStream,
contentType, <span style="COLOR: teal">Path</span>.GetFileName(fileName), options);<br />
      }<br />
   }<br />
   <span style="COLOR: blue">catch<br /></span>   {<br />
      <span style="COLOR: blue">return</span><span style="COLOR: teal">PoxMessages</span>.CreateNotFoundMessage();<br />
   }<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p class="MsoNormal">
The implementation will first make a guess for the file’s content-type based on the
file-name, which is a simple registry lookup with a fallback to <i>application/octet-stream</i>.
 Then it’ll try to open the file using a <i>FileStream</i> object. If that works
–  ignoring the special case with <i>rangeOffset/rangeLength</i> being set –
we delegate to the <i>CreateRawReplyMessage()</i> method: 
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">public</span>
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">
                      <span style="COLOR: blue">static</span>
                      <span style="COLOR: teal">Message</span> CreateRawReplyMessage(<span style="COLOR: teal">Stream</span> stm, <span style="COLOR: blue">string</span> contentType, <span style="COLOR: blue">long</span> rangeOffset, <span style="COLOR: blue">long</span> rangeLength, <span style="COLOR: blue">long</span> totalLength, <span style="COLOR: blue">string</span> streamName, <span style="COLOR: teal">ReplyOptions</span> options)<br />
{<br />
   <span style="COLOR: teal">PoxStreamedMessage</span> reply = <span style="COLOR: blue">new</span><span style="COLOR: teal">PoxStreamedMessage</span>(stm,
16384);<br />
   <span style="COLOR: teal">HttpResponseMessageProperty</span> responseProperty
= <span style="COLOR: blue">new</span><span style="COLOR: teal">HttpResponseMessageProperty</span>();<br />
   <span style="COLOR: blue">if</span> ((options &amp; <span style="COLOR: teal">ReplyOptions</span>.ContentDisposition)
== <span style="COLOR: teal">ReplyOptions</span>.ContentDisposition)<br />
   {<br />
      responseProperty.Headers.Add(<span style="COLOR: maroon">"Content-Disposition"</span>, <span style="COLOR: teal">String</span>.Format(<span style="COLOR: maroon">"Content-Disposition:
attachment; filename=\"{0}\""</span>, streamName));<br />
   }<br />
    responseProperty.Headers.Add(<span style="COLOR: maroon">"Content-Type"</span>,
contentType);<br />
   <span style="COLOR: blue">if</span> (rangeOffset != -1 &amp;&amp; rangeLength
!= -1)<br />
   {<br />
      responseProperty.StatusCode = System.Net.<span style="COLOR: teal">HttpStatusCode</span>.PartialContent;<br />
      responseProperty.Headers.Add(<span style="COLOR: maroon">"Content-Range"</span>, <span style="COLOR: teal">String</span>.Format(<span style="COLOR: maroon">"bytes
{0}-{1}/{2}"</span>,rangeOffset,rangeOffset+rangeLength,totalLength));<br />
      responseProperty.Headers.Add(<span style="COLOR: maroon">"Content-Length"</span>,
rangeLength.ToString());<br />
   }<br />
   <span style="COLOR: blue">else<br /></span>   {<br />
        <span style="COLOR: blue">if</span> ((options
&amp; <span style="COLOR: teal">ReplyOptions</span>.AcceptRange) == <span style="COLOR: teal">ReplyOptions</span>.AcceptRange)<br />
        {<br />
            responseProperty.Headers.Add(<span style="COLOR: maroon">"Content-Range"</span>, <span style="COLOR: teal">String</span>.Format(<span style="COLOR: maroon">"bytes
{0}-{1}/{2}"</span>, 0, totalLength-1, totalLength));<br />
        }<br />
        responseProperty.Headers.Add(<span style="COLOR: maroon">"Content-Length"</span>,
totalLength.ToString());<br />
   }<br />
   <span style="COLOR: blue">if</span> ((options &amp; <span style="COLOR: teal">ReplyOptions</span>.NoCache)
== <span style="COLOR: teal">ReplyOptions</span>.NoCache)<br />
   {<br />
      responseProperty.Headers.Add(<span style="COLOR: maroon">"Cache-Control"</span>, <span style="COLOR: maroon">"no-cache"</span>);<br />
      responseProperty.Headers.Add(<span style="COLOR: maroon">"Expires"</span>, <span style="COLOR: maroon">"-1"</span>);<br />
   }<br />
   <span style="COLOR: blue">if</span> ((options &amp; <span style="COLOR: teal">ReplyOptions</span>.AcceptRange)
== <span style="COLOR: teal">ReplyOptions</span>.AcceptRange)<br />
   {<br />
      responseProperty.Headers.Add(<span style="COLOR: maroon">"Accept-Ranges"</span>, <span style="COLOR: maroon">"bytes"</span>);<br />
   }<br />
    reply.Properties.Add(<span style="COLOR: teal">HttpResponseMessageProperty</span>.Name,
responseProperty);<br />
   reply.Properties.Add(<span style="COLOR: teal">PoxEncoderMessageProperty</span>.Name, <span style="COLOR: blue">new</span><span style="COLOR: teal">PoxEncoderMessageProperty</span>(<span style="COLOR: blue">true</span>));<br />
   <span style="COLOR: blue">return</span> reply;<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p class="MsoNormal">
That method takes the stream, wraps it in our <i>PoxStreamedMessage</i>, sets all
desired HTTP headers on the <i>HttpResponseMessageProperty</i>, adds the property
to the message and lastly adds the <i>PoxEncoderMessageProperty<u></u></i>indicating
that we want the encoder to operate in raw binary mode. However, all these helper
methods are already part of the library and therefore the application code doesn’t
really have to deal with all of that anymore. You just construct the fitting message,
stick the content into it and return it.<br />
So now we have a service class and what’s left to do is to host it. For that we need
a simple service host with a tiny little twist. Since the <i>ServiceMetadataBehavior </i>that
typically gives you the WSDL file and the service information page would conflict
with our direct interaction with HTTP, we need to switch it off. We do that by removing
it from the list of behaviors before the service is initialized.
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">public</span>
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">
                      <span style="COLOR: blue">class</span>
                      <span style="COLOR: teal">MyWebServerHost</span> : <span style="COLOR: teal">ServiceHost<br /></span>{<br />
    <span style="COLOR: blue">public</span> MyWebServerHost(<span style="COLOR: blue">object</span> instance)<br />
        : <span style="COLOR: blue">base</span>(instance)<br />
    {<br />
    }<br /><br />
    <span style="COLOR: blue">protected</span><span style="COLOR: blue">override</span><span style="COLOR: blue">void</span> OnInitialize()<br />
    {<br />
        Description.Behaviors.Remove&lt;<span style="COLOR: teal">ServiceMetadataBehavior</span>&gt;();<br />
        <span style="COLOR: blue">base</span>.OnInitialize();<br />
    }<br />
}<br /><br /><br /><span style="COLOR: blue">class</span><span style="COLOR: teal">Program<br /></span>{<br />
    <span style="COLOR: blue">static</span><span style="COLOR: blue">void</span> Main(<span style="COLOR: blue">string</span>[]
args)<br />
    {<br />
        <span style="COLOR: blue">string</span> directoryName
= args[0];<br /><br />
        <span style="COLOR: teal">Console</span>.WriteLine(<span style="COLOR: maroon">"LittleIndigoWebServer"</span>);<br />
        <span style="COLOR: blue">if</span> (args.Length
== 0)<br />
        {<br />
            <span style="COLOR: teal">Console</span>.WriteLine(<span style="COLOR: maroon">"Usage:
LittleIndigoWebServer.exe [root path]"</span>);<br />
            <span style="COLOR: blue">return</span>;<br />
        }<br />
        
<br />
        <span style="COLOR: blue">if</span> (!<span style="COLOR: teal">Directory</span>.Exists(directoryName))<br />
        {<br />
            <span style="COLOR: teal">Console</span>.WriteLine(<span style="COLOR: maroon">"Directory
'{0}' does not exist"</span>);<br />
            <span style="COLOR: blue">return</span>;<br />
        }<br /><br />
        <span style="COLOR: teal">Console</span>.WriteLine(<span style="COLOR: maroon">"Web
server starting."</span>);<br /><br />
        <span style="COLOR: blue">using</span> (<span style="COLOR: teal">MyWebServerHost</span> host
= <span style="COLOR: blue">new</span><span style="COLOR: teal">MyWebServerHost</span>(<span style="COLOR: blue">new</span><span style="COLOR: teal">MyWebServer</span>(directoryName)))<br />
        {<br />
            host.Open();<br />
            <span style="COLOR: teal">Console</span>.WriteLine(<span style="COLOR: maroon">"Web
Server running. Press ENTER to quit."</span>);<br />
            <span style="COLOR: teal">Console</span>.ReadLine();<br />
            host.Close();<br />
        }<br />
    }<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
The rest is just normal business for hosting and setting up a service model service
in a console application. We read the first argument from the command-line and assume
that’s a directory name. We verify that that is indeed so, construct the service host
passing the singleton new’ed up with the directory name. We open the service host
and we have the web server listening. The details for how the service is exposed on
the network is the job of configuration and binding and, again, exhaustively explained
in <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,7465c74e-6001-4d08-93ae-ad7110dee188.aspx">Part
8</a>. 
</p>
          <p>
Below is the downloadable archive that contains two C# projects. <i>Newtelligence.ServiceModelExtensions</i> contains
the extension set and <i>LittleIndigoWebServer</i> is the above demo app. The code
complies and works with the WinFX November and December CTPs. 
</p>
          <p>
If you have installed Visual Studio on drive <i>C:</i> you should be able to run the
sample immediately with F5, since the <i>LittleIndigoWebServer</i> project’s debugging
settings pass the .NET SDK directory to the application on startup. So if you have
that, start the server, and then browse <i>http://localhost:8020/StartHere.htm</i> you
get this:
</p>
          <p style="TEXT-ALIGN: center" align="center">
            <img height="352" src="http://staff.newtelligence.net/clemensv/content/binary/image0021234567891011.jpg" width="488" border="0" />
          </p>
          <p>
Otherwise, you can just start the server using any directory of your choosing, preferably
one with HTML content.
</p>
          <p>
And that’s it. I am happy that I’ve got all of the stuff out. This is probably the
most documentation I’ve ever written in one stretch for some public giveaway infrastructure,
but I am sure it’s worth it. I will follow up with more examples using these extensions.
For instance I will show to use this for actual POX apps (the web server is just spitting
out raw data, after all) using RSS, OPML and ASX. Stay tuned.
</p>
          <p>
Oh, and … if you like this stuff I’d be happy about comments, questions, blog mentions
and, first and foremost, public examples of other people using this stuff. License
is BSD: Use as you like, risk is all yours, mention the creators. Enjoy.
</p>
        </div>
        <p>
Download: <a href="http://staff.newtelligence.net/clemensv/content/binary/newtelligence-WCFExtensions-20060901.zip">newtelligence-WCFExtensions-20060901.zip</a><br /></p>
        <p>
          <em>[Note: I am preparing an update with client-side support and a few bugfixes right
now. Should be available before or on 2006-01-16]</em>
        </p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=8fc367b2-a4be-4588-8264-5455c268b94a" />
      </body>
      <title>Teaching Indigo to do REST/POX: Part 9 (final part)</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,8fc367b2-a4be-4588-8264-5455c268b94a.aspx</guid>
      <link>http://vasters.com/clemensv/2006/01/09/Teaching+Indigo+To+Do+RESTPOX+Part+9+Final+Part.aspx</link>
      <pubDate>Mon, 09 Jan 2006 22:36:32 GMT</pubDate>
      <description>&lt;div class=Section1&gt;
&lt;p class=MsoNormal&gt;
&lt;span lang=DE&gt;&lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx"&gt;&lt;span lang=EN-US&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx&gt;Part
1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"&gt;&lt;span lang=EN-US&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx&gt;Part
2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx"&gt;&lt;span lang=EN-US&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx&gt;Part
3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx"&gt;&lt;span lang=EN-US&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx&gt;Part
4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx"&gt;Part
5&lt;/a&gt;, &lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,51327201-07c7-4a30-b79c-53842cda1e77.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,51327201-07c7-4a30-b79c-53842cda1e77.aspx"&gt;Part
6&lt;/a&gt;, &lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,e82c8423-f106-4105-81e4-14410a83315a.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,e82c8423-f106-4105-81e4-14410a83315a.aspx"&gt;Part
7&lt;/a&gt;, &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,7465c74e-6001-4d08-93ae-ad7110dee188.aspx"&gt;Part
8&lt;/a&gt;
&lt;br&gt;
If you are in a hurry and all you want is the code, scroll down to the bottom. ;)&lt;br&gt;
And for the few who are still reading: This is the 9&lt;sup&gt;th&lt;/sup&gt; and final part of
this series, which turned out to be a little bigger than planned. And if you read
all parts up to here, you have meanwhile figured out that the extensions that I have
presented here are not only about REST and POX but primarily a demonstration of how
customizable Indigo is for your own needs. &amp;nbsp;Indigo – Indigo was really a cool
code-name. Just like many folks on the &lt;s&gt;Indigo&lt;/s&gt; WCF team it’s a bit difficult
for me to trade it for a clunky moniker like WCF, and it seems that &lt;a href="http://www.googlefight.com/index.php?lang=en_GB&amp;amp;word1=Microsoft+Indigo&amp;amp;word2=Microsoft+WCF"&gt;this
somewhat reflects public opinion&lt;/a&gt;. Much less am I inclined to really spell out
“Windows Communication Foundation” in presentations, because that doesn’t exactly
roll off the tongue like a poem, does it? But, hey, there’s always the namespace name
and that doesn’t suck. “Service Model” is what everyone will be using in code. We
don’t need three-letter acronyms, or do we?&lt;br&gt;
But I digress. I’ve explained a complete set of extensions that outfit the &lt;i&gt;service
model&lt;/i&gt; with the ability to receive and respond to HTTP requests with arbitrary
payloads and without SOAP envelopes and do so by dispatching to request handlers (method)
by matching the request URI and the HTTP method against metadata that we stick on
the methods using attributes. 
&lt;br&gt;
And now I’ll show you the “Hello World!” for the extensions and about the simplest
thing I can think of is a web server ;-) &amp;nbsp;In fact, you already have the complete
configuration file for this sample; I showed you that in &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,7465c74e-6001-4d08-93ae-ad7110dee188.aspx"&gt;Part
8&lt;/a&gt;.&lt;br&gt;
Since things like “Hello World!” are supposed to be simple and it’s ok not to make
that a full coverage test case, we start with the following, very plain contract: 
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;[&lt;span style="COLOR: teal"&gt;ServiceContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethodOperationSelector&lt;/span&gt;]&lt;br&gt;
&lt;span style="COLOR: blue"&gt;interface&lt;/span&gt; &lt;span style="COLOR: teal"&gt;IMyWebServer&lt;br&gt;
&lt;/span&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"GET"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/*"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; Get(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg);&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;(Action = &lt;span style="COLOR: maroon"&gt;"*"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; UnknownMessage(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg);&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class=MsoNormal&gt;
By now that should not need much explanation. The &lt;i&gt;Get()&lt;/i&gt; method receives all
HTTP GET requests on the URI suffix “/*” whereby “*” is a wildcard. In other words,
all GET requests go to that method. 
&lt;br&gt;
The implementation of the service is pretty simple. &amp;nbsp;I am implementing it as
a singleton service that is constructed passing a directory name (path). 
&lt;br&gt;
The &lt;i&gt;Get()&lt;/i&gt; implementation gets the URI of the incoming request from the &lt;i&gt;To&lt;/i&gt; header
of the message’s &lt;i&gt;Headers&lt;/i&gt; collection. (Note that the HTTP transport maps the
incoming request’s absolute URI to that header once the encoder has constructed the
message.) &amp;nbsp;
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;[&lt;span style="COLOR: teal"&gt;ServiceBehavior&lt;/span&gt;(InstanceContextMode=&lt;span style="COLOR: teal"&gt;InstanceContextMode&lt;/span&gt;.Single)]&lt;br&gt;
&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MyWebServer&lt;/span&gt; : &lt;span style="COLOR: teal"&gt;IMyWebServer&lt;br&gt;
&lt;/span&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; directory;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; MyWebServer(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; directory)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.directory
= directory;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; Get(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; requestPath
= msg.Headers.To.AbsolutePath;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;// get the path&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (requestPath.Length
&amp;gt; 0 &amp;amp;&amp;amp; requestPath[0] == &lt;span style="COLOR: maroon"&gt;'/'&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
if the path is just the "/", append "default.htm" as the 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
default page.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (requestPath.Substring(1).Length
== 0)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
requestPath = &lt;span style="COLOR: maroon"&gt;"/default.htm"&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
otherwise check whether a file by the requested name exists&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; filePath
= &lt;span style="COLOR: teal"&gt;Path&lt;/span&gt;.Combine(directory, requestPath.Substring(1).Replace(&lt;span style="COLOR: maroon"&gt;'/'&lt;/span&gt;, &lt;span style="COLOR: maroon"&gt;'\\'&lt;/span&gt;));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;File&lt;/span&gt;.Exists(filePath))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
and return a file message&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxMessages&lt;/span&gt;.CreateFileReplyMessage(filePath, &lt;span style="COLOR: teal"&gt;PoxMessages&lt;/span&gt;.&lt;span style="COLOR: teal"&gt;ReplyOptions&lt;/span&gt;.None);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;// if all fails,
send a 404&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxMessages&lt;/span&gt;.CreateErrorMessage(&lt;span style="COLOR: teal"&gt;HttpStatusCode&lt;/span&gt;.NotFound);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; UnknownMessage(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxMessages&lt;/span&gt;.CreateErrorMessage(&lt;span style="COLOR: teal"&gt;HttpStatusCode&lt;/span&gt;.NotImplemented);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class=MsoNormal&gt;
Once we’ve done a few checks on the URIs path portion, we construct a file path from
the base directory and the URI path, check whether such a file exists, and if it does
we create a message for that file and return it. If we can’t find the resulting file
name, we construct a 404 “not found” error message. The &lt;i&gt;UnknownMessage()&lt;/i&gt; method
receives all requests with HTTP methods other than GET and appropriately returns a
501 “not implemented” message. Web server done.&lt;br&gt;
Well, ok. The actual messages are constructed in a helper class &lt;i&gt;PoxMessages&lt;/i&gt; that
aids in constructing the most common reply messages. The class is part of the extension
assembly code you can download and therefore I just quote the relevant methods that
are used above. We’ll start with &lt;i&gt;PoxMessages.CreateErrorMessage(), &lt;/i&gt;because
that its very simple: 
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; CreateErrorMessage(System.Net.&lt;span style="COLOR: teal"&gt;HttpStatusCode&lt;/span&gt; code)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; reply = &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt;.CreateMessage(&lt;span style="COLOR: maroon"&gt;"urn:reply"&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;HttpResponseMessageProperty&lt;/span&gt; responseProperty
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;HttpResponseMessageProperty&lt;/span&gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp; responseProperty.StatusCode = code;&lt;br&gt;
&amp;nbsp; &amp;nbsp;reply.Properties.Add(&lt;span style="COLOR: teal"&gt;HttpResponseMessageProperty&lt;/span&gt;.Name,
responseProperty);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; reply;&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class=MsoNormal&gt;
We create a plain, empty service model &lt;i&gt;Message&lt;/i&gt;, create an &lt;i&gt;HttpResponseMessageProperty&lt;/i&gt; instance,
set the &lt;i&gt;StatusCode&lt;/i&gt; to the status code we want and add the property to the message.
Return, done. 
&lt;br&gt;
The &lt;i&gt;PoxMessages.CreateFileReplyMessage()&lt;/i&gt; method is a bit more complex, because
it, well, involves opening files. I am not showing you the exact overload that’s used
in the above example but the one that’s being delegated to: &amp;nbsp;
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; CreateFileReplyMessage(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; fileName, &lt;span style="COLOR: blue"&gt;long&lt;/span&gt; rangeOffset, &lt;span style="COLOR: blue"&gt;long&lt;/span&gt; rangeLength, &lt;span style="COLOR: teal"&gt;ReplyOptions&lt;/span&gt; options)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; contentType = GetContentTypeFromFileName(fileName);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;try&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;FileStream&lt;/span&gt; fileStream
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;FileStream&lt;/span&gt;(fileName, &lt;span style="COLOR: teal"&gt;FileMode&lt;/span&gt;.Open, &lt;span style="COLOR: teal"&gt;FileAccess&lt;/span&gt;.Read, &lt;span style="COLOR: teal"&gt;FileShare&lt;/span&gt;.Read);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (rangeOffset !=
-1 &amp;amp;&amp;amp; rangeLength != -1)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;SegmentStream&lt;/span&gt; segmentStream
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;SegmentStream&lt;/span&gt;(fileStream,
rangeOffset, rangeLength, &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxMessages&lt;/span&gt;.CreateRawReplyMessage(segmentStream,
contentType, rangeOffset, rangeLength, fileStream.Length, &lt;span style="COLOR: teal"&gt;Path&lt;/span&gt;.GetFileName(fileName),
options);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;else&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxMessages&lt;/span&gt;.CreateRawReplyMessage(fileStream,
contentType, &lt;span style="COLOR: teal"&gt;Path&lt;/span&gt;.GetFileName(fileName), options);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;catch&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxMessages&lt;/span&gt;.CreateNotFoundMessage();&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class=MsoNormal&gt;
The implementation will first make a guess for the file’s content-type based on the
file-name, which is a simple registry lookup with a fallback to &lt;i&gt;application/octet-stream&lt;/i&gt;.
&amp;nbsp;Then it’ll try to open the file using a &lt;i&gt;FileStream&lt;/i&gt; object. If that works
– &amp;nbsp;ignoring the special case with &lt;i&gt;rangeOffset/rangeLength&lt;/i&gt; being set –
we delegate to the &lt;i&gt;CreateRawReplyMessage()&lt;/i&gt; method: 
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; CreateRawReplyMessage(&lt;span style="COLOR: teal"&gt;Stream&lt;/span&gt; stm, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; contentType, &lt;span style="COLOR: blue"&gt;long&lt;/span&gt; rangeOffset, &lt;span style="COLOR: blue"&gt;long&lt;/span&gt; rangeLength, &lt;span style="COLOR: blue"&gt;long&lt;/span&gt; totalLength, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; streamName, &lt;span style="COLOR: teal"&gt;ReplyOptions&lt;/span&gt; options)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;PoxStreamedMessage&lt;/span&gt; reply = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxStreamedMessage&lt;/span&gt;(stm,
16384);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;HttpResponseMessageProperty&lt;/span&gt; responseProperty
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;HttpResponseMessageProperty&lt;/span&gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; ((options &amp;amp; &lt;span style="COLOR: teal"&gt;ReplyOptions&lt;/span&gt;.ContentDisposition)
== &lt;span style="COLOR: teal"&gt;ReplyOptions&lt;/span&gt;.ContentDisposition)&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;responseProperty.Headers.Add(&lt;span style="COLOR: maroon"&gt;"Content-Disposition"&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;String&lt;/span&gt;.Format(&lt;span style="COLOR: maroon"&gt;"Content-Disposition:
attachment; filename=\"{0}\""&lt;/span&gt;, streamName));&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; responseProperty.Headers.Add(&lt;span style="COLOR: maroon"&gt;"Content-Type"&lt;/span&gt;,
contentType);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (rangeOffset != -1 &amp;amp;&amp;amp; rangeLength
!= -1)&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;responseProperty.StatusCode = System.Net.&lt;span style="COLOR: teal"&gt;HttpStatusCode&lt;/span&gt;.PartialContent;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;responseProperty.Headers.Add(&lt;span style="COLOR: maroon"&gt;"Content-Range"&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;String&lt;/span&gt;.Format(&lt;span style="COLOR: maroon"&gt;"bytes
{0}-{1}/{2}"&lt;/span&gt;,rangeOffset,rangeOffset+rangeLength,totalLength));&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;responseProperty.Headers.Add(&lt;span style="COLOR: maroon"&gt;"Content-Length"&lt;/span&gt;,
rangeLength.ToString());&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; ((options
&amp;amp; &lt;span style="COLOR: teal"&gt;ReplyOptions&lt;/span&gt;.AcceptRange) == &lt;span style="COLOR: teal"&gt;ReplyOptions&lt;/span&gt;.AcceptRange)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; responseProperty.Headers.Add(&lt;span style="COLOR: maroon"&gt;"Content-Range"&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;String&lt;/span&gt;.Format(&lt;span style="COLOR: maroon"&gt;"bytes
{0}-{1}/{2}"&lt;/span&gt;, 0, totalLength-1, totalLength));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; responseProperty.Headers.Add(&lt;span style="COLOR: maroon"&gt;"Content-Length"&lt;/span&gt;,
totalLength.ToString());&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; ((options &amp;amp; &lt;span style="COLOR: teal"&gt;ReplyOptions&lt;/span&gt;.NoCache)
== &lt;span style="COLOR: teal"&gt;ReplyOptions&lt;/span&gt;.NoCache)&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;responseProperty.Headers.Add(&lt;span style="COLOR: maroon"&gt;"Cache-Control"&lt;/span&gt;, &lt;span style="COLOR: maroon"&gt;"no-cache"&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;responseProperty.Headers.Add(&lt;span style="COLOR: maroon"&gt;"Expires"&lt;/span&gt;, &lt;span style="COLOR: maroon"&gt;"-1"&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; ((options &amp;amp; &lt;span style="COLOR: teal"&gt;ReplyOptions&lt;/span&gt;.AcceptRange)
== &lt;span style="COLOR: teal"&gt;ReplyOptions&lt;/span&gt;.AcceptRange)&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;responseProperty.Headers.Add(&lt;span style="COLOR: maroon"&gt;"Accept-Ranges"&lt;/span&gt;, &lt;span style="COLOR: maroon"&gt;"bytes"&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; reply.Properties.Add(&lt;span style="COLOR: teal"&gt;HttpResponseMessageProperty&lt;/span&gt;.Name,
responseProperty);&lt;br&gt;
&amp;nbsp;&amp;nbsp; reply.Properties.Add(&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;.Name, &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;true&lt;/span&gt;));&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; reply;&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class=MsoNormal&gt;
That method takes the stream, wraps it in our &lt;i&gt;PoxStreamedMessage&lt;/i&gt;, sets all
desired HTTP headers on the &lt;i&gt;HttpResponseMessageProperty&lt;/i&gt;, adds the property
to the message and lastly adds the &lt;i&gt;PoxEncoderMessageProperty&lt;u&gt; &lt;/u&gt;&lt;/i&gt;indicating
that we want the encoder to operate in raw binary mode. However, all these helper
methods are already part of the library and therefore the application code doesn’t
really have to deal with all of that anymore. You just construct the fitting message,
stick the content into it and return it.&lt;br&gt;
So now we have a service class and what’s left to do is to host it. For that we need
a simple service host with a tiny little twist. Since the &lt;i&gt;ServiceMetadataBehavior &lt;/i&gt;that
typically gives you the WSDL file and the service information page would conflict
with our direct interaction with HTTP, we need to switch it off. We do that by removing
it from the list of behaviors before the service is initialized.
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MyWebServerHost&lt;/span&gt; : &lt;span style="COLOR: teal"&gt;ServiceHost&lt;br&gt;
&lt;/span&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; MyWebServerHost(&lt;span style="COLOR: blue"&gt;object&lt;/span&gt; instance)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; : &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;(instance)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; OnInitialize()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Description.Behaviors.Remove&amp;lt;&lt;span style="COLOR: teal"&gt;ServiceMetadataBehavior&lt;/span&gt;&amp;gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;.OnInitialize();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Program&lt;br&gt;
&lt;/span&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Main(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[]
args)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; directoryName
= args[0];&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR: maroon"&gt;"LittleIndigoWebServer"&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (args.Length
== 0)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR: maroon"&gt;"Usage:
LittleIndigoWebServer.exe [root path]"&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (!&lt;span style="COLOR: teal"&gt;Directory&lt;/span&gt;.Exists(directoryName))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR: maroon"&gt;"Directory
'{0}' does not exist"&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR: maroon"&gt;"Web
server starting."&lt;/span&gt;);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;using&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;MyWebServerHost&lt;/span&gt; host
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MyWebServerHost&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MyWebServer&lt;/span&gt;(directoryName)))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host.Open();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR: maroon"&gt;"Web
Server running. Press ENTER to quit."&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Console&lt;/span&gt;.ReadLine();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; host.Close();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
The rest is just normal business for hosting and setting up a service model service
in a console application. We read the first argument from the command-line and assume
that’s a directory name. We verify that that is indeed so, construct the service host
passing the singleton new’ed up with the directory name. We open the service host
and we have the web server listening. The details for how the service is exposed on
the network is the job of configuration and binding and, again, exhaustively explained
in &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,7465c74e-6001-4d08-93ae-ad7110dee188.aspx"&gt;Part
8&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
Below is the downloadable archive that contains two C# projects. &lt;i&gt;Newtelligence.ServiceModelExtensions&lt;/i&gt; contains
the extension set and &lt;i&gt;LittleIndigoWebServer&lt;/i&gt; is the above demo app. The code
complies and works with the WinFX November and December CTPs. 
&lt;/p&gt;
&lt;p&gt;
If you have installed Visual Studio on drive &lt;i&gt;C:&lt;/i&gt; you should be able to run the
sample immediately with F5, since the &lt;i&gt;LittleIndigoWebServer&lt;/i&gt; project’s debugging
settings pass the .NET SDK directory to the application on startup. So if you have
that, start the server, and then browse &lt;i&gt;http://localhost:8020/StartHere.htm&lt;/i&gt; you
get this:
&lt;/p&gt;
&lt;p style="TEXT-ALIGN: center" align=center&gt;
&lt;img height=352 src="http://staff.newtelligence.net/clemensv/content/binary/image0021234567891011.jpg" width=488 border=0&gt;
&lt;/p&gt;
&lt;p&gt;
Otherwise, you can just start the server using any directory of your choosing, preferably
one with HTML content.
&lt;/p&gt;
&lt;p&gt;
And that’s it. I am happy that I’ve got all of the stuff out. This is probably the
most documentation I’ve ever written in one stretch for some public giveaway infrastructure,
but I am sure it’s worth it. I will follow up with more examples using these extensions.
For instance I will show to use this for actual POX apps (the web server is just spitting
out raw data, after all) using RSS, OPML and ASX. Stay tuned.
&lt;/p&gt;
&lt;p&gt;
Oh, and … if you like this stuff I’d be happy about comments, questions, blog mentions
and, first and foremost, public examples of other people using this stuff. License
is BSD: Use as you like, risk is all yours, mention the creators. Enjoy.
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
Download: &lt;a href="http://staff.newtelligence.net/clemensv/content/binary/newtelligence-WCFExtensions-20060901.zip"&gt;newtelligence-WCFExtensions-20060901.zip&lt;/a&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;[Note: I am preparing an update with client-side support and a few bugfixes right
now. Should be available before or on 2006-01-16]&lt;/em&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=8fc367b2-a4be-4588-8264-5455c268b94a" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,8fc367b2-a4be-4588-8264-5455c268b94a.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=7465c74e-6001-4d08-93ae-ad7110dee188</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,7465c74e-6001-4d08-93ae-ad7110dee188.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,7465c74e-6001-4d08-93ae-ad7110dee188.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=7465c74e-6001-4d08-93ae-ad7110dee188</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <div class="Section1">
          <p class="MsoNormal">
            <span lang="DE">
              <a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx">
                <span lang="EN-US">
                  <span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx">
                    <span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx">Part
1</span>
                  </span>
                </span>
              </a>
            </span>, <span lang="DE"><a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"><span lang="EN-US"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx">Part
2</span></span></span></a></span>, <span lang="DE"><a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx"><span lang="EN-US"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx">Part
3</span></span></span></a></span>, <span lang="DE"><a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx"><span lang="EN-US"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx">Part
4</span></span></span></a></span>, <a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx">Part
5</a>, <a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,51327201-07c7-4a30-b79c-53842cda1e77.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,51327201-07c7-4a30-b79c-53842cda1e77.aspx">Part
6</a>, <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,e82c8423-f106-4105-81e4-14410a83315a.aspx">Part
7</a></p>
          <p>
We’ve got all the moving pieces and what’s left is a way to configure the <i>PoxEncoder </i>into
bindings and use those to hook a service up to the network and run it. 
</p>
          <p>
Bindings? Well, all Indigo (WCF) services need to know their ABC to function. ABC?
I’ll quote from <a href="http://msdn.microsoft.com/library/en-us/dnlong/html/introtowcf.asp">my
WCF Introduction on MSDN</a>:
</p>
          <div align="center">
            <table class="MsoTableGrid" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #ffff99; BORDER-LEFT: medium none; WIDTH: 90%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="90%" border="1">
              <tbody>
                <tr>
                  <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; TEXT-ALIGN: left" valign="top" align="left">
                    <p>
                      <i>
                        <span style="FONT-SIZE: 10pt">“ABC” is the WCF mantra. “ABC” is the key to understanding
how a WCF service endpoint is composed. Think Ernie, Bert, Cookie Monster or Big Bird.
Remember "ABC". </span>
                      </i>
                    </p>
                    <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
                      <span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>
                      <i>
                        <span style="FONT-SIZE: 10pt">"A"
stands for Address: Where is the service? </span>
                      </i>
                    </p>
                    <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
                      <span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>
                      <i>
                        <span style="FONT-SIZE: 10pt">"B"
stands for Binding: How do I talk to the service? </span>
                      </i>
                    </p>
                    <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
                      <span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>
                      <i>
                        <span style="FONT-SIZE: 10pt">"C"
stands for Contract: What can the service do for me? </span>
                      </i>
                    </p>
                    <p>
                      <i>
                        <span style="FONT-SIZE: 10pt">Web services zealots who read Web Service Description
Language (WSDL) descriptions at the breakfast table will easily recognize these three
concepts as the three levels of abstraction expressed in WSDL. So if you live in a
world full of angle brackets, you can look at it this way: </span>
                      </i>
                    </p>
                    <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
                      <span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>
                      <i>
                        <span style="FONT-SIZE: 10pt">"A"
stands for Address—as expressed in the wsdl:service section and links wsdl:binding
to a concrete service endpoint address. </span>
                      </i>
                    </p>
                    <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
                      <span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>
                      <i>
                        <span style="FONT-SIZE: 10pt">"B"
stands for Binding—as expressed in the wsdl:binding section and binds a wsdl:portType
contract description to a concrete transport, an envelope format and associated policies. </span>
                      </i>
                    </p>
                    <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
                      <span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>
                      <i>
                        <span style="FONT-SIZE: 10pt">"C"
stands for Contract—as expressed in the wsdl:portType, wsdl:message and wsdl:type
sections and describes types, messages, message exchange patterns and operations. </span>
                      </i>
                    </p>
                    <p>
                      <i>
                        <span style="FONT-SIZE: 10pt">"ABC" means that writing (and configuring) a WCF
service is always a three-step process: </span>
                      </i>
                    </p>
                    <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
                      <span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>
                      <i>
                        <span style="FONT-SIZE: 10pt">You
define a contract and implement it on a service </span>
                      </i>
                    </p>
                    <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
                      <span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>
                      <i>
                        <span style="FONT-SIZE: 10pt">You
choose or define a service binding that selects a transport along with quality of
service, security and other options </span>
                      </i>
                    </p>
                    <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
                      <span style="FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>
                      <i>
                        <span style="FONT-SIZE: 10pt">You
deploy an endpoint for the contract by binding it (using the binding definition, hence
the name) to a network address.</span>
                      </i>
                    </p>
                  </td>
                </tr>
              </tbody>
            </table>
          </div>
          <p>
A binding is a layered combination of a transport, an encoder and of any additional
protocol channels (reliable session, transaction flow, etc.) that you’d like to assemble
into a transport stack for exposing a service implementation on a specific endpoint
address.
</p>
          <p>
For exposing a HTTP-based RESTish service we need:
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
A.<span style="FONT: 7pt 'Times New Roman'">    </span>The HTTP address
to host the service at.
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
B.<span style="FONT: 7pt 'Times New Roman'">     </span>Some binding
configuration that tells Indigo’s HTTP transport to use our <i>PoxEncoder.</i></p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
C.<span style="FONT: 7pt 'Times New Roman'">     </span>An implementation
of a service-contract that’s configured (using the <i>HttpMethodOperationSelectorSection</i> config
extension) or marked-up (with the <i>HttpMethodOperationSelectorAttribute) </i>to
use our <i>HttpMethodOperationSelectorBehavior</i> for endpoint address filtering
and selecting methods.
</p>
          <p>
I’ve shown you quite a few contract variants in the first parts of this series and
therefore I don’t really have to explain the <i>C</i> in too much detail anymore;
except: While the <i>A</i> is just a plain HTTP address such as <i>http://www.example.com/service</i>,
it’s interesting insofar as this address is, unlike as with SOAP services, really
just the common address prefix for the dispatch URIs of the particular service and
that there is a split between what is <i>A</i> and what is <i>C</i>.
</p>
          <p>
            <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx">As
I’ve explained</a>, the philosophy behind the contract design of my extensions is
around the namespaces that are the basis for forming URIs. Because REST services aren’t
simply using HTTP as a transport tunnel as SOAP services do, but rather leverage HTTP
as the application protocol it is, the URI is a lot more than just a drop-off point
for messages. With REST services, the URI is an expression that has both, addressing
(transport) and contract (dispatch) aspects to it and we need to separate those out.
A clear distinction between global and local namespaces allows us to do that (And
I am going into a bit more detail than I usually would, to further address an objection
of Mark Baker, <a href="http://staff.newtelligence.net/clemensv/CommentView,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx">1<sup>st</sup> comment</a>,
on my choice of the programming model):
</p>
          <p>
There is a global namespace that’s managed by the global DNS system of which anyone
can reserve a chunk for themselves by registering a domain-name. The domain-name provides
a self-manageable namespace root of which sub-namespaces (subdomains) can be derived
and allocated to specific hosts/services or groups of hosts/services by the domain
owners. On the particular host, you can put an application behind a specific port,
which might either the default port of your particular application protocol or – diverging
from the protocol standard – some other port of your choosing. Each Internet application <i>deployment</i> has
therefore at least one unique mapping into this global namespace system.
</p>
          <p>
Any further segmentation of the namespace except the host-name and the port-number
are private matters of the application listing to that endpoint. With Indigo self-hosted
HTTP services, the listening application is <i>Windows</i> (!) – more precisely it’s
the HTTP.SYS kernel listener. For IIS/WAS hosted services, the listening application
is IIS (for IIS 5.1 and below) or, again, Windows – through that very listener. At
the HTTP.SYS listener, handler processes can register their interest in requests sent
to certain sub-namespaces of the global namespace mapping (host/port), which are identified
by relative URIs. To be clear: The HTTP.SYS API indeed requires the caller to provide
an absolute URI like <i>http://hostname:port/service, </i>but the two main parts (scheme/host/port
and path) of that URI are used for different purposes: 
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
            <span style="FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>
            <i>Global
mapping:</i> The hostname and port are used to establish a new listener on that particular
port (if there is already a listener it is shared) and to populate the hostname-filter
table that’s used to disambiguate requests by the <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23">Host</a> header
in case the IP address is mapped to multiple DNS host entries. 
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
            <span style="FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>
            <i>Local
mapping:</i> The path information of the URI (the remaining relative URI with scheme,
hostname and port stripped) is used as a prefix-matching expression to figure out
which handler process shall receive the request and, inside that handler process,
to further identify and invoke the appropriate endpoint and handler that deals with
the resource that the complete URI path represents.
</p>
          <p>
As indicated, mapping URIs to an endpoint needs to distinguish between how we segment
and map a local namespace and how we hook that into the global namespace. Hence, the
root for any absolute URIs that’s establishing the mapping into the global namespace
shall <i>always</i> be separate from the code and reside in configuration for reasons
of flexibility as Mark was rightfully pointing out in his objection, while the shape
and mapping of the local namespace is typically very application and use-case specific
and might well be partially or entirely hardwired.
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
            <span style="FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>The
Indigo <i>A</i>(ddress)<i></i>of a REST service implemented with my particular programming
model is used to hook a given service (or resource representation manager, if you
like) into the global namespace: <i>http://myservice.example.com/</i>. Only to be
pragmatic and to allow multiple such services to locally share a particular hostname
and port and indeed only as an alternative and workaround to creating a separate DNS
entry for each service, that mapping might include a path prefix allowing the local
low-level infrastructure to demultiplex requests sent to the same global namespace
mapping: <i>http://myservices.example.com<b>/serviceA</b></i> and <i>http://myservices.example.com<b>/serviceB</b></i>. 
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
            <span style="FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>The
Indigo <i>C</i>(ontract) of a REST service implemented with my particular programming
model is used to define the shape of the local namespace that the service owns and
which is used to provide access to the representations of the resource-types the service
is responsible for. 
</p>
          <p class="MsoNormal">
The following configuration snippet for a simple web-server based on my extensions
is illustrating that split: 
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">&lt;</span>
                    <span style="FONT-SIZE: 8pt; COLOR: maroon; FONT-FAMILY: Courier">services</span>
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">&gt;<br />
   &lt;</span>
                    <span style="FONT-SIZE: 8pt; COLOR: maroon; FONT-FAMILY: Courier">service</span>
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">
                    </span>
                    <span style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: Courier">type</span>
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">=</span>
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">"<span style="COLOR: blue">LittleIndigoWebServer.MyWebServer</span>"<span style="COLOR: blue">&gt;<br />
      &lt;</span><span style="COLOR: maroon">endpoint</span><span style="COLOR: blue"></span><span style="COLOR: red">contract</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">LittleIndigoWebServer.IMyWebServer</span>"<br /><span style="COLOR: blue">                </span><span style="COLOR: red">address</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">http://localhost:8020/</span>"<span style="COLOR: blue"><br />
                </span><span style="COLOR: red">binding</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">customBinding</span>"<span style="COLOR: blue"><br />
                </span><span style="COLOR: red">bindingConfiguration</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">poxBinding</span>"<span style="COLOR: blue">/&gt;<br />
   &lt;/</span><span style="COLOR: maroon">service</span><span style="COLOR: blue">&gt;<br />
&lt;/</span><span style="COLOR: maroon">services</span><span style="COLOR: blue">&gt;</span></span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
The address <i>http://localhost:8020/</i> is how I map the service into the global
addressing namespace. The local namespace shape for that particular service is a defined
by the layout of the file-system directory from which the service grabs files and
returns them. What? You can’t see the directory structure and the resulting URLs from
the above mapping? Of course not. It’s a private matter of the service implementation
what that the local namespace structure is and it’s up to me what parts I am exposing.
If I am nice enough I will give you something on a GET/HEAD request on the root of
my local namespace (= global address without any suffix), and if I am not nice you
get a 404 and will just have to know what to ask for. The “will have to know” part
is contract. It’s an assurance that if you come looking at a particular place in my
namespace you will have access to a particular thing. My <i>[HttpMethod]</i> attributes
manifest that assurance on Indigo contracts. 
</p>
          <p>
That leaves B. Before I got carried away by A and C, I wrote [now a bit annotated] <i>“A
binding is a layered combination of a transport, an encoder and of any additional
protocol channels (reliable session, transaction flow, etc.) that you’d like to assemble
into a transport stack for exposing a service implementation </i>[C] <i>on a specific
endpoint address </i>[A]<i>.”</i></p>
          <p>
Putting together such a binding is not much more work than putting a little text between
angle brackets and quotation marks in config as shown in the following snippet: 
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">&lt;</span>
                    <span style="FONT-SIZE: 8pt; COLOR: maroon; FONT-FAMILY: Courier">customBinding</span>
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">&gt;<br />
   &lt;</span>
                    <span style="FONT-SIZE: 8pt; COLOR: maroon; FONT-FAMILY: Courier">binding</span>
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">
                    </span>
                    <span style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: Courier">name</span>
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">=</span>
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">"<span style="COLOR: blue">poxBinding</span>"<span style="COLOR: blue">&gt;<br />
      &lt;</span><span style="COLOR: maroon">poxEncoder</span><span style="COLOR: blue">/&gt;<br />
      &lt;</span><span style="COLOR: maroon">httpTransport</span><span style="COLOR: blue"></span><span style="COLOR: red">mapAddressingHeadersToHttpHeaders</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">true</span>"<span style="COLOR: blue"><br />
           </span><span style="COLOR: red">maxMessageSize</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">2048000</span>"<span style="COLOR: blue"></span><span style="COLOR: red">maxBufferSize</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">2048000</span>"<span style="COLOR: blue"></span><span style="COLOR: red">manualAddressing</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">true</span>"<span style="COLOR: blue"><br />
          </span><span style="COLOR: red">authenticationScheme</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Anonymous</span>"<span style="COLOR: blue"></span><span style="COLOR: red">transferMode</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">StreamedResponse</span>"<span style="COLOR: blue"> 
/&gt;<br />
   &lt;/</span><span style="COLOR: maroon">binding</span><span style="COLOR: blue">&gt;<br />
&lt;/</span><span style="COLOR: maroon">customBinding</span><span style="COLOR: blue">&gt;</span></span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p class="MsoNormal">
I am building a custom binding that’s combining the HTTP transport with a custom binding
element config extension I built for the <i>PoxEncoder</i>. It’s that simple. And
adding the binding element extension does not require black magic, either. It’s just
another XML snippet that maps the extension class to an element name (“poxEncoder”)
as you can see in the <i>extensions</i> section of the complete config file:
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"> <span style="COLOR: blue">&lt;?</span><span style="COLOR: maroon">xml</span><span style="COLOR: blue"></span><span style="COLOR: red">version</span><span style="COLOR: blue">=</span>”<span style="COLOR: blue">1.0</span>”<span style="COLOR: blue"></span><span style="COLOR: red">encoding</span><span style="COLOR: blue">=</span>”<span style="COLOR: blue">utf-8</span>”<span style="COLOR: blue"> ?&gt;<br />
&lt;</span><span style="COLOR: maroon">configuration</span><span style="COLOR: blue">&gt;<br />
   &lt;</span><span style="COLOR: maroon">system.serviceModel</span><span style="COLOR: blue">&gt;<br />
      &lt;</span><span style="COLOR: maroon">extensions</span><span style="COLOR: blue">&gt;<br />
         &lt;</span><span style="COLOR: maroon">bindingElementExtensions</span><span style="COLOR: blue">&gt;<br />
            &lt;</span><span style="COLOR: maroon">add</span><span style="COLOR: blue"></span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">poxEncoder</span>"<span style="COLOR: blue"></span><span style="COLOR: red">type</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">newtelligence.ServiceModelExtensions.PoxEncoderBindingExtension,
newtelligence.ServiceModelExtensions</span>"<span style="COLOR: blue">/&gt;<br />
         &lt;/</span><span style="COLOR: maroon">bindingElementExtensions</span><span style="COLOR: blue">&gt;<br />
      &lt;/</span><span style="COLOR: maroon">extensions</span><span style="COLOR: blue">&gt;<br />
      &lt;</span><span style="COLOR: maroon">bindings</span><span style="COLOR: blue">&gt;<br />
         &lt;</span><span style="COLOR: maroon">customBinding</span><span style="COLOR: blue">&gt;<br />
        &lt;</span><span style="COLOR: maroon">binding</span><span style="COLOR: blue"></span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">poxBinding</span>"<span style="COLOR: blue">&gt;<br />
               &lt;</span><span style="COLOR: maroon">poxEncoder</span><span style="COLOR: blue">/&gt;<br />
               &lt;</span><span style="COLOR: maroon">httpTransport</span><span style="COLOR: blue"></span><span style="COLOR: red">mapAddressingHeadersToHttpHeaders</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">true</span>"<span style="COLOR: blue"><br />
                           </span><span style="COLOR: red">maxMessageSize</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">2048000</span>"<span style="COLOR: blue"></span><span style="COLOR: red">maxBufferSize</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">2048000</span>"<span style="COLOR: blue"></span><span style="COLOR: red">manualAddressing</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">true</span>"<span style="COLOR: blue"><br />
                           </span><span style="COLOR: red">authenticationScheme</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Anonymous</span>"<span style="COLOR: blue"></span><span style="COLOR: red">transferMode</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">Streamed</span>"<span style="COLOR: blue"> 
/&gt;<br />
            &lt;/</span><span style="COLOR: maroon">binding</span><span style="COLOR: blue">&gt;<br />
         &lt;/</span><span style="COLOR: maroon">customBinding</span><span style="COLOR: blue">&gt;<br />
      &lt;/</span><span style="COLOR: maroon">bindings</span><span style="COLOR: blue">&gt;<br />
      &lt;</span><span style="COLOR: maroon">services</span><span style="COLOR: blue">&gt;<br />
         &lt;</span><span style="COLOR: maroon">service</span><span style="COLOR: blue"></span><span style="COLOR: red">type</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">LittleIndigoWebServer.MyWebServer</span>"<span style="COLOR: blue">&gt;<br />
            &lt;</span><span style="COLOR: maroon">endpoint</span><span style="COLOR: blue"></span><span style="COLOR: red">contract</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">LittleIndigoWebServer.IMyWebServer</span>"<br /><span style="COLOR: blue">                    </span><span style="COLOR: red">address</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">http://localhost:8020/</span>"<span style="COLOR: blue"><br />
                    </span><span style="COLOR: red">binding</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">customBinding</span>"<span style="COLOR: blue"><br />
                    </span><span style="COLOR: red">bindingConfiguration</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">poxBinding</span>"<span style="COLOR: blue">/&gt;<br />
         &lt;/</span><span style="COLOR: maroon">service</span><span style="COLOR: blue">&gt;<br />
      &lt;/</span><span style="COLOR: maroon">services</span><span style="COLOR: blue">&gt;<br />
  &lt;/</span><span style="COLOR: maroon">system.serviceModel</span><span style="COLOR: blue">&gt;<br />
&lt;/</span><span style="COLOR: maroon">configuration</span><span style="COLOR: blue">&gt;</span></span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p class="MsoNormal">
The <i>PoxEncoderBindingExtension</i> is a class that is based on <i>System.ServiceModel.Configuration.BindingElementExtensionSection</i>.
Whenever the configuration is processed by Indigo, the presence of the “poxEncoder”
element in a binding triggers the creation of an instance of the class and if we’d
require any configuration attributes (which we don’t), those would be stuffed into
the <i>Properties</i> collection. <i> </i>  
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">using</span>
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"> System;<br /><span style="COLOR: blue">using</span> System.ServiceModel.Configuration;<br /><span style="COLOR: blue">using</span> System.ServiceModel;<br /><span style="COLOR: blue">using</span> System.Configuration;<br /><br /><span style="COLOR: blue">namespace</span> newtelligence.ServiceModelExtensions<br />
{<br />
   <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: teal">PoxEncoderBindingExtension</span> : <span style="COLOR: teal">BindingElementExtensionSection<br /></span>   {<br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Initializes
a new instance of the </span><span style="COLOR: gray">&lt;see cref="T:PoxEncoderBindingExtension"/&gt;</span><span style="COLOR: green"> class.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>      <span style="COLOR: blue">public</span> PoxEncoderBindingExtension()<br />
      {<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Creates
the binding element.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;<br /></span>      <span style="COLOR: blue">protected</span><span style="COLOR: blue">override</span><span style="COLOR: teal">BindingElement</span> CreateBindingElement()<br />
      {<br />
         <span style="COLOR: teal">PoxEncoderBindingElement</span> pcc
= <span style="COLOR: blue">new</span><span style="COLOR: teal">PoxEncoderBindingElement</span>();<br />
         <span style="COLOR: blue">return</span> pcc;<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the type of the binding element.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;value&gt;</span><span style="COLOR: green">The
type of the binding element.</span><span style="COLOR: gray">&lt;/value&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: teal">Type</span> BindingElementType<br />
      {<br />
         <span style="COLOR: blue">get<br /></span>         {<br />
            <span style="COLOR: blue">return</span><span style="COLOR: blue">typeof</span>(<span style="COLOR: teal">PoxEncoderBindingElement</span>);<br />
         }<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the name of the configured section.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;value&gt;</span><span style="COLOR: green">The
name of the configured section.</span><span style="COLOR: gray">&lt;/value&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: blue">string</span> ConfiguredSectionName<br />
      {<br />
         <span style="COLOR: blue">get<br /></span>         {<br />
            <span style="COLOR: blue">return</span><span style="COLOR: maroon">"poxEncoder"</span>;<br />
         }<br />
      }<br /><br />
      <span style="COLOR: blue">private</span><span style="COLOR: teal">ConfigurationPropertyCollection</span> properties;<br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the collection of properties.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;value&gt;&lt;/value&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">The </span><span style="COLOR: gray">&lt;see
cref="T:System.Configuration.ConfigurationPropertyCollection"&gt;&lt;/see&gt;</span><span style="COLOR: green"> collection
of properties for the element.</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>      <span style="COLOR: blue">protected</span><span style="COLOR: blue">override</span><span style="COLOR: teal">ConfigurationPropertyCollection</span> Properties<br />
      {<br />
         <span style="COLOR: blue">get<br /></span>         {<br />
            <span style="COLOR: blue">if</span> (<span style="COLOR: blue">this</span>.properties
== <span style="COLOR: blue">null</span>)<br />
            {<br />
               <span style="COLOR: teal">ConfigurationPropertyCollection</span> configProperties
= <span style="COLOR: blue">new</span><span style="COLOR: teal">ConfigurationPropertyCollection</span>();<br />
               <span style="COLOR: blue">this</span>.properties
= configProperties;<br />
            }<br />
            <span style="COLOR: blue">return</span><span style="COLOR: blue">this</span>.properties;<br />
         }<br />
      }<br />
   }<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p class="MsoNormal">
Once the configuration information has been read, the extension is asked to create
a <i>BindingElement</i> from the acquired information. So these extensions are really
just factories for binding elements. The binding element, which can also be used to
compose such a binding in code by explicitly adding it to a <i>System.ServiceModel.CustomBinding</i> is
shown below:
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"> <span style="COLOR: blue">using</span> System;<br /><span style="COLOR: blue">using</span> System.Collections.Generic;<br /><span style="COLOR: blue">using</span> System.Text;<br /><span style="COLOR: blue">using</span> System.ServiceModel;<br /><span style="COLOR: blue">using</span> System.ServiceModel.Design;<br /><span style="COLOR: blue">using</span> System.ServiceModel.Channels;<br /><br /><span style="COLOR: blue">namespace</span> newtelligence.ServiceModelExtensions<br />
{<br />
    <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: teal">PoxEncoderBindingElement</span> : <span style="COLOR: teal">BindingElement</span>, <span style="COLOR: teal">IMessageEncodingBindingElement<br /></span>   {<br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Clones
this instance.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: teal">BindingElement</span> Clone()<br />
      {<br />
         <span style="COLOR: blue">return</span><span style="COLOR: blue">new</span><span style="COLOR: teal">PoxEncoderBindingElement</span>();<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Creates
the message encoder factory.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: teal">MessageEncoderFactory</span> CreateMessageEncoderFactory()<br />
      {<br />
         <span style="COLOR: blue">return</span><span style="COLOR: blue">new</span><span style="COLOR: teal">PoxEncoderFactory</span>();<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the addressing version.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;value&gt;</span><span style="COLOR: green">The
addressing version.</span><span style="COLOR: gray">&lt;/value&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: teal">AddressingVersion</span> AddressingVersion<br />
      {<br />
         <span style="COLOR: blue">get<br /></span>         {<br />
            <span style="COLOR: blue">return</span><span style="COLOR: teal">AddressingVersion</span>.Addressing1;<br />
         }<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the protection requirements.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span> System.ServiceModel.Security.Protocols.<span style="COLOR: teal">ChannelProtectionRequirements</span> GetProtectionRequirements()<br />
      {<br />
         <span style="COLOR: blue">return</span><span style="COLOR: blue">null</span>;<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Builds
the channel factory.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="context"&gt;</span><span style="COLOR: green">The context.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: teal">IChannelFactory</span> BuildChannelFactory(<span style="COLOR: teal">ChannelBuildContext</span> context)<br />
      {<br />
         <span style="COLOR: blue">if</span> (context
== <span style="COLOR: blue">null</span>)<br />
            <span style="COLOR: blue">throw</span><span style="COLOR: blue">new</span><span style="COLOR: teal">ArgumentNullException</span>(<span style="COLOR: maroon">"context"</span>);<br /><br />
         context.UnhandledBindingElements.Add(<span style="COLOR: blue">this</span>);<br />
         <span style="COLOR: blue">return</span> context.BuildInnerChannelFactory();<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Builds
the channel listener.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="context"&gt;</span><span style="COLOR: green">The context.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;<br /></span>        <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: teal">IChannelListener</span>&lt;TChannel&gt;
BuildChannelListener&lt;TChannel&gt;(<span style="COLOR: teal">ChannelBuildContext</span> context)<br />
        {<br />
            <span style="COLOR: blue">if</span> (context
== <span style="COLOR: blue">null</span>)<br />
            <span style="COLOR: blue">throw</span><span style="COLOR: blue">new</span><span style="COLOR: teal">ArgumentNullException</span>(<span style="COLOR: maroon">"context"</span>);<br /><br />
         context.UnhandledBindingElements.Add(<span style="COLOR: blue">this</span>);<br />
         <span style="COLOR: blue">return</span> context.BuildInnerChannelListener&lt;TChannel&gt;();<br />
      }<br />
   }<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p class="MsoNormal">
Binding elements are typically used to put together client-side (channel factory)
or service-side (channel listener) transport stacks. At the bottom is the transport
and layered on top of it are security, reliable sessions, transaction flow and all
other protocol features you need. Each protocol or feature on the channel/listener
level has its own binding element and using those you configure yourself a binding
combining the features you need and in the order that they should be applied.
</p>
          <p class="MsoNormal">
The binding elements for message encoders are a bit different, because they are not
contributing their own channel factories or channel listeners into the stack, but
rather “only” supply the message encoder for the configured transport. 
</p>
          <p class="MsoNormal">
Whenever a binding is instantiated, Indigo creates a <i>ChannelBuildContext</i> which
contains the sequence of the binding elements that shall be stacked onto each other
into a channel or listener stack and starts stacking them from top to bottom by invoking
the topmost binding element’s <i>BuildChannelListener</i> or <i>BuildChannelFactory</i> method.
Once the binding element is done creating its channel factory or channel listener,
it invokes <i>BuildInnerChannel[Listener/Factory]</i> on the context to have the binding
element underneath do its work. (The context is also used to validate whether combination
of the elements yields a functional binding stack, but I won’t go into that here).
</p>
          <p class="MsoNormal">
Our binding element, however, won’t create a channel factory or listener, but rather
put itself into the <i>UnhandledBindingElements</i> collection on the build context
and will then just have the context complete the construction work. With putting itself
into that collection, the binding element makes itself and its most irresistible feature
(you’d also think that if you were an Indigo transport) – the <i>IMessageEncodingBindingElement</i> implementation
– visible to the transport and waves its hand that it wants to be used. The transport’s
binding element, which is at the bottom of the stack and therefore asked to build
its channel factory/listener <i>after</i> our binding element has been invoked, will
go look in the <i>UnhandledBindingElements</i>  collection whether a message
encoding binding element is advertising itself for use. And if that’s so it will forget
all of its defaults and happily embrace and use an encoder created by the factory
returned by <i>IMessageEncodingBindingElement.CreateMessageEncoderFactory</i>, which
is, in our case, this rather simple class:
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"> <span style="COLOR: blue">using</span> System;<br /><span style="COLOR: blue">using</span> System.Collections.Generic;<br /><span style="COLOR: blue">using</span> System.Text;<br /><span style="COLOR: blue">using</span> System.ServiceModel.Channels;<br /><span style="COLOR: blue">using</span> System.ServiceModel;<br /><br /><span style="COLOR: blue">namespace</span> newtelligence.ServiceModelExtensions<br />
{<br />
    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"><br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>   <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: teal">PoxEncoderFactory</span> : <span style="COLOR: teal">MessageEncoderFactory<br /></span>   {<br />
      <span style="COLOR: teal">MessageEncoder</span> encoder;<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Initializes
a new instance of the </span><span style="COLOR: gray">&lt;see cref="T:PoxEncoderFactory"/&gt;</span><span style="COLOR: green"> class.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>      <span style="COLOR: blue">public</span> PoxEncoderFactory()<br />
      {<br />
          encoder = <span style="COLOR: blue">new</span><span style="COLOR: teal">PoxEncoder</span>();<br /><br />
      }<br /><br />
         <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the encoder.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;value&gt;</span><span style="COLOR: green">The
encoder.</span><span style="COLOR: gray">&lt;/value&gt;<br /></span>        <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: teal">MessageEncoder</span> Encoder<br />
      {<br />
         <span style="COLOR: blue">get<br /></span>         {<br />
            <span style="COLOR: blue">return</span> encoder;<br />
         }<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the message version.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;value&gt;</span><span style="COLOR: green">The
message version.</span><span style="COLOR: gray">&lt;/value&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: teal">MessageVersion</span> MessageVersion<br />
      {<br />
         <span style="COLOR: blue">get<br /></span>         {<br />
            <span style="COLOR: blue">return</span> encoder.MessageVersion;<br />
         }<br />
      }<br />
   }<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
Soooooooo….!
</p>
          <p>
If you had actually copied all those classes from Parts 1-8 down into local files
and compiled them into an assembly, you’d have all my REST/POX plumbing code by now
(except, admittedly, an application-level utility class that helps putting messages
together). 
</p>
          <p>
But wait … don’t do that. In the next part(s) I’ll give you the code all packed up
and ready to compile along with the little web server that we’ve configured here and
will also share some code snippets from my TV app … maybe the RSS and ASX pieces?
</p>
        </div>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=7465c74e-6001-4d08-93ae-ad7110dee188" />
      </body>
      <title>Teaching Indigo to do REST/POX: Part 8</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,7465c74e-6001-4d08-93ae-ad7110dee188.aspx</guid>
      <link>http://vasters.com/clemensv/2006/01/05/Teaching+Indigo+To+Do+RESTPOX+Part+8.aspx</link>
      <pubDate>Thu, 05 Jan 2006 15:11:21 GMT</pubDate>
      <description>&lt;div class=Section1&gt;
&lt;p class=MsoNormal&gt;
&lt;span lang=DE&gt;&lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx"&gt;&lt;span lang=EN-US&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx&gt;Part
1&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"&gt;&lt;span lang=EN-US&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx&gt;Part
2&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx"&gt;&lt;span lang=EN-US&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx&gt;Part
3&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx"&gt;&lt;span lang=EN-US&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx&gt;Part
4&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx"&gt;Part
5&lt;/a&gt;, &lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,51327201-07c7-4a30-b79c-53842cda1e77.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,51327201-07c7-4a30-b79c-53842cda1e77.aspx"&gt;Part
6&lt;/a&gt;, &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,e82c8423-f106-4105-81e4-14410a83315a.aspx"&gt;Part
7&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
We’ve got all the moving pieces and what’s left is a way to configure the &lt;i&gt;PoxEncoder &lt;/i&gt;into
bindings and use those to hook a service up to the network and run it. 
&lt;/p&gt;
&lt;p&gt;
Bindings? Well, all Indigo (WCF) services need to know their ABC to function. ABC?
I’ll quote from &lt;a href="http://msdn.microsoft.com/library/en-us/dnlong/html/introtowcf.asp"&gt;my
WCF Introduction on MSDN&lt;/a&gt;:
&lt;/p&gt;
&lt;div align=center&gt;
&lt;table class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #ffff99; BORDER-LEFT: medium none; WIDTH: 90%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="90%" border=1&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; TEXT-ALIGN: left" valign=top align=left&gt;
&lt;p&gt;
&lt;i&gt;&lt;span style="FONT-SIZE: 10pt"&gt;“ABC” is the WCF mantra. “ABC” is the key to understanding
how a WCF service endpoint is composed. Think Ernie, Bert, Cookie Monster or Big Bird.
Remember "ABC". &lt;/span&gt;&lt;/i&gt;
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span style="FONT-SIZE: 10pt"&gt;"A"
stands for Address: Where is the service? &lt;/span&gt;&lt;/i&gt;
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span style="FONT-SIZE: 10pt"&gt;"B"
stands for Binding: How do I talk to the service? &lt;/span&gt;&lt;/i&gt;
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span style="FONT-SIZE: 10pt"&gt;"C"
stands for Contract: What can the service do for me? &lt;/span&gt;&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;&lt;span style="FONT-SIZE: 10pt"&gt;Web services zealots who read Web Service Description
Language (WSDL) descriptions at the breakfast table will easily recognize these three
concepts as the three levels of abstraction expressed in WSDL. So if you live in a
world full of angle brackets, you can look at it this way: &lt;/span&gt;&lt;/i&gt;
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span style="FONT-SIZE: 10pt"&gt;"A"
stands for Address—as expressed in the wsdl:service section and links wsdl:binding
to a concrete service endpoint address. &lt;/span&gt;&lt;/i&gt;
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span style="FONT-SIZE: 10pt"&gt;"B"
stands for Binding—as expressed in the wsdl:binding section and binds a wsdl:portType
contract description to a concrete transport, an envelope format and associated policies. &lt;/span&gt;&lt;/i&gt;
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span style="FONT-SIZE: 10pt"&gt;"C"
stands for Contract—as expressed in the wsdl:portType, wsdl:message and wsdl:type
sections and describes types, messages, message exchange patterns and operations. &lt;/span&gt;&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;&lt;span style="FONT-SIZE: 10pt"&gt;"ABC" means that writing (and configuring) a WCF
service is always a three-step process: &lt;/span&gt;&lt;/i&gt;
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span style="FONT-SIZE: 10pt"&gt;You
define a contract and implement it on a service &lt;/span&gt;&lt;/i&gt;
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span style="FONT-SIZE: 10pt"&gt;You
choose or define a service binding that selects a transport along with quality of
service, security and other options &lt;/span&gt;&lt;/i&gt;
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;i&gt;&lt;span style="FONT-SIZE: 10pt"&gt;You
deploy an endpoint for the contract by binding it (using the binding definition, hence
the name) to a network address.&lt;/span&gt;&lt;/i&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;p&gt;
A binding is a layered combination of a transport, an encoder and of any additional
protocol channels (reliable session, transaction flow, etc.) that you’d like to assemble
into a transport stack for exposing a service implementation on a specific endpoint
address.
&lt;/p&gt;
&lt;p&gt;
For exposing a HTTP-based RESTish service we need:
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
A.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;The HTTP address
to host the service at.
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
B.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Some binding
configuration that tells Indigo’s HTTP transport to use our &lt;i&gt;PoxEncoder.&lt;/i&gt;
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
C.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;An implementation
of a service-contract that’s configured (using the &lt;i&gt;HttpMethodOperationSelectorSection&lt;/i&gt; config
extension) or marked-up (with the &lt;i&gt;HttpMethodOperationSelectorAttribute) &lt;/i&gt;to
use our &lt;i&gt;HttpMethodOperationSelectorBehavior&lt;/i&gt; for endpoint address filtering
and selecting methods.
&lt;/p&gt;
&lt;p&gt;
I’ve shown you quite a few contract variants in the first parts of this series and
therefore I don’t really have to explain the &lt;i&gt;C&lt;/i&gt; in too much detail anymore;
except: While the &lt;i&gt;A&lt;/i&gt; is just a plain HTTP address such as &lt;i&gt;http://www.example.com/service&lt;/i&gt;,
it’s interesting insofar as this address is, unlike as with SOAP services, really
just the common address prefix for the dispatch URIs of the particular service and
that there is a split between what is &lt;i&gt;A&lt;/i&gt; and what is &lt;i&gt;C&lt;/i&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"&gt;As
I’ve explained&lt;/a&gt;, the philosophy behind the contract design of my extensions is
around the namespaces that are the basis for forming URIs. Because REST services aren’t
simply using HTTP as a transport tunnel as SOAP services do, but rather leverage HTTP
as the application protocol it is, the URI is a lot more than just a drop-off point
for messages. With REST services, the URI is an expression that has both, addressing
(transport) and contract (dispatch) aspects to it and we need to separate those out.
A clear distinction between global and local namespaces allows us to do that (And
I am going into a bit more detail than I usually would, to further address an objection
of Mark Baker, &lt;a href="http://staff.newtelligence.net/clemensv/CommentView,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"&gt;1&lt;sup&gt;st&lt;/sup&gt; comment&lt;/a&gt;,
on my choice of the programming model):
&lt;/p&gt;
&lt;p&gt;
There is a global namespace that’s managed by the global DNS system of which anyone
can reserve a chunk for themselves by registering a domain-name. The domain-name provides
a self-manageable namespace root of which sub-namespaces (subdomains) can be derived
and allocated to specific hosts/services or groups of hosts/services by the domain
owners. On the particular host, you can put an application behind a specific port,
which might either the default port of your particular application protocol or – diverging
from the protocol standard – some other port of your choosing. Each Internet application &lt;i&gt;deployment&lt;/i&gt; has
therefore at least one unique mapping into this global namespace system.
&lt;/p&gt;
&lt;p&gt;
Any further segmentation of the namespace except the host-name and the port-number
are private matters of the application listing to that endpoint. With Indigo self-hosted
HTTP services, the listening application is &lt;i&gt;Windows&lt;/i&gt; (!) – more precisely it’s
the HTTP.SYS kernel listener. For IIS/WAS hosted services, the listening application
is IIS (for IIS 5.1 and below) or, again, Windows – through that very listener. At
the HTTP.SYS listener, handler processes can register their interest in requests sent
to certain sub-namespaces of the global namespace mapping (host/port), which are identified
by relative URIs. To be clear: The HTTP.SYS API indeed requires the caller to provide
an absolute URI like &lt;i&gt;http://hostname:port/service, &lt;/i&gt;but the two main parts (scheme/host/port
and path) of that URI are used for different purposes: 
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;i&gt;Global
mapping:&lt;/i&gt; The hostname and port are used to establish a new listener on that particular
port (if there is already a listener it is shared) and to populate the hostname-filter
table that’s used to disambiguate requests by the &lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.23"&gt;Host&lt;/a&gt; header
in case the IP address is mapped to multiple DNS host entries. 
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;&lt;i&gt;Local
mapping:&lt;/i&gt; The path information of the URI (the remaining relative URI with scheme,
hostname and port stripped) is used as a prefix-matching expression to figure out
which handler process shall receive the request and, inside that handler process,
to further identify and invoke the appropriate endpoint and handler that deals with
the resource that the complete URI path represents.
&lt;/p&gt;
&lt;p&gt;
As indicated, mapping URIs to an endpoint needs to distinguish between how we segment
and map a local namespace and how we hook that into the global namespace. Hence, the
root for any absolute URIs that’s establishing the mapping into the global namespace
shall &lt;i&gt;always&lt;/i&gt; be separate from the code and reside in configuration for reasons
of flexibility as Mark was rightfully pointing out in his objection, while the shape
and mapping of the local namespace is typically very application and use-case specific
and might well be partially or entirely hardwired.
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;The
Indigo &lt;i&gt;A&lt;/i&gt;(ddress)&lt;i&gt; &lt;/i&gt;of a REST service implemented with my particular programming
model is used to hook a given service (or resource representation manager, if you
like) into the global namespace: &lt;i&gt;http://myservice.example.com/&lt;/i&gt;. Only to be
pragmatic and to allow multiple such services to locally share a particular hostname
and port and indeed only as an alternative and workaround to creating a separate DNS
entry for each service, that mapping might include a path prefix allowing the local
low-level infrastructure to demultiplex requests sent to the same global namespace
mapping: &lt;i&gt;http://myservices.example.com&lt;b&gt;/serviceA&lt;/b&gt;&lt;/i&gt; and &lt;i&gt;http://myservices.example.com&lt;b&gt;/serviceB&lt;/b&gt;&lt;/i&gt;. 
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;The
Indigo &lt;i&gt;C&lt;/i&gt;(ontract) of a REST service implemented with my particular programming
model is used to define the shape of the local namespace that the service owns and
which is used to provide access to the representations of the resource-types the service
is responsible for. 
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
The following configuration snippet for a simple web-server based on my extensions
is illustrating that split: 
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: maroon; FONT-FAMILY: Courier"&gt;services&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: maroon; FONT-FAMILY: Courier"&gt;service&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: Courier"&gt;type&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;"&lt;span style="COLOR: blue"&gt;LittleIndigoWebServer.MyWebServer&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;endpoint&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;contract&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;LittleIndigoWebServer.IMyWebServer&lt;/span&gt;"&lt;br&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: red"&gt;address&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;http://localhost:8020/&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; 
&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: red"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;customBinding&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; 
&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: red"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;poxBinding&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;service&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;services&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
The address &lt;i&gt;http://localhost:8020/&lt;/i&gt; is how I map the service into the global
addressing namespace. The local namespace shape for that particular service is a defined
by the layout of the file-system directory from which the service grabs files and
returns them. What? You can’t see the directory structure and the resulting URLs from
the above mapping? Of course not. It’s a private matter of the service implementation
what that the local namespace structure is and it’s up to me what parts I am exposing.
If I am nice enough I will give you something on a GET/HEAD request on the root of
my local namespace (= global address without any suffix), and if I am not nice you
get a 404 and will just have to know what to ask for. The “will have to know” part
is contract. It’s an assurance that if you come looking at a particular place in my
namespace you will have access to a particular thing. My &lt;i&gt;[HttpMethod]&lt;/i&gt; attributes
manifest that assurance on Indigo contracts. 
&lt;/p&gt;
&lt;p&gt;
That leaves B. Before I got carried away by A and C, I wrote [now a bit annotated] &lt;i&gt;“A
binding is a layered combination of a transport, an encoder and of any additional
protocol channels (reliable session, transaction flow, etc.) that you’d like to assemble
into a transport stack for exposing a service implementation &lt;/i&gt;[C] &lt;i&gt;on a specific
endpoint address &lt;/i&gt;[A]&lt;i&gt;.”&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
Putting together such a binding is not much more work than putting a little text between
angle brackets and quotation marks in config as shown in the following snippet: 
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;&amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: maroon; FONT-FAMILY: Courier"&gt;customBinding&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: maroon; FONT-FAMILY: Courier"&gt;binding&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: red; FONT-FAMILY: Courier"&gt;name&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;=&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;"&lt;span style="COLOR: blue"&gt;poxBinding&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;poxEncoder&lt;/span&gt;&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;httpTransport&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;mapAddressingHeadersToHttpHeaders&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;true&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: red"&gt;maxMessageSize&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;2048000&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;maxBufferSize&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;2048000&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;manualAddressing&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;true&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: red"&gt;authenticationScheme&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;Anonymous&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;transferMode&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;StreamedResponse&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;nbsp;
/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;customBinding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class=MsoNormal&gt;
I am building a custom binding that’s combining the HTTP transport with a custom binding
element config extension I built for the &lt;i&gt;PoxEncoder&lt;/i&gt;. It’s that simple. And
adding the binding element extension does not require black magic, either. It’s just
another XML snippet that maps the extension class to an element name (“poxEncoder”)
as you can see in the &lt;i&gt;extensions&lt;/i&gt; section of the complete config file:
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;xml&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;version&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;”&lt;span style="COLOR: blue"&gt;1.0&lt;/span&gt;”&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;encoding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;”&lt;span style="COLOR: blue"&gt;utf-8&lt;/span&gt;”&lt;span style="COLOR: blue"&gt; ?&amp;gt;&lt;br&gt;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;configuration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;system.serviceModel&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;extensions&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;bindingElementExtensions&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;add&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;poxEncoder&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;type&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;newtelligence.ServiceModelExtensions.PoxEncoderBindingExtension,
newtelligence.ServiceModelExtensions&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;bindingElementExtensions&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;extensions&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;bindings&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;customBinding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;poxBinding&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;poxEncoder&lt;/span&gt;&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;httpTransport&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;mapAddressingHeadersToHttpHeaders&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;true&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: red"&gt;maxMessageSize&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;2048000&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;maxBufferSize&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;2048000&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;manualAddressing&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;true&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: red"&gt;authenticationScheme&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;Anonymous&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;transferMode&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;Streamed&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;nbsp;
/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;customBinding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;bindings&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;services&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;service&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;type&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;LittleIndigoWebServer.MyWebServer&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;endpoint&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;contract&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;LittleIndigoWebServer.IMyWebServer&lt;/span&gt;"&lt;br&gt;
&lt;span style="COLOR: blue"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: red"&gt;address&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;http://localhost:8020/&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: red"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;customBinding&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: red"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;poxBinding&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;service&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;services&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;system.serviceModel&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;br&gt;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;configuration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class=MsoNormal&gt;
The &lt;i&gt;PoxEncoderBindingExtension&lt;/i&gt; is a class that is based on &lt;i&gt;System.ServiceModel.Configuration.BindingElementExtensionSection&lt;/i&gt;.
Whenever the configuration is processed by Indigo, the presence of the “poxEncoder”
element in a binding triggers the creation of an instance of the class and if we’d
require any configuration attributes (which we don’t), those would be stuffed into
the &lt;i&gt;Properties&lt;/i&gt; collection. &lt;i&gt;&amp;nbsp;&lt;/i&gt;&amp;nbsp;&amp;nbsp;
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt; System;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel.Configuration;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Configuration;&lt;br&gt;
&lt;br&gt;
&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; newtelligence.ServiceModelExtensions&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxEncoderBindingExtension&lt;/span&gt; : &lt;span style="COLOR: teal"&gt;BindingElementExtensionSection&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Initializes
a new instance of the &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see cref="T:PoxEncoderBindingExtension"/&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; class.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; PoxEncoderBindingExtension()&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Creates
the binding element.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;BindingElement&lt;/span&gt; CreateBindingElement()&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;PoxEncoderBindingElement&lt;/span&gt; pcc
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxEncoderBindingElement&lt;/span&gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; pcc;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the type of the binding element.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The
type of the binding element.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/value&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Type&lt;/span&gt; BindingElementType&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: teal"&gt;PoxEncoderBindingElement&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the name of the configured section.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The
name of the configured section.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/value&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; ConfiguredSectionName&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: maroon"&gt;"poxEncoder"&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ConfigurationPropertyCollection&lt;/span&gt; properties;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the collection of properties.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;value&amp;gt;&amp;lt;/value&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see
cref="T:System.Configuration.ConfigurationPropertyCollection"&amp;gt;&amp;lt;/see&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; collection
of properties for the element.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ConfigurationPropertyCollection&lt;/span&gt; Properties&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.properties
== &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;ConfigurationPropertyCollection&lt;/span&gt; configProperties
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ConfigurationPropertyCollection&lt;/span&gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.properties
= configProperties;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.properties;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class=MsoNormal&gt;
Once the configuration information has been read, the extension is asked to create
a &lt;i&gt;BindingElement&lt;/i&gt; from the acquired information. So these extensions are really
just factories for binding elements. The binding element, which can also be used to
compose such a binding in code by explicitly adding it to a &lt;i&gt;System.ServiceModel.CustomBinding&lt;/i&gt; is
shown below:
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Text;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel.Design;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel.Channels;&lt;br&gt;
&lt;br&gt;
&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; newtelligence.ServiceModelExtensions&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxEncoderBindingElement&lt;/span&gt; : &lt;span style="COLOR: teal"&gt;BindingElement&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;IMessageEncodingBindingElement&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Clones
this instance.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;BindingElement&lt;/span&gt; Clone()&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxEncoderBindingElement&lt;/span&gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Creates
the message encoder factory.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MessageEncoderFactory&lt;/span&gt; CreateMessageEncoderFactory()&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxEncoderFactory&lt;/span&gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the addressing version.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The
addressing version.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/value&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: teal"&gt;AddressingVersion&lt;/span&gt; AddressingVersion&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: teal"&gt;AddressingVersion&lt;/span&gt;.Addressing1;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the protection requirements.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; System.ServiceModel.Security.Protocols.&lt;span style="COLOR: teal"&gt;ChannelProtectionRequirements&lt;/span&gt; GetProtectionRequirements()&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Builds
the channel factory.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="context"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The context.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;IChannelFactory&lt;/span&gt; BuildChannelFactory(&lt;span style="COLOR: teal"&gt;ChannelBuildContext&lt;/span&gt; context)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (context
== &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ArgumentNullException&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"context"&lt;/span&gt;);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;context.UnhandledBindingElements.Add(&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; context.BuildInnerChannelFactory();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Builds
the channel listener.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="context"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The context.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;IChannelListener&lt;/span&gt;&amp;lt;TChannel&amp;gt;
BuildChannelListener&amp;lt;TChannel&amp;gt;(&lt;span style="COLOR: teal"&gt;ChannelBuildContext&lt;/span&gt; context)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (context
== &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;throw&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ArgumentNullException&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"context"&lt;/span&gt;);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;context.UnhandledBindingElements.Add(&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; context.BuildInnerChannelListener&amp;lt;TChannel&amp;gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p class=MsoNormal&gt;
Binding elements are typically used to put together client-side (channel factory)
or service-side (channel listener) transport stacks. At the bottom is the transport
and layered on top of it are security, reliable sessions, transaction flow and all
other protocol features you need. Each protocol or feature on the channel/listener
level has its own binding element and using those you configure yourself a binding
combining the features you need and in the order that they should be applied.
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
The binding elements for message encoders are a bit different, because they are not
contributing their own channel factories or channel listeners into the stack, but
rather “only” supply the message encoder for the configured transport. 
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
Whenever a binding is instantiated, Indigo creates a &lt;i&gt;ChannelBuildContext&lt;/i&gt; which
contains the sequence of the binding elements that shall be stacked onto each other
into a channel or listener stack and starts stacking them from top to bottom by invoking
the topmost binding element’s &lt;i&gt;BuildChannelListener&lt;/i&gt; or &lt;i&gt;BuildChannelFactory&lt;/i&gt; method.
Once the binding element is done creating its channel factory or channel listener,
it invokes &lt;i&gt;BuildInnerChannel[Listener/Factory]&lt;/i&gt; on the context to have the binding
element underneath do its work. (The context is also used to validate whether combination
of the elements yields a functional binding stack, but I won’t go into that here).
&lt;/p&gt;
&lt;p class=MsoNormal&gt;
Our binding element, however, won’t create a channel factory or listener, but rather
put itself into the &lt;i&gt;UnhandledBindingElements&lt;/i&gt; collection on the build context
and will then just have the context complete the construction work. With putting itself
into that collection, the binding element makes itself and its most irresistible feature
(you’d also think that if you were an Indigo transport) – the &lt;i&gt;IMessageEncodingBindingElement&lt;/i&gt; implementation
– visible to the transport and waves its hand that it wants to be used. The transport’s
binding element, which is at the bottom of the stack and therefore asked to build
its channel factory/listener &lt;i&gt;after&lt;/i&gt; our binding element has been invoked, will
go look in the &lt;i&gt;UnhandledBindingElements&lt;/i&gt; &amp;nbsp;collection whether a message
encoding binding element is advertising itself for use. And if that’s so it will forget
all of its defaults and happily embrace and use an encoder created by the factory
returned by &lt;i&gt;IMessageEncodingBindingElement.CreateMessageEncoderFactory&lt;/i&gt;, which
is, in our case, this rather simple class:
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Text;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel.Channels;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel;&lt;br&gt;
&lt;br&gt;
&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; newtelligence.ServiceModelExtensions&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxEncoderFactory&lt;/span&gt; : &lt;span style="COLOR: teal"&gt;MessageEncoderFactory&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;MessageEncoder&lt;/span&gt; encoder;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Initializes
a new instance of the &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see cref="T:PoxEncoderFactory"/&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; class.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; PoxEncoderFactory()&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; encoder = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxEncoder&lt;/span&gt;();&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the encoder.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The
encoder.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/value&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MessageEncoder&lt;/span&gt; Encoder&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; encoder;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the message version.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The
message version.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/value&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MessageVersion&lt;/span&gt; MessageVersion&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; encoder.MessageVersion;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
Soooooooo….!
&lt;/p&gt;
&lt;p&gt;
If you had actually copied all those classes from Parts 1-8 down into local files
and compiled them into an assembly, you’d have all my REST/POX plumbing code by now
(except, admittedly, an application-level utility class that helps putting messages
together). 
&lt;/p&gt;
&lt;p&gt;
But wait … don’t do that. In the next part(s) I’ll give you the code all packed up
and ready to compile along with the little web server that we’ve configured here and
will also share some code snippets from my TV app … maybe the RSS and ASX pieces?
&lt;/p&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=7465c74e-6001-4d08-93ae-ad7110dee188" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,7465c74e-6001-4d08-93ae-ad7110dee188.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=3de7bd79-8505-4644-87b7-d75dc96c17f5</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,3de7bd79-8505-4644-87b7-d75dc96c17f5.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,3de7bd79-8505-4644-87b7-d75dc96c17f5.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=3de7bd79-8505-4644-87b7-d75dc96c17f5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In case you are not following my <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,e82c8423-f106-4105-81e4-14410a83315a.aspx">Indigo
REST/POX series</a>, I quote one paragraph from today's Part 7 that is well worth
to be quoted out of context. It talks about (SOAP-) messages and the misconception
that a message is a small thing:
</p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <em>There’s no specification that says that you cannot stick 500 Terabyte or 500 Exabyte
worth of data (think 365x24 live 1080i video streams) into a single message. As long
as you have some reason to believe that the sender will eventually, in 20 years from
now, give you “&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;” to terminate the message,
the message can be assumed to be well-formed and complete.</em>
          </p>
        </blockquote>
        <p dir="ltr">
The WCF transports that support "streamed" transfer-mode (all except MSMQ) all
consider messages to be monsters like that when streaming is enabled. I have
a bit more on the streaming mode in today's <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,e82c8423-f106-4105-81e4-14410a83315a.aspx">part
of the series</a>.
</p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3de7bd79-8505-4644-87b7-d75dc96c17f5" />
      </body>
      <title>Maximum message size: Unlimited.</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,3de7bd79-8505-4644-87b7-d75dc96c17f5.aspx</guid>
      <link>http://vasters.com/clemensv/2006/01/04/Maximum+Message+Size+Unlimited.aspx</link>
      <pubDate>Wed, 04 Jan 2006 21:21:59 GMT</pubDate>
      <description>&lt;p&gt;
In case you are not following my &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,e82c8423-f106-4105-81e4-14410a83315a.aspx"&gt;Indigo
REST/POX series&lt;/a&gt;, I quote one paragraph from today's Part 7 that is well worth
to&amp;nbsp;be quoted out of context. It talks about (SOAP-) messages and the misconception
that a message is a small thing:
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;em&gt;There’s no specification that says that you cannot stick 500 Terabyte or 500 Exabyte
worth of data (think 365x24 live 1080i video streams) into a single message. As long
as you have some reason to believe that the sender will eventually, in 20 years from
now, give you “&amp;lt;/soap:Body&amp;gt;&amp;lt;/soap:Envelope&amp;gt;” to terminate the message,
the message can be assumed to be well-formed and complete.&lt;/em&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p dir=ltr&gt;
The WCF&amp;nbsp;transports that support "streamed" transfer-mode (all except MSMQ) all
consider messages to be monsters like that when&amp;nbsp;streaming is enabled. I have
a bit more on the streaming mode in today's &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,e82c8423-f106-4105-81e4-14410a83315a.aspx"&gt;part
of the series&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3de7bd79-8505-4644-87b7-d75dc96c17f5" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,3de7bd79-8505-4644-87b7-d75dc96c17f5.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=e82c8423-f106-4105-81e4-14410a83315a</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,e82c8423-f106-4105-81e4-14410a83315a.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,e82c8423-f106-4105-81e4-14410a83315a.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=e82c8423-f106-4105-81e4-14410a83315a</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <div class="Section1">
          <p>
            <span lang="DE">
              <a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx">
                <span lang="EN-US">
                  <span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx">Part
1</span>
                </span>
              </a>
            </span>, <span lang="DE"><a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"><span lang="EN-US"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx">Part
2</span></span></a></span>, <span lang="DE"><a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx"><span lang="EN-US"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx">Part
3</span></span></a></span>, <span lang="DE"><a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx"><span lang="EN-US"><span title="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx">Part
4</span></span></a></span>, <a title="http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx" href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx">Part
5</a>, <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,51327201-07c7-4a30-b79c-53842cda1e77.aspx">Part
6</a>, <strong>Part 7</strong>, <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,7465c74e-6001-4d08-93ae-ad7110dee188.aspx">Part
8</a>, <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,8fc367b2-a4be-4588-8264-5455c268b94a.aspx">Part
9</a></p>
          <p>
Where are we?
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
            <span style="FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>In
Parts 1 and 2, I explained contracts in the REST/POX context and the dispatch mechanisms
that we need to enable Indigo to accept and handle REST/POX requests. With that I
introduced a metadata extension, the <i>[HttpMethod]</i> attribute that can be used
to mark up operations on an Indigo contract with HTTP methods and a URI suffixes that
we can dispatch on. I also showed how we can employ a parameter inspector to extract
URI-embedded arguments and flow them to the operation in a message property.
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
            <span style="FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>In
Parts 3 and 4, I showed how we use the <i>[HttpMethodOperationSelector]</i> attribute
to replace Indigo’s default address filtering and operation selection mechanisms,
basically the entire message dispatch mechanism, with our own variants. The <i>SuffixFilter</i> is
used to find the appropriate endpoint for an incoming request and the <i>HttpMethodOperationSelectorBehavior </i> find
the operation (method) on that endpoint which shall receive the incoming request message.
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
            <span style="FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>In
Parts 5 and 6, you saw how the <i>PoxEncoder</i> puts outbound envelope-less POX documents
onto the wire in its <i>WriteMessage</i> methods and accepts incoming non-SOAP XML
requests through its <i>ReadMessage </i>methods and wraps them with an in-memory envelope
(“message”) for further processing. I also showed the <i>PoxBase64XmlStreamReader</i>,
which is an XML Infoset wrapper for arbitrary binary streams that interacts with the <i>PoxEncoder </i>to
allow smuggling any sort of raw binary content through the Indigo infrastructure and
onto the wire.
</p>
          <p>
We’re pretty far along already. We’ve got the dispatch mechanisms, we know how to
hook the dispatch metadata into the services, we’ve got the wire-encoding – we have
most of the core pieces together. In fact, the last two key classes we’re missing
(configuration hooks aside) are two specialized message classes that we need to handle
incoming requests. In Part 6, you could see that the two <i>ReadMessage</i> overloads
of the <i>PoxEncoder</i> delegate all work to the <i>PoxBufferedMessage</i> for the
“buffered” transfer-mode overload and to <i>PoxStreamedMessage</i> for the “streamed”
transfer mode overload.
</p>
          <p>
            <i>ReadMessage </i>is called on an encoder whenever a transport has received a complete
message buffer (buffered mode) or has accepted and opened a network stream (streamed
mode). 
</p>
          <p>
Using streamed mode means very concretely that Indigo will start handling the message
even though the message might not have completely arrived. A transport in streaming
mode will only do as much as it needs to do in order to deal with the transport-level
framing protocol. I use “framing protocol” as a general term for what is done at the
transport level to know what the nature of the payload is and where the payload starts
and ends. For HTTP, the HTTP transport figures out whether an incoming request is
indeed an HTTP request, will read/parse the HTTP headers, and will then layer a stream
over the request’s content, irrespective of whether the transfer of that byte sequence
has already been completed. This stream is immediately handed off to the rest of the
Indigo infrastructure and the transport has done its work by doing so. 
</p>
          <p>
Pulling the remaining bytes from that stream is someone else’s responsibility in streamed
mode. Whenever a piece of the infrastructure pulls data directly or indirectly from
the stream and the data chunk requested is still in transfer, the stream will block
and wait until the data is there. The transport’s handling of the framing protocol
will typically also take care of chunking and thus make a chunked stream appear to
be continuous. When I say “indirect pull” I mean that it may very well be an <i>XmlDictionaryReader</i> layered
over an <i>XmlReader</i> layered over the incoming network stream. 
</p>
          <p>
The streaming mode is of particular interest for very large messages that may, in
an extreme case, be virtually limitless in size. There’s no specification that says
that you cannot stick 500 Terabyte or 500 Exabyte worth of data (think 365x24 live
1080i video streams) into a single message. As long as you have some reason to believe
that the sender will eventually, in 20 years from now, give you “&lt;/soap:Body&gt;&lt;/soap:Envelope&gt;”
to terminate the message, the message can be assumed to be well-formed and complete.
</p>
          <p>
No matter whether you use buffered or streamed mode, the configured encoder’s <i>ReadMessage</i> method
is the first place where the read data chunk or the stream goes and that delegates,
as shown to our two message classes. So let’s look at them.
</p>
          <p>
We’ll primarily look at the <i>PoxBufferedMessage</i>, which is constructed over the
read message buffer in the <i>PoxEncoder</i> like this:
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: Courier">public</span>
                    <span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier">
                      <span style="COLOR: blue">override</span>
                      <span style="COLOR: teal">Message</span> ReadMessage(<span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;
buffer, <span style="COLOR: teal">BufferManager</span> bufferManager)<br />
{<br />
   <span style="COLOR: blue">return</span><span style="COLOR: blue">new</span><span style="COLOR: teal">PoxBufferedMessage</span>(buffer,
bufferManager);<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
The class <i>PoxBufferedMessage</i> is derived from the abstract <i>System.ServiceModel.Message</i> class
and implements the base-class’s abstract properties <i>Headers, Properties, </i>and <i>Version</i> and
overrides the <i>OnClose(), OnGetReaderAtBodyContents()</i>, and <i>OnWriteBodyContents()</i> virtual
methods. Internally, Indigo has several such <i>Message</i> implementations that are
each customized for certain scenarios. Implementing own variants of <i>Message</i> is
simply another extensibility mechanism that Indigo gives us. 
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">Using</span>
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"> System;<br /><span style="COLOR: blue">using</span> System.Collections.Generic;<br /><span style="COLOR: blue">using</span> System.Text;<br /><span style="COLOR: blue">using</span> System.ServiceModel;<br /><span style="COLOR: blue">using</span> System.IO;<br /><span style="COLOR: blue">using</span> System.Xml;<br /><span style="COLOR: blue">using</span> System.Runtime.CompilerServices;<br /><span style="COLOR: blue">using</span> System.ServiceModel.Channels;<br /><br /><span style="COLOR: blue">namespace</span> newtelligence.ServiceModelExtensions<br />
{<br />
    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> This
class is one of the message classes used by the </span><span style="COLOR: gray">&lt;see
cref="T:PoxEncoder"/&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> It
serves to wrap an unencapsulated data buffer with a message structure.<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> The
data buffer becomes the body content of the message.<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>   <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: teal">PoxBufferedMessage</span> : <span style="COLOR: teal">Message</span>, <span style="COLOR: teal">IPoxRawBodyMessage<br /></span>   {<br />
      <span style="COLOR: teal">MessageHeaders</span> headers
= <span style="COLOR: blue">new</span><span style="COLOR: teal">MessageHeaders</span>(<span style="COLOR: teal">MessageVersion</span>.Soap11Addressing1);<br />
      <span style="COLOR: teal">MessageProperties</span> properties
= <span style="COLOR: blue">new</span><span style="COLOR: teal">MessageProperties</span>();<br />
      <span style="COLOR: blue">byte</span>[] buffer;<br />
      <span style="COLOR: blue">int</span> bufferSize;<br />
      <span style="COLOR: teal">BufferManager</span> bufferManager;<br />
      <span style="COLOR: teal">Stream</span> body;<br />
        
<br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Initializes
a new instance of the </span><span style="COLOR: gray">&lt;see cref="T:PoxBufferedMessage"/&gt;</span><span style="COLOR: green"> class.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="buffer"&gt;</span><span style="COLOR: green">The buffer.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>      <span style="COLOR: blue">public</span> PoxBufferedMessage(<span style="COLOR: blue">byte</span>[]
buffer)<br />
      {<br />
            bufferManager = <span style="COLOR: blue">null</span>;<br />
            buffer = buffer;<br />
            bufferSize = buffer.Length;<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Initializes
a new instance of the </span><span style="COLOR: gray">&lt;see cref="T:PoxBufferedMessage"/&gt;</span><span style="COLOR: green"> class.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="buffer"&gt;</span><span style="COLOR: green">The buffer.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="bufferManager"&gt;</span><span style="COLOR: green">The buffer manager.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: blue">public</span> PoxBufferedMessage(<span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;
buffer, <span style="COLOR: teal">BufferManager</span> bufferManager)<br />
        {<br />
            bufferManager =
bufferManager;<br />
            bufferSize = buffer.Count;<br />
            buffer = bufferManager.TakeBuffer(
bufferSize);<br />
            <span style="COLOR: teal">Array</span>.Copy(buffer.Array,
buffer.Offset, buffer, 0, bufferSize);<br />
        }      </span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
We can construct instances of the class over a raw byte array or an “array segment”
layered over such an array. Array segments are preferred over raw arrays, because
their use eases memory management. You can keep a pool of buffers with a common size,
even though the actual content is shorter than the buffer size and probably even offset
from the lower buffer boundary. If we get a raw byte array we simply adopt it, but
if we get an array segment alongside a reference to a buffer manager we take a new
buffer from the buffer manager and copy the array segment to that acquired buffer.
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">     
  <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Called
when the message is being closed.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: blue">protected</span><span style="COLOR: blue">override</span><span style="COLOR: blue">void</span> OnClose()<br />
        {<br />
            <span style="COLOR: blue">base</span>.OnClose();<br />
            <span style="COLOR: blue">if</span> (
bufferManager != <span style="COLOR: blue">null</span>)<br />
            {<br />
               
bufferManager.ReturnBuffer( buffer);<br />
            }            
<br />
        }</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
When we close the message and we have acquired it using the buffer manager (which
is signaled by the presence of the reference) we duly return it once the message is
being closed (or disposed or finalized). 
</p>
          <p>
The next two methods are an implementation of the <i>IPoxRawBodyMessage</i> interface
that is, you guessed it, defined in my extensions. If the handler method wants to
get straight at the raw body content knowing that it doesn’t expect XML, it can shortcut
by the whole <i>XmlReader</i> and XML serialization story by asking for the <i>BodyContentType</i> and
pull out the raw body data as a stream layered over the buffer: 
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the raw body stream.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;<br /></span>      [<span style="COLOR: teal">MethodImpl</span>(<span style="COLOR: teal">MethodImplOptions</span>.Synchronized)]<br />
      <span style="COLOR: blue">public</span><span style="COLOR: teal">Stream</span> GetRawBodyStream()<br />
      {<br />
         <span style="COLOR: blue">if</span> (
body == <span style="COLOR: blue">null</span>)<br />
         {<br />
             body = <span style="COLOR: blue">new</span><span style="COLOR: teal">MemoryStream</span>(
buffer,0, bufferSize,<span style="COLOR: blue">false</span>,<span style="COLOR: blue">true</span>);<br />
         }<br />
         <span style="COLOR: blue">return</span> body;<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the content type of the raw message body based on the Content-Type HTTP header 
<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> contained
in the HttpRequestMessageProperty or HttpResponseMessageProperty of this<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> message.
The value is null if the type is unknown.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: blue">public</span><span style="COLOR: blue">string</span> BodyContentType<br />
        {<br />
            <span style="COLOR: blue">get</span><br />
            {<br />
                <span style="COLOR: blue">if</span> (Properties.ContainsKey(<span style="COLOR: teal">HttpRequestMessageProperty</span>.Name))<br />
               
{<br />
                    <span style="COLOR: blue">return</span> ((<span style="COLOR: teal">HttpRequestMessageProperty</span>)Properties[<span style="COLOR: teal">HttpRequestMessageProperty</span>.Name]).Headers[<span style="COLOR: maroon">"Content-Type"</span>];<br />
               
}<br />
                <span style="COLOR: blue">if</span> (Properties.ContainsKey(<span style="COLOR: teal">HttpResponseMessageProperty</span>.Name))<br />
               
{<br />
                    <span style="COLOR: blue">return</span> ((<span style="COLOR: teal">HttpResponseMessageProperty</span>)Properties[<span style="COLOR: teal">HttpResponseMessageProperty</span>.Name]).Headers[<span style="COLOR: maroon">"Content-Type"</span>];<br />
               
}<br />
                <span style="COLOR: blue">return</span><span style="COLOR: blue">null</span>;<br />
            }<br />
        }</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
There is a bit of caution required using this mechanism, though. Because the message <i>State</i> (Created,
Written, Read, Copied, Closed) is controlled by the base-class and cannot be set by
derived classes, the message should be considered to be in the <i>State==MessageState.Read</i> after
calling the <i>GetRawBodyStream()</i> method. That doesn’t seem to be necessary because
we have a buffer here, but for the streamed variant that’s a must. And for the sake
of consistency we introduce this constraint here. 
</p>
          <p>
The <i>BodyContentType</i> property implementation seems, admittedly, a bit strange
at first sight. Even though you won’t see the message properties being populated anywhere
inside this class, we’re asking for them and base the content-type detection on their
values. That only makes sense when we consider the way messages are being populated
by Indigo. As I explained, the first thing that gets called once the transport has
a raw data chunk or stream in its hands that it believes to be a message, it invokes
the encoder. For incoming requests/messages, the encoder is really serving as the
message factory constructing <i>Message</i>-derived instances over raw data. Once
the encoder has constructed the message in one of the <i>ReadMessage</i> overloads,
the message is returned to the transport. If the transport wants, it can then (and
the HTTP transport does) stick properties into that newly created message and then
hand it off to the rest of the channel infrastructure for processing and dispatching.
Because these extensions are built for REST/POX and therefore have HTTP affinity,
that’s precisely what we assume to be happening for the <i>BodyContentType</i> property
and the <i>CreateBodyReader() </i>method below. As I already explained in Part 1,
the HTTP transport will always add a <i>HttpRequestMessageProperty</i>  to the
message and that’s consequently from which we can grab the content-type of the incoming
request data.
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">        <span style="COLOR: blue">private</span><span style="COLOR: teal">XmlDictionaryReader</span> CreateBodyReader()<br />
        {<br />
            <span style="COLOR: teal">XmlDictionaryReader</span> reader
= <span style="COLOR: blue">null</span>;<br /><br />
            <span style="COLOR: green">/* 
<br />
             * Check whether
the message properties indicate that this is a raw binary message.<br />
             * In that
case, we'll wrap the body with a PoxBase64XmlStreamReader 
<br />
             */<br /></span>            <span style="COLOR: blue">bool</span> hasPoxEncoderProperty
= Properties.ContainsKey(<span style="COLOR: teal">PoxEncoderMessageProperty</span>.Name);<br />
            <span style="COLOR: blue">if</span> (!(hasPoxEncoderProperty
&amp;&amp; ((<span style="COLOR: teal">PoxEncoderMessageProperty</span>)Properties[<span style="COLOR: teal">PoxEncoderMessageProperty</span>.Name]).RawBinary))<br />
            {<br />
                <span style="COLOR: blue">string</span> contentType
= <span style="COLOR: blue">null</span>;<br /><br />
                <span style="COLOR: green">/*<br />
                
* Check for whether either the HttpRequestMessageProperty or the HttpResponseMessageProperty 
<br />
                
* are present. If so, extract the HTTP Content-Type header. Otherwise the content-type
is 
<br />
                
* assumed to be text/xml ("POX")<br />
                 */<br /></span>                <span style="COLOR: blue">bool</span> hasRequestProperty
= Properties.ContainsKey(<span style="COLOR: teal">HttpRequestMessageProperty</span>.Name);<br />
                <span style="COLOR: blue">bool</span> hasResponseProperty
= Properties.ContainsKey(<span style="COLOR: teal">HttpResponseMessageProperty</span>.Name);<br />
                <span style="COLOR: blue">if</span> (hasResponseProperty)<br />
               
{<br />
                    <span style="COLOR: teal">HttpResponseMessageProperty</span> responseProperty
= 
<br />
                     
Properties[<span style="COLOR: teal">HttpResponseMessageProperty</span>.Name] <span style="COLOR: blue">as</span><span style="COLOR: teal">HttpResponseMessageProperty</span>;<br />
                   
contentType = responseProperty.Headers[<span style="COLOR: maroon">"Content-Type"</span>];<br />
               
}<br />
                <span style="COLOR: blue">else</span><span style="COLOR: blue">if</span> (hasRequestProperty)<br />
               
{<br />
                    <span style="COLOR: teal">HttpRequestMessageProperty</span> requestProperty
= 
<br />
                      
Properties[<span style="COLOR: teal">HttpRequestMessageProperty</span>.Name] <span style="COLOR: blue">as</span><span style="COLOR: teal">HttpRequestMessageProperty</span>;<br />
                   
contentType = requestProperty.Headers[<span style="COLOR: maroon">"Content-Type"</span>];<br />
               
}<br /><br />
                <span style="COLOR: blue">if</span> (contentType
== <span style="COLOR: blue">null</span>)<br />
               
{<br />
                   
contentType = <span style="COLOR: maroon">"text/xml"</span>;<br />
               
}<br /><br />
                <span style="COLOR: green">/*<br />
                
* If the content type is text/xml (POX) we will create a plain XmlTextReader for the
body.<br />
                
*/<br /></span>                <span style="COLOR: blue">if</span> (contentType.StartsWith(<span style="COLOR: maroon">"text/xml"</span>, <span style="COLOR: teal">StringComparison</span>.OrdinalIgnoreCase))<br />
               
{<br />
                  
// do we only have a UTF byte-order mark?<br />
                   <font color="#0000ff">if</font> (_bufferSize
&lt;= 4)<br />
                
  {<br />
                       <font color="#008000">//
create a new reader over a fake infoset and place it on the EndElement<br />
                       </font>reader
=<font color="#008080"> XmlDictionaryReader</font>.CreateDictionaryReader(<br />
                        
 <font color="#0000ff">new</font><font color="#008080">XmlTextReader</font>(<font color="#0000ff">new</font><font color="#008080">StringReader</font>(<font color="#800000">"&lt;no-data&gt;&lt;/no-data&gt;"</font>)));<br />
                      
reader.Read(); reader.Read();<br />
                  
}<br />
                   <font color="#0000ff">else<br />
                   </font>{<br />
                      
reader = <font color="#008080">XmlDictionaryReader</font>.CreateDictionaryReader(<font color="#0000ff">new</font><font color="#008080">XmlTextReader</font>(GetRawBodyStream()));<br />
                  
}
</span>
                  </p>
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
               
}<br />
            }<br />
            <span style="COLOR: green">/*<br />
             * If the
content wasn't identified to be POX, we'll wrap it as binary.  
<br />
             */<br /></span>            <span style="COLOR: blue">if</span> (reader
== <span style="COLOR: blue">null</span>)<br />
            {<br />
               
reader = <span style="COLOR: teal">XmlDictionaryReader</span>.CreateDictionaryReader(<span style="COLOR: blue">new</span><span style="COLOR: teal">PoxBase64XmlStreamReader</span>(GetRawBodyStream()));<br />
            }<br />
            <span style="COLOR: blue">return</span> reader;<br />
        }
</p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
The private <i>CreateBodyReader()</i> method that constructs XML readers for the both,
the <i>OnGetBodyReaderAtBodyContents()</i> and the <i>OnWriteBodyContents()</i> overrides
shown below, uses the same strategy to figure out the content-type of the message
and therefore to guess what’s hidden inside the byte-array (or array segment) the
message was constructed over. To make the message class useful for the request and
response direction, we’ll distinguish there two separate cases here:
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
            <span style="FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>If
the message is a response, the handling method in the user code might have indicated
that it wants the encoder to serialize the message onto the wire in “raw binary” mode.
The indicator for that is the presence of the <i>PoxEncoderMessageProperty</i> having
the <i>RawBinary </i>property set to <i>true</i>. If that is the case, the reader
we return is always our <i>PoxBase64XmlStreamReader.</i> The property cannot occur
in request messages because the Indigo transports simply don’t know about it.
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
            <span style="FONT-FAMILY: Symbol">·<span style="FONT: 7pt 'Times New Roman'">         </span></span>If
the message is a request or a response with the mentioned property missing, we will
try figuring out the message’s content-type using the described strategy of using
the HTTP transport’s message properties. If we can’t figure out a content-type for
a response (it’s optional for the responding handler code to supply it), we will assume
that the content-type is “text/xml”. If the message is a request we can rely of getting
a content-type as long as the underlying transport is Indigo’s HTTP transport implementation.
If the content-type is indeed “text/xml” we construct an <i>XmlTextReader</i> over
the raw data and return it. If the content-type is anything else, we use our <i>PoxBase64XmlStreamReader</i> wrapper,
because we have to assume that the encapsulated data we’re dealing with is not XML.
</p>
          <p>
The <i>OnGetBodyReaderAtBodyContents()</i> and the <i>OnWriteBodyContents()</i> overrides
are consequently very simple:
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Called
when the client requests a reader for the body contents.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;<br /></span>      <span style="COLOR: blue">protected</span><span style="COLOR: blue">override</span><span style="COLOR: teal">XmlDictionaryReader</span> OnGetReaderAtBodyContents()<br />
      {<br />
         <span style="COLOR: teal">XmlDictionaryReader</span> reader
= CreateBodyReader();<br />
         reader.MoveToContent();<br />
         <span style="COLOR: blue">return</span> reader;<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Called
when the client requests to write the body contents.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="writer"&gt;</span><span style="COLOR: green">The writer.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>      <span style="COLOR: blue">protected</span><span style="COLOR: blue">override</span><span style="COLOR: blue">void</span> OnWriteBodyContents(<span style="COLOR: teal">XmlDictionaryWriter</span> writer)<br />
      {<br />
         <span style="COLOR: teal">XmlDictionaryReader</span> reader
= CreateBodyReader();<br />
         writer.WriteNode(reader, <span style="COLOR: blue">false</span>);<br />
      }</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
What’s left to complete the message implementation are the compulsory overrides of
the abstract properties of <i>Message</i>, for which we have backing fields declared
at the top of the class:
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal" style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the message version.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;value&gt;</span><span style="COLOR: green">The
message version.</span><span style="COLOR: gray">&lt;/value&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: teal">MessageVersion</span> Version<br />
      {<br />
         <span style="COLOR: blue">get<br /></span>         {<br />
            <span style="COLOR: blue">return</span><span style="COLOR: teal">MessageVersion</span>.Soap11Addressing1;<br />
         }<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the SOAP headers.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;value&gt;</span><span style="COLOR: green">The
headers.</span><span style="COLOR: gray">&lt;/value&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: teal">MessageHeaders</span> Headers<br />
      {<br />
         <span style="COLOR: blue">get<br /></span>         {<br />
            <span style="COLOR: blue">return</span> headers;<br />
         }<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the message properties.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;value&gt;</span><span style="COLOR: green">The
properties.</span><span style="COLOR: gray">&lt;/value&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: teal">MessageProperties</span> Properties<br />
      {<br />
         <span style="COLOR: blue">get<br /></span>         {<br />
            <span style="COLOR: blue">return</span> properties;<br />
         }<br />
      }<br />
    }<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
The <i>PoxStreamedMessage</i> is only different from this class insofar as that it
doesn’t have the buffer management. The <i>GetRawBodyStream()</i> method immediately
returns the encapsulated stream and the remaining implementation is largely equivalent,
if not identical (yes, I should consolidate that into a base class). Therefore I am
not pasting that class here as code but rather just append as a downloadable file,
alongside the declaration of <i>IPoxRawBodyMessage</i> and the twice mentioned and
not yet shown <i>PoxEncoderMessageProperty</i> class.
</p>
          <p>
With this, we’ve got all the moving pieces we need to build what’s essentially becoming
an Indigo-based, message-oriented web-server infrastructure with a REST-oriented programming
model. What’s missing is how we get our encoder configured into a binding so that
we can put it all together and run it. 
</p>
          <p>
Configuration is next; wait for part 8.
</p>
        </div>
        <p>
Download: <a href="http://staff.newtelligence.net/clemensv/content/binary/PoxEncoderMessageProperty.zip">PoxEncoderMessageProperty.zip</a><br />
Download: <a href="http://staff.newtelligence.net/clemensv/content/binary/PoxStreamedMessage.zip">PoxStreamedMessage.zip</a><br />
Download: <a href="http://staff.newtelligence.net/clemensv/content/binary/IPoxRawBodyMessage.zip">IPoxRawBodyMessage.zip</a><br /></p>
        <p>
          <em>[2006-01-13: Updated PoxBufferedMessage code to deal with entity bodies that
only consist of a UTF BOM]</em>
        </p>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=e82c8423-f106-4105-81e4-14410a83315a" />
      </body>
      <title>Teaching Indigo to do REST/POX: Part 7</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,e82c8423-f106-4105-81e4-14410a83315a.aspx</guid>
      <link>http://vasters.com/clemensv/2006/01/04/Teaching+Indigo+To+Do+RESTPOX+Part+7.aspx</link>
      <pubDate>Wed, 04 Jan 2006 13:41:38 GMT</pubDate>
      <description>&lt;div class=Section1&gt;
&lt;p&gt;
&lt;span lang=DE&gt;&lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx"&gt;&lt;span lang=EN-US&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx&gt;Part
1&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"&gt;&lt;span lang=EN-US&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx&gt;Part
2&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx"&gt;&lt;span lang=EN-US&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx&gt;Part
3&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx"&gt;&lt;span lang=EN-US&gt;&lt;span title=http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx&gt;Part
4&lt;/span&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;a title=http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx"&gt;Part
5&lt;/a&gt;, &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,51327201-07c7-4a30-b79c-53842cda1e77.aspx"&gt;Part
6&lt;/a&gt;, &lt;strong&gt;Part 7&lt;/strong&gt;, &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,7465c74e-6001-4d08-93ae-ad7110dee188.aspx"&gt;Part
8&lt;/a&gt;, &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,8fc367b2-a4be-4588-8264-5455c268b94a.aspx"&gt;Part
9&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Where are we?
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;In
Parts 1 and 2, I explained contracts in the REST/POX context and the dispatch mechanisms
that we need to enable Indigo to accept and handle REST/POX requests. With that I
introduced a metadata extension, the &lt;i&gt;[HttpMethod]&lt;/i&gt; attribute that can be used
to mark up operations on an Indigo contract with HTTP methods and a URI suffixes that
we can dispatch on. I also showed how we can employ a parameter inspector to extract
URI-embedded arguments and flow them to the operation in a message property.
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;In
Parts 3 and 4, I showed how we use the &lt;i&gt;[HttpMethodOperationSelector]&lt;/i&gt; attribute
to replace Indigo’s default address filtering and operation selection mechanisms,
basically the entire message dispatch mechanism, with our own variants. The &lt;i&gt;SuffixFilter&lt;/i&gt; is
used to find the appropriate endpoint for an incoming request and the &lt;i&gt;HttpMethodOperationSelectorBehavior &lt;/i&gt;&amp;nbsp;find
the operation (method) on that endpoint which shall receive the incoming request message.
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;In
Parts 5 and 6, you saw how the &lt;i&gt;PoxEncoder&lt;/i&gt; puts outbound envelope-less POX documents
onto the wire in its &lt;i&gt;WriteMessage&lt;/i&gt; methods and accepts incoming non-SOAP XML
requests through its &lt;i&gt;ReadMessage &lt;/i&gt;methods and wraps them with an in-memory envelope
(“message”) for further processing. I also showed the &lt;i&gt;PoxBase64XmlStreamReader&lt;/i&gt;,
which is an XML Infoset wrapper for arbitrary binary streams that interacts with the &lt;i&gt;PoxEncoder &lt;/i&gt;to
allow smuggling any sort of raw binary content through the Indigo infrastructure and
onto the wire.
&lt;/p&gt;
&lt;p&gt;
We’re pretty far along already. We’ve got the dispatch mechanisms, we know how to
hook the dispatch metadata into the services, we’ve got the wire-encoding – we have
most of the core pieces together. In fact, the last two key classes we’re missing
(configuration hooks aside) are two specialized message classes that we need to handle
incoming requests. In Part 6, you could see that the two &lt;i&gt;ReadMessage&lt;/i&gt; overloads
of the &lt;i&gt;PoxEncoder&lt;/i&gt; delegate all work to the &lt;i&gt;PoxBufferedMessage&lt;/i&gt; for the
“buffered” transfer-mode overload and to &lt;i&gt;PoxStreamedMessage&lt;/i&gt; for the “streamed”
transfer mode overload.
&lt;/p&gt;
&lt;p&gt;
&lt;i&gt;ReadMessage &lt;/i&gt;is called on an encoder whenever a transport has received a complete
message buffer (buffered mode) or has accepted and opened a network stream (streamed
mode). 
&lt;/p&gt;
&lt;p&gt;
Using streamed mode means very concretely that Indigo will start handling the message
even though the message might not have completely arrived. A transport in streaming
mode will only do as much as it needs to do in order to deal with the transport-level
framing protocol. I use “framing protocol” as a general term for what is done at the
transport level to know what the nature of the payload is and where the payload starts
and ends. For HTTP, the HTTP transport figures out whether an incoming request is
indeed an HTTP request, will read/parse the HTTP headers, and will then layer a stream
over the request’s content, irrespective of whether the transfer of that byte sequence
has already been completed. This stream is immediately handed off to the rest of the
Indigo infrastructure and the transport has done its work by doing so. 
&lt;/p&gt;
&lt;p&gt;
Pulling the remaining bytes from that stream is someone else’s responsibility in streamed
mode. Whenever a piece of the infrastructure pulls data directly or indirectly from
the stream and the data chunk requested is still in transfer, the stream will block
and wait until the data is there. The transport’s handling of the framing protocol
will typically also take care of chunking and thus make a chunked stream appear to
be continuous. When I say “indirect pull” I mean that it may very well be an &lt;i&gt;XmlDictionaryReader&lt;/i&gt; layered
over an &lt;i&gt;XmlReader&lt;/i&gt; layered over the incoming network stream. 
&lt;/p&gt;
&lt;p&gt;
The streaming mode is of particular interest for very large messages that may, in
an extreme case, be virtually limitless in size. There’s no specification that says
that you cannot stick 500 Terabyte or 500 Exabyte worth of data (think 365x24 live
1080i video streams) into a single message. As long as you have some reason to believe
that the sender will eventually, in 20 years from now, give you “&amp;lt;/soap:Body&amp;gt;&amp;lt;/soap:Envelope&amp;gt;”
to terminate the message, the message can be assumed to be well-formed and complete.
&lt;/p&gt;
&lt;p&gt;
No matter whether you use buffered or streamed mode, the configured encoder’s &lt;i&gt;ReadMessage&lt;/i&gt; method
is the first place where the read data chunk or the stream goes and that delegates,
as shown to our two message classes. So let’s look at them.
&lt;/p&gt;
&lt;p&gt;
We’ll primarily look at the &lt;i&gt;PoxBufferedMessage&lt;/i&gt;, which is constructed over the
read message buffer in the &lt;i&gt;PoxEncoder&lt;/i&gt; like this:
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: Courier"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier"&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; ReadMessage(&lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;
buffer, &lt;span style="COLOR: teal"&gt;BufferManager&lt;/span&gt; bufferManager)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxBufferedMessage&lt;/span&gt;(buffer,
bufferManager);&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
The class &lt;i&gt;PoxBufferedMessage&lt;/i&gt; is derived from the abstract &lt;i&gt;System.ServiceModel.Message&lt;/i&gt; class
and implements the base-class’s abstract properties &lt;i&gt;Headers, Properties, &lt;/i&gt;and &lt;i&gt;Version&lt;/i&gt; and
overrides the &lt;i&gt;OnClose(), OnGetReaderAtBodyContents()&lt;/i&gt;, and &lt;i&gt;OnWriteBodyContents()&lt;/i&gt; virtual
methods. Internally, Indigo has several such &lt;i&gt;Message&lt;/i&gt; implementations that are
each customized for certain scenarios. Implementing own variants of &lt;i&gt;Message&lt;/i&gt; is
simply another extensibility mechanism that Indigo gives us. 
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;Using&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt; System;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Text;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.IO;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Xml;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Runtime.CompilerServices;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel.Channels;&lt;br&gt;
&lt;br&gt;
&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; newtelligence.ServiceModelExtensions&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; This
class is one of the message classes used by the &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see
cref="T:PoxEncoder"/&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; It
serves to wrap an unencapsulated data buffer with a message structure.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; The
data buffer becomes the body content of the message.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxBufferedMessage&lt;/span&gt; : &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;IPoxRawBodyMessage&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;MessageHeaders&lt;/span&gt; headers
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MessageHeaders&lt;/span&gt;(&lt;span style="COLOR: teal"&gt;MessageVersion&lt;/span&gt;.Soap11Addressing1);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;MessageProperties&lt;/span&gt; properties
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MessageProperties&lt;/span&gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[] buffer;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; bufferSize;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;BufferManager&lt;/span&gt; bufferManager;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Stream&lt;/span&gt; body;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Initializes
a new instance of the &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see cref="T:PoxBufferedMessage"/&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; class.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="buffer"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The buffer.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; PoxBufferedMessage(&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[]
buffer)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bufferManager = &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; buffer = buffer;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bufferSize = buffer.Length;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Initializes
a new instance of the &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see cref="T:PoxBufferedMessage"/&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; class.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="buffer"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The buffer.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="bufferManager"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The buffer manager.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; PoxBufferedMessage(&lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;
buffer, &lt;span style="COLOR: teal"&gt;BufferManager&lt;/span&gt; bufferManager)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bufferManager =
bufferManager;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bufferSize = buffer.Count;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; buffer = bufferManager.TakeBuffer(
bufferSize);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Array&lt;/span&gt;.Copy(buffer.Array,
buffer.Offset, buffer, 0, bufferSize);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
We can construct instances of the class over a raw byte array or an “array segment”
layered over such an array. Array segments are preferred&amp;nbsp;over raw arrays, because
their use eases memory management. You can keep a pool of buffers with a common size,
even though the actual content is shorter than the buffer size and probably even offset
from the lower buffer boundary. If we get a raw byte array we simply adopt it, but
if we get an array segment alongside a reference to a buffer manager we take a new
buffer from the buffer manager and copy the array segment to that acquired buffer.
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Called
when the message is being closed.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; OnClose()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;.OnClose();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (
bufferManager != &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
bufferManager.ReturnBuffer( buffer);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
When we close the message and we have acquired it using the buffer manager (which
is signaled by the presence of the reference) we duly return it once the message is
being closed (or disposed or finalized). 
&lt;/p&gt;
&lt;p&gt;
The next two methods are an implementation of the &lt;i&gt;IPoxRawBodyMessage&lt;/i&gt; interface
that is, you guessed it, defined in my extensions. If the handler method wants to
get straight at the raw body content knowing that it doesn’t expect XML, it can shortcut
by the whole &lt;i&gt;XmlReader&lt;/i&gt; and XML serialization story by asking for the &lt;i&gt;BodyContentType&lt;/i&gt; and
pull out the raw body data as a stream layered over the buffer: 
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the raw body stream.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;[&lt;span style="COLOR: teal"&gt;MethodImpl&lt;/span&gt;(&lt;span style="COLOR: teal"&gt;MethodImplOptions&lt;/span&gt;.Synchronized)]&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Stream&lt;/span&gt; GetRawBodyStream()&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (
body == &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; body = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MemoryStream&lt;/span&gt;(
buffer,0, bufferSize,&lt;span style="COLOR: blue"&gt;false&lt;/span&gt;,&lt;span style="COLOR: blue"&gt;true&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; body;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the content type of the raw message body based on the Content-Type HTTP header 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; contained
in the HttpRequestMessageProperty or HttpResponseMessageProperty of this&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; message.
The value is null if the type is unknown.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; BodyContentType&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;get&lt;/span&gt; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (Properties.ContainsKey(&lt;span style="COLOR: teal"&gt;HttpRequestMessageProperty&lt;/span&gt;.Name))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; ((&lt;span style="COLOR: teal"&gt;HttpRequestMessageProperty&lt;/span&gt;)Properties[&lt;span style="COLOR: teal"&gt;HttpRequestMessageProperty&lt;/span&gt;.Name]).Headers[&lt;span style="COLOR: maroon"&gt;"Content-Type"&lt;/span&gt;];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (Properties.ContainsKey(&lt;span style="COLOR: teal"&gt;HttpResponseMessageProperty&lt;/span&gt;.Name))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; ((&lt;span style="COLOR: teal"&gt;HttpResponseMessageProperty&lt;/span&gt;)Properties[&lt;span style="COLOR: teal"&gt;HttpResponseMessageProperty&lt;/span&gt;.Name]).Headers[&lt;span style="COLOR: maroon"&gt;"Content-Type"&lt;/span&gt;];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
There is a bit of caution required using this mechanism, though. Because the message &lt;i&gt;State&lt;/i&gt; (Created,
Written, Read, Copied, Closed) is controlled by the base-class and cannot be set by
derived classes, the message should be considered to be in the &lt;i&gt;State==MessageState.Read&lt;/i&gt; after
calling the &lt;i&gt;GetRawBodyStream()&lt;/i&gt; method. That doesn’t seem to be necessary because
we have a buffer here, but for the streamed variant that’s a must. And for the sake
of consistency we introduce this constraint here. 
&lt;/p&gt;
&lt;p&gt;
The &lt;i&gt;BodyContentType&lt;/i&gt; property implementation seems, admittedly, a bit strange
at first sight. Even though you won’t see the message properties being populated anywhere
inside this class, we’re asking for them and base the content-type detection on their
values. That only makes sense when we consider the way messages are being populated
by Indigo. As I explained, the first thing that gets called once the transport has
a raw data chunk or stream in its hands that it believes to be a message, it invokes
the encoder. For incoming requests/messages, the encoder is really serving as the
message factory constructing &lt;i&gt;Message&lt;/i&gt;-derived instances over raw data. Once
the encoder has constructed the message in one of the &lt;i&gt;ReadMessage&lt;/i&gt; overloads,
the message is returned to the transport. If the transport wants, it can then (and
the HTTP transport does) stick properties into that newly created message and then
hand it off to the rest of the channel infrastructure for processing and dispatching.
Because these extensions are built for REST/POX and therefore have HTTP affinity,
that’s precisely what we assume to be happening for the &lt;i&gt;BodyContentType&lt;/i&gt; property
and the &lt;i&gt;CreateBodyReader() &lt;/i&gt;method below. As I already explained in Part 1,
the HTTP transport will always add a &lt;i&gt;HttpRequestMessageProperty&lt;/i&gt; &amp;nbsp;to the
message and that’s consequently from which we can grab the content-type of the incoming
request data.
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: teal"&gt;XmlDictionaryReader&lt;/span&gt; CreateBodyReader()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;XmlDictionaryReader&lt;/span&gt; reader
= &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;/* 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * Check whether
the message properties indicate that this is a raw binary message.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * In that
case, we'll wrap the body with a PoxBase64XmlStreamReader 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; hasPoxEncoderProperty
= Properties.ContainsKey(&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;.Name);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (!(hasPoxEncoderProperty
&amp;amp;&amp;amp; ((&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;)Properties[&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;.Name]).RawBinary))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; contentType
= &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;/*&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
* Check for whether either the HttpRequestMessageProperty or the HttpResponseMessageProperty 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
* are present. If so, extract the HTTP Content-Type header. Otherwise the content-type
is 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
* assumed to be text/xml ("POX")&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;*/&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; hasRequestProperty
= Properties.ContainsKey(&lt;span style="COLOR: teal"&gt;HttpRequestMessageProperty&lt;/span&gt;.Name);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; hasResponseProperty
= Properties.ContainsKey(&lt;span style="COLOR: teal"&gt;HttpResponseMessageProperty&lt;/span&gt;.Name);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (hasResponseProperty)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;HttpResponseMessageProperty&lt;/span&gt; responseProperty
= 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Properties[&lt;span style="COLOR: teal"&gt;HttpResponseMessageProperty&lt;/span&gt;.Name] &lt;span style="COLOR: blue"&gt;as&lt;/span&gt; &lt;span style="COLOR: teal"&gt;HttpResponseMessageProperty&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
contentType = responseProperty.Headers[&lt;span style="COLOR: maroon"&gt;"Content-Type"&lt;/span&gt;];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;/span&gt; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (hasRequestProperty)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;HttpRequestMessageProperty&lt;/span&gt; requestProperty
= 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
Properties[&lt;span style="COLOR: teal"&gt;HttpRequestMessageProperty&lt;/span&gt;.Name] &lt;span style="COLOR: blue"&gt;as&lt;/span&gt; &lt;span style="COLOR: teal"&gt;HttpRequestMessageProperty&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
contentType = requestProperty.Headers[&lt;span style="COLOR: maroon"&gt;"Content-Type"&lt;/span&gt;];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (contentType
== &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
contentType = &lt;span style="COLOR: maroon"&gt;"text/xml"&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;/*&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
* If the content type is text/xml (POX) we will create a plain XmlTextReader for the
body.&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
*/&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (contentType.StartsWith(&lt;span style="COLOR: maroon"&gt;"text/xml"&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;StringComparison&lt;/span&gt;.OrdinalIgnoreCase))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
// do we only have a UTF byte-order mark?&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#0000ff&gt;if&lt;/font&gt; (_bufferSize
&amp;lt;= 4)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#008000&gt;//
create a new reader over a fake infoset and place it on the EndElement&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;reader
=&lt;font color=#008080&gt;&amp;nbsp;XmlDictionaryReader&lt;/font&gt;.CreateDictionaryReader(&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&lt;font color=#0000ff&gt;new&lt;/font&gt; &lt;font color=#008080&gt;XmlTextReader&lt;/font&gt;(&lt;font color=#0000ff&gt;new&lt;/font&gt; &lt;font color=#008080&gt;StringReader&lt;/font&gt;(&lt;font color=#800000&gt;"&amp;lt;no-data&amp;gt;&amp;lt;/no-data&amp;gt;"&lt;/font&gt;)));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
reader.Read(); reader.Read();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color=#0000ff&gt;else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
reader = &lt;font color=#008080&gt;XmlDictionaryReader&lt;/font&gt;.CreateDictionaryReader(&lt;font color=#0000ff&gt;new&lt;/font&gt; &lt;font color=#008080&gt;XmlTextReader&lt;/font&gt;(GetRawBodyStream()));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;/*&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * If the
content wasn't identified to be POX, we'll wrap it as binary.&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (reader
== &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
reader = &lt;span style="COLOR: teal"&gt;XmlDictionaryReader&lt;/span&gt;.CreateDictionaryReader(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxBase64XmlStreamReader&lt;/span&gt;(GetRawBodyStream()));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; reader;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&gt;
&lt;/p&gt;
&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
The private &lt;i&gt;CreateBodyReader()&lt;/i&gt; method that constructs XML readers for the both,
the &lt;i&gt;OnGetBodyReaderAtBodyContents()&lt;/i&gt; and the &lt;i&gt;OnWriteBodyContents()&lt;/i&gt; overrides
shown below, uses the same strategy to figure out the content-type of the message
and therefore to guess what’s hidden inside the byte-array (or array segment) the
message was constructed over. To make the message class useful for the request and
response direction, we’ll distinguish there two separate cases here:
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;If
the message is a response, the handling method in the user code might have indicated
that it wants the encoder to serialize the message onto the wire in “raw binary” mode.
The indicator for that is the presence of the &lt;i&gt;PoxEncoderMessageProperty&lt;/i&gt; having
the &lt;i&gt;RawBinary &lt;/i&gt;property set to &lt;i&gt;true&lt;/i&gt;. If that is the case, the reader
we return is always our &lt;i&gt;PoxBase64XmlStreamReader.&lt;/i&gt; The property cannot occur
in request messages because the Indigo transports simply don’t know about it.
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-FAMILY: Symbol"&gt;·&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/span&gt;If
the message is a request or a response with the mentioned property missing, we will
try figuring out the message’s content-type using the described strategy of using
the HTTP transport’s message properties. If we can’t figure out a content-type for
a response (it’s optional for the responding handler code to supply it), we will assume
that the content-type is “text/xml”. If the message is a request we can rely of getting
a content-type as long as the underlying transport is Indigo’s HTTP transport implementation.
If the content-type is indeed “text/xml” we construct an &lt;i&gt;XmlTextReader&lt;/i&gt; over
the raw data and return it. If the content-type is anything else, we use our &lt;i&gt;PoxBase64XmlStreamReader&lt;/i&gt; wrapper,
because we have to assume that the encapsulated data we’re dealing with is not XML.
&lt;/p&gt;
&lt;p&gt;
The &lt;i&gt;OnGetBodyReaderAtBodyContents()&lt;/i&gt; and the &lt;i&gt;OnWriteBodyContents()&lt;/i&gt; overrides
are consequently very simple:
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Called
when the client requests a reader for the body contents.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;XmlDictionaryReader&lt;/span&gt; OnGetReaderAtBodyContents()&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;XmlDictionaryReader&lt;/span&gt; reader
= CreateBodyReader();&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;reader.MoveToContent();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; reader;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Called
when the client requests to write the body contents.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="writer"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The writer.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; OnWriteBodyContents(&lt;span style="COLOR: teal"&gt;XmlDictionaryWriter&lt;/span&gt; writer)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;XmlDictionaryReader&lt;/span&gt; reader
= CreateBodyReader();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;writer.WriteNode(reader, &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
What’s left to complete the message implementation are the compulsory overrides of
the abstract properties of &lt;i&gt;Message&lt;/i&gt;, for which we have backing fields declared
at the top of the class:
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the message version.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The
message version.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/value&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MessageVersion&lt;/span&gt; Version&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MessageVersion&lt;/span&gt;.Soap11Addressing1;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the SOAP headers.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The
headers.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/value&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MessageHeaders&lt;/span&gt; Headers&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; headers;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the message properties.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The
properties.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/value&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MessageProperties&lt;/span&gt; Properties&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; properties;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
The &lt;i&gt;PoxStreamedMessage&lt;/i&gt; is only different from this class insofar as that it
doesn’t have the buffer management. The &lt;i&gt;GetRawBodyStream()&lt;/i&gt; method immediately
returns the encapsulated stream and the remaining implementation is largely equivalent,
if not identical (yes, I should consolidate that into a base class). Therefore I am
not pasting that class here as code but rather just append as a downloadable file,
alongside the declaration of &lt;i&gt;IPoxRawBodyMessage&lt;/i&gt; and the twice mentioned and
not yet shown &lt;i&gt;PoxEncoderMessageProperty&lt;/i&gt; class.
&lt;/p&gt;
&lt;p&gt;
With this, we’ve got all the moving pieces we need to build what’s essentially becoming
an Indigo-based, message-oriented web-server infrastructure with a REST-oriented programming
model. What’s missing is how we get our encoder configured into a binding so that
we can put it all together and run it. 
&lt;/p&gt;
&lt;p&gt;
Configuration is next; wait for part 8.
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
Download: &lt;a href="http://staff.newtelligence.net/clemensv/content/binary/PoxEncoderMessageProperty.zip"&gt;PoxEncoderMessageProperty.zip&lt;/a&gt;
&lt;br&gt;
Download: &lt;a href="http://staff.newtelligence.net/clemensv/content/binary/PoxStreamedMessage.zip"&gt;PoxStreamedMessage.zip&lt;/a&gt;
&lt;br&gt;
Download: &lt;a href="http://staff.newtelligence.net/clemensv/content/binary/IPoxRawBodyMessage.zip"&gt;IPoxRawBodyMessage.zip&lt;/a&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;[2006-01-13: Updated PoxBufferedMessage&amp;nbsp;code to deal with entity bodies that
only consist of a UTF BOM]&lt;/em&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=e82c8423-f106-4105-81e4-14410a83315a" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,e82c8423-f106-4105-81e4-14410a83315a.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=51327201-07c7-4a30-b79c-53842cda1e77</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,51327201-07c7-4a30-b79c-53842cda1e77.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,51327201-07c7-4a30-b79c-53842cda1e77.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=51327201-07c7-4a30-b79c-53842cda1e77</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <div class="Section1">
          <p>
            <span lang="DE">
              <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx">
                <span lang="EN-US">Part
1</span>
              </a>
            </span>, <span lang="DE"><a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"><span lang="EN-US">Part
2</span></a></span>, <span lang="DE"><a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx"><span lang="EN-US">Part
3</span></a></span>, <span lang="DE"><a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx"><span lang="EN-US">Part
4</span></a></span>, <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx">Part
5</a></p>
          <p>
I threw a lot of unexplained code at you in Part 5 and that wasn’t really fair. 
</p>
          <p>
The <i>PoxEncoder </i>class is a replacement for Indigo’s default <i>TextMessageEncoder </i>class
that’s used by the HTTP transport unless you explicitly configure something different.
Indigo comes with three built-in encoders, namely:
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
            <span style="FONT-FAMILY: Symbol">·</span>
            <span style="FONT-SIZE: 7pt">         </span>The <i>TextMessageEncoder</i> serializes
Indigo’s internal <i>Message </i>into SOAP 1.1 or SOAP 1.2 envelopes using (applies
only to the latter) the desired character encodings (UTF-8, UTF-16, etc.) and of course
it also deserializes incoming SOAP envelopes into the Indigo representation.
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
            <span style="FONT-FAMILY: Symbol">·</span>
            <span style="FONT-SIZE: 7pt">         </span>The <i>MtomMessageEncoder</i> serializes
messages into SOAP 1.2 messages as specified by the <i><a href="http://www.w3.org/TR/2005/REC-soap12-mtom-20050125/">MTOM</a></i> specification,
which allows for a much more compact transmission of binary-heavy SOAP envelopes than
if you were simply using base64Binary encoded element data. MTOM is a good choice
whenever the size of binary content in a SOAP envelope far exceeds the size of the
rest of the data. Your mileage may vary, so that’s a thing to measure carefully unless
it’s blatantly obvious such as in the case of writing a service for a digital imaging
library.
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
            <span style="FONT-FAMILY: Symbol">·</span>
            <span style="FONT-SIZE: 7pt">         </span>The <i>BinaryMessageEncoder</i> serializes
messages into SOAP 1.2 envelopes, but does so in a very compact binary format that
preserves the XML information set, but is not at all like XML text. The gist of the
binary encoding is the assumption that if both communicating parties are implemented
with Indigo and share the same contract, the metadata existing at both ends reduces
the hints that need to go on the wire. In other words: The binary encoding doesn’t
need to throw all  these lengthy XML tag names and namespace names explicitly
onto the wire, but can refer to them by pointing to a dictionary that’s identically
constructed on both ends. The binary encoding in Indigo is a bit like the modern-day,
loosely coupled grand-child of <a href="http://www.opengroup.org/onlinepubs/9629399/chap14.htm">NDR</a> and
“<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/midl/midl/ oi.asp">midl.exe
/Oicf</a>” if you like. What’s important to note about this encoding is that its primary
design goal is performance and interoperability is in fact a non-goal. The <i>BinaryMessageEncoder</i> assumes
Indigo endpoints. If you don’t like that, you can always use the text encoding, which
is designed for interoperability.
</p>
          <p>
Our <i>PoxEncoder</i> here differs from all three Indigo encoders in that it does
specifically <b>not</b> serialize SOAP messages, but rather just the body contents
of a <i>Message.</i></p>
          <p>
In order for you to understand what’s happening here, I’ll pick the most relevant
methods and explain them in detail. We will start with the <i>Initialize() </i>method
that is invoked by all three constructor overloads:
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">///</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier">
                    </span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">&lt;summary&gt;<br />
///</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"> Initializes
common properties of the encoder.<br /></span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">///</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier">
                    </span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">&lt;/summary&gt;<br /></span>
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">private</span>
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">
                      <span style="COLOR: blue">void</span> Initialize()<br />
{<br />
  <span style="COLOR: blue">if</span> (<span style="COLOR: blue">this</span>.MessageVersion.Envelope
== <span style="COLOR: teal">EnvelopeVersion</span>.Soap12)<br />
  {<br />
    <span style="COLOR: green">// set the aprorpiate media type for
SOAP 1.2<br /></span>     <span style="COLOR: blue">this</span>. mediaType = <span style="COLOR: maroon">"application/soap+xml"</span>;<br />
  }<br />
  <span style="COLOR: blue">else</span><span style="COLOR: blue">if</span> (<span style="COLOR: blue">this</span>.MessageVersion.Envelope
== <span style="COLOR: teal">EnvelopeVersion</span>.Soap11)<br />
  {<br />
    <span style="COLOR: green">// set the appropriate media type for
SOAP 1.1<br /></span>     <span style="COLOR: blue">this</span>. mediaType = <span style="COLOR: maroon">"text/xml"</span>;<br />
  }<br />
  <span style="COLOR: green">// compose the content type from charset and media
type<br /></span>  <span style="COLOR: blue">this</span>. contentType = <span style="COLOR: blue">string</span>.Format(<span style="COLOR: teal">CultureInfo</span>.InvariantCulture, <span style="COLOR: maroon">"{0};
charset={1}"</span>, mediaType, textEncoding.WebName);<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
It is required for each <i>MessageEncoder-</i>derived class to implement the abstract
properties <i>MediaType</i>, <i>ContentType</i>, and <i>MessageVersion</i>, and therefore
we have to initialize the backing fields for these properties properly and return
meaningful values even though the <i>PoxEncoder </i>is exactly the “anti-SOAP” encoder.
The message version specified in the encoder is relevant for Indigo higher up on the
stack, because it needs to know what rules and constraints apply to <i>Message</i> instances
as they are constructed and processed. The content type and media types are required
by the transports so that they know what content and/or media type to specify as metadata
in their transport frame (eg. the <i>Content-Type</i> header in HTTP). If we initialize
the encoder with the Soap12 message version, it will consequently report the <i>application/soap+xml</i> media
type, even though the encoder doesn’t ever write such envelopes to the wire. You might
consider that a bug in the <i>PoxEncoder</i> and you might be right, but it doesn’t
really matter. Because any methods can return all sorts of payloads, we will override
the content-type on the message-level so that this information has really no effect.
I do need to clean this up a little. Later.
</p>
          <p>
Now let’s look at the parts that actually do the work. I will start with the two <i>WriteMessage</i> overloads.
</p>
          <p>
The first overload’s signature is<br />
     <i>public override ArraySegment&lt;byte&gt; WriteMessage(Message
msg, int maxMessageSize, BufferManager bufferManager, int messageOffset)<br /></i>and is invoked by the transport whenever a message must be wire-encoded and the
output transfer mode is set to <i>TransferMode.Buffered</i> or <i>TransferMode.StreamedRequest </i>(which
implies a buffered response). The second overload’s signature is<br />
    <i>public override void WriteMessage(Message msg, System.IO.Stream
stream)<br /></i>and is invoked by the transport whenever a message must be wire-encoded and the
output transfer mode is set of <i>TransferMode.Streamed</i> or <i>TransferMode.StreamedResponse</i> (which
implies a streamed response). 
</p>
          <p>
The transfer-mode property is configurable on all of the pre-built HTTP bindings and
on the <i>&lt;httpTransport&gt;</i> binding element. “Buffered” encoding means that
the entire message is encoded at once and written into a buffer, which is then given
to the the transport for sending. “Streamed” encoding means that the message is pushed
into to a stream, whereby the stream is typically immediately layered directly over
the transport. That means that whenever our encoder writes data to that stream, it
is immediately pushed to the remote communication partner. The “streamed” mode is
the optimal choice for sending very large messages that are, for instance, too big
to be reasonably handled as a single memory block. The buffered mode is better (and
faster) for compact messages. I’ll dissect the buffered variant first:
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">public</span>
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">
                      <span style="COLOR: blue">override</span>
                      <span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;
WriteMessage(<span style="COLOR: teal">Message</span> msg, <span style="COLOR: blue">int</span> maxMessageSize, <span style="COLOR: teal">BufferManager</span> bufferManager, <span style="COLOR: blue">int</span> messageOffset)<br />
{<br />
   <span style="COLOR: blue">if</span> (msg.IsEmpty)<br />
   {<br />
      <span style="COLOR: green">// if the message is empty
(no body defined) the result is an empty 
<br /></span>      <span style="COLOR: green">// byte array.<br /></span>      <span style="COLOR: blue">byte</span>[]
buffer = bufferManager.TakeBuffer(maxMessageSize);<br />
      <span style="COLOR: blue">return</span><span style="COLOR: blue">new</span><span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;(buffer,
0, 0);<br />
   } </span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
If the message is empty (that means: the body is empty), we request a buffer from
the buffer manager and return an empty slice of that buffer, because this encoder’s
output is “nothing” if the body is empty.The <i>BufferManager</i> is an Indigo helper
class that manages a pool of pre-allocated buffers and serves to optimize memory management
by avoiding the allocation and the discarding of buffers for every message. And encoder
should therefore use the buffer manager argument and use it to obtain the buffers
backing the array segment that is to be returned. Once the message has been handled
by the transport, the transport will return the buffer into the pool. 
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">   <span style="COLOR: blue">else<br /></span>   {<br />
      <span style="COLOR: green">// check RawBinary
bit in the message property<br /></span>          <span style="COLOR: blue">bool</span> rawBinary
= <span style="COLOR: blue">false</span>;<br />
          <span style="COLOR: blue">if</span> (msg.Properties.ContainsKey(<span style="COLOR: teal">PoxEncoderMessageProperty</span>.Name))<br />
      {<br />
         rawBinary = ((<span style="COLOR: teal">PoxEncoderMessageProperty</span>)msg.Properties[<span style="COLOR: teal">PoxEncoderMessageProperty</span>.Name]).RawBinary;<br />
      }</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
If the message is not empty (we have a body), we check whether there is a <i>PoxEncoderMessageProperty</i> present
in the message. This property is a plain CLR class that is part of my extensions and
has two significant properties: <i>Name</i> is a static, constant string value used
as the key for the message properties collection and <i>RawBinary</i> is a Boolean
instance value that contains and indicator for whether the encoder shall encode the
data as XML or as raw binary data. The <i>Message</i> property collection is a simple
dictionary of objects keyed by strings. The properties allow application-level code
to interact with infrastructure-level code in the way illustrated by this property.
Whenever I want the encoder to use its “raw binary” mode, I add this property to the
message and the encoder can pick up the information. 
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">      <span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;
retval = <span style="COLOR: blue">new</span><span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;();<br />
      <span style="COLOR: blue">byte</span>[] buffer
= bufferManager.TakeBuffer(maxMessageSize);<br />
      <span style="COLOR: blue">if</span> (!rawBinary)<br />
      {<br />
         <span style="COLOR: green">// If
we're rendering XML data, we construct a memory stream<br /></span>         <span style="COLOR: green">//
over the output buffer, layer an XMLDictionaryWriter on top of it<br /></span>         <span style="COLOR: green">//
and have the message write the body content into the buffer as XML.<br /></span>         <span style="COLOR: green">//
The buffer is then wrapped into an array segment and returned.<br /></span>         <span style="COLOR: teal">MemoryStream</span> stream
= <span style="COLOR: blue">new</span><span style="COLOR: teal">MemoryStream</span>(buffer);<br />
         <span style="COLOR: teal">XmlWriterSettings</span> settings
= <span style="COLOR: blue">new</span><span style="COLOR: teal">XmlWriterSettings</span>();<br />
         settings.OmitXmlDeclaration
= <span style="COLOR: blue">true</span>;<br />
         settings.Indent = <span style="COLOR: blue">true</span>;<br />
         settings.Encoding = <span style="COLOR: blue">this</span>.
textEncoding;<br />
         <span style="COLOR: teal">XmlWriter</span> innerWriter
= <span style="COLOR: teal">XmlWriter</span>.Create(stream, settings);<br />
         <span style="COLOR: teal">XmlDictionaryWriter</span> writer
= <span style="COLOR: teal">XmlDictionaryWriter</span>.CreateDictionaryWriter(innerWriter, <span style="COLOR: blue">false</span>);<br />
         msg.WriteBodyContents(writer);<br />
         writer.Flush();<br />
         retval = <span style="COLOR: blue">new</span><span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;(buffer,
0, (<span style="COLOR: blue">int</span>)stream.Position);<br />
      }</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
Next we take a buffer from the buffer manager and if we’re not in “raw binary” mode,
we’ll construct a memory stream over the buffer, construct an XmlDictionaryWriter
over that stream and ask the message to render its “body contents” into the writer
and therefore into the memory stream and into the buffer. The “body contents” of a
message is what would be the child nodes of the &lt;soap:Body&gt; element, if we were
using that (but we don’t). Once the body contents have been written, we flush the
writer to make sure that all buffered data is committed into the underlying stream
and then construct the return value as an array segment over the buffer with the length
of the bytes written to the stream. 
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">      <span style="COLOR: blue">else<br /></span>      {<br />
         <span style="COLOR: green">// If
we're rendering raw binary data, we grab at most 'buffer.Length'<br /></span>         <span style="COLOR: green">//
bytes from the binary content of the base64Binary element (if that 
<br /></span>         <span style="COLOR: green">//
exists) and return the result wrapped into an array segment.<br /></span>         <span style="COLOR: teal">XmlDictionaryReader</span> dictReader
= msg.GetReaderAtBodyContents();<br />
         <span style="COLOR: blue">if</span> (dictReader.NodeType
== <span style="COLOR: teal">XmlNodeType</span>.Element &amp;&amp; 
<br />
            dictReader.LocalName
== <span style="COLOR: maroon">"base64Binary"</span>)<br />
         {<br />
            <span style="COLOR: blue">if</span> (dictReader.Read()
&amp;&amp; dictReader.NodeType == <span style="COLOR: teal">XmlNodeType</span>.Text)<br />
            {<br />
               <span style="COLOR: blue">int</span> size
= dictReader.ReadContentAsBase64(buffer, 0, buffer.Length);<br />
               retval
= <span style="COLOR: blue">new</span><span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;(buffer,
0, size);<br />
            }<br />
         }<br />
      }<br />
      <span style="COLOR: blue">return</span> retval;<br />
   }<br />
}<br />
 </span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
If the “raw binary” mode is to be used, we are making a bit of an assumption inside
the encoder. The assumption is that the body content consists of a single element
named “base64Binary” and that its content is just that: base64 binary encoded content.
That is of course the other side of the <i>PoxBase64XmlStreamReader </i>trick I explained
in <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx">Part
5</a>. For binary data we simply assume here that the body reader is our wrapper class
and this is how arbitrary binary data is smuggled through the Indigo infrastructure.
The array segment to be returned is constructed by reading the binary data into the
buffer and setting the array segment length to the number of bytes we could get from
the element content.
</p>
          <p>
The streamed version of <i>WriteMessage</i> is quite different:
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">public</span>
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">
                      <span style="COLOR: blue">override</span>
                      <span style="COLOR: blue">void</span> WriteMessage(<span style="COLOR: teal">Message</span> msg,
System.IO.<span style="COLOR: teal">Stream</span> stream)<br />
{<br />
    <span style="COLOR: blue">try<br /></span>    {<br />
        <span style="COLOR: blue">if</span> (!msg.IsEmpty)<br />
        {<br />
            <span style="COLOR: green">//
check RawBinary bit in the message property<br /></span>            <span style="COLOR: blue">bool</span> rawBinary
= <span style="COLOR: blue">false</span>;<br />
            <span style="COLOR: blue">if</span> (msg.Properties.ContainsKey(<span style="COLOR: teal">PoxEncoderMessageProperty</span>.Name))<br />
            {<br />
               
rawBinary = ((<span style="COLOR: teal">PoxEncoderMessageProperty</span>)msg.Properties[<span style="COLOR: teal">PoxEncoderMessageProperty</span>.Name]).RawBinary;<br />
            }<br />
            <span style="COLOR: blue">if</span> (!rawBinary)<br />
            {<br />
                <span style="COLOR: green">//
If we're rendering XML, we layer an XMLDictionaryWriter over the 
<br /></span>                <span style="COLOR: green">//
output stream and have the message render its body content into<br /></span>                <span style="COLOR: green">//
that writer and therefore onto the stream.<br /></span>                <span style="COLOR: teal">XmlWriterSettings</span> settings
= <span style="COLOR: blue">new</span><span style="COLOR: teal">XmlWriterSettings</span>();<br />
                settings.OmitXmlDeclaration
= <span style="COLOR: blue">true</span>;<br />
               
settings.Indent = <span style="COLOR: blue">true</span>;<br />
               
settings.Encoding = <span style="COLOR: blue">this</span>. textEncoding;<br />
                <span style="COLOR: teal">XmlWriter</span> innerWriter
= <span style="COLOR: teal">XmlWriter</span>.Create(stream, settings);<br />
                <span style="COLOR: teal">XmlDictionaryWriter</span> writer
= <span style="COLOR: teal">XmlDictionaryWriter</span>.CreateDictionaryWriter(innerWriter, <span style="COLOR: blue">false</span>);<br />
               
msg.WriteBodyContents(writer);<br />
               
writer.Flush();<br />
            }</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
The first significant difference is that if we’re using streams, we will simply ignore
empty messages and do nothing with them. In streaming mode, the transport will do
any setup work required for  sending a message before invoking the encoder and
ready the output network stream so that the encoder can write to it. When the encoder
returns, the transport considers the write action done. So if we don’t write to the
output stream, there’s no payload data hitting the wire and that happens to be what
we want.
</p>
          <p>
If we have data and we’re not in “raw binary” mode, the encoder will construct an <i>XmlDictionaryWriter</i> over
the supplied stream and have the message write its body contents to it. That’s all.
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">            <span style="COLOR: blue">Else<br /></span>            {<br />
                <span style="COLOR: green">//
If we're rendering raw binary data, we grab chunks of at most 1MByte<br /></span>                <span style="COLOR: green">//
from the 'base64Binary' content element (if that exists) and write them<br /></span>                <span style="COLOR: green">//
out as binary data to the output stream. Chunking is done, because we<br /></span>                <span style="COLOR: green">//
have to assume that the body content is arbitrarily large. To optimize the 
<br /></span>                <span style="COLOR: green">//
behavior for large streams, we read and write concurrently and swap buffers.<br /></span>                <span style="COLOR: teal">XmlDictionaryReader</span> dictReader
= msg.GetReaderAtBodyContents();<br />
                <span style="COLOR: blue">if</span> (dictReader.NodeType
== <span style="COLOR: teal">XmlNodeType</span>.Element &amp;&amp; dictReader.LocalName
== <span style="COLOR: maroon">"base64Binary"</span>)<br />
               
{<br />
                    <span style="COLOR: blue">if</span> (dictReader.Read()
&amp;&amp; dictReader.NodeType == <span style="COLOR: teal">XmlNodeType</span>.Text)<br />
                   
{<br />
                        <span style="COLOR: blue">byte</span>[]
buffer1 = <span style="COLOR: blue">new</span><span style="COLOR: blue">byte</span>[1024*1024],
buffer2 = <span style="COLOR: blue">new</span><span style="COLOR: blue">byte</span>[1024*1024];<br />
                      
 <span style="COLOR: blue">byte</span>[] readBuffer = buffer1, writeBuffer =
buffer2;<br />
                        
<br />
                        <span style="COLOR: blue">int</span> bytesRead
= 0;<br />
                        <span style="COLOR: green">//
read the first chunk into the read buffer<br /></span>                       
bytesRead = dictReader.ReadContentAsBase64(readBuffer, 0, readBuffer.Length);<br />
                        <span style="COLOR: blue">do<br /></span>                       
{<br />
                            <span style="COLOR: green">//
the abort condition for the loop is that we can't read<br /></span>                
           <span style="COLOR: green">//
any more bytes from the input because the base64Binary element is<br /></span>                            <span style="COLOR: green">//
exhausted.<br /></span>                            <span style="COLOR: blue">if</span> (bytesRead
&gt; 0 )<br />
                           
{<br />
                                <span style="COLOR: green">//
make the last read buffer the write buffer<br /></span>                               
writeBuffer = readBuffer;<br />
                                <span style="COLOR: green">//
write the write buffer to the output stream asynchronously<br /></span>                                <span style="COLOR: teal">IAsyncResult</span> result
= stream.BeginWrite(writeBuffer, 0, bytesRead,<span style="COLOR: blue">null</span>,<span style="COLOR: blue">null</span>);<br />
                                <span style="COLOR: green">//
swap the read buffer<br /></span>                               
readBuffer = (readBuffer == buffer1) ? buffer2 : buffer1;<br />
                                <span style="COLOR: green">//
read a new chunk into the 'other' buffer synchronously<br /></span>                               
bytesRead = dictReader.ReadContentAsBase64(readBuffer, 0, readBuffer.Length);<br />
                                <span style="COLOR: green">//
wait for the write operation to complete<br /></span>                               
result.AsyncWaitHandle.WaitOne();<br />
                               
stream.EndWrite(result);<br />
                           
}<br />
                        }<br />
                        <span style="COLOR: blue">while</span> (bytesRead
&gt; 0);<br />
                   
}<br />
               
}<br />
            }<br />
        }<br />
    }<br />
    <span style="COLOR: blue">catch<br /></span>    {<br />
        <span style="COLOR: green">// the client
may disconnect at any time, so that's an expected exception and absorbed.<br /></span>    }<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
In streamed “raw binary” mode things get a bit more complicated. Under these circumstances
we assume that the output we are sending is HUGE. The use-case I had in mind when
I wrote this is the download of multi-GByte video recordings. Therefore I construct
two 1MByte buffers that are used in turns to read a chunk of data from the source
body reader (for which we make the same content assumption as for the buffered case:
This is believed to be a <i>PoxBase64XmlStreamReader</i> compatible infoset) and asynchronously
push the read data into the output stream.
</p>
          <p>
Because it may take a while to get a huge data stream to the other side, a lot of
things can happen to the network connection during that time. Therefore the encoder
fully expects that the network connection terminates unexpectedly. If that happens,
we’ll catch and absorb the network exception and happily return to the caller as if
we’re done.
</p>
          <p>
Compared to all the complexity of the <i>WriteMessage </i> overloads, the respective <i>ReadMessage</i> methods
look fairly innocent, simple, and similar:
</p>
          <table class="MsoNormalTable" style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="0">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p style="MARGIN-BOTTOM: 12pt">
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">///</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier">
                    </span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">&lt;summary&gt;<br />
///</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"> Reads
an incoming array segment containing a message and<br /></span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">///</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"> wraps
it with a buffered message. The assumption is that the incoming 
<br /></span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">///</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"> data
stream is </span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">&lt;i&gt;</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier">not</span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">&lt;/i&gt;</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"> a
SOAP envelope, but rather an unencapsulated<br /></span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">///</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"> data
item, may it be some raw binary, an XML document or HTML form<br /></span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">///</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"> postback
data. This method is called if the inbound transfer mode of the 
<br /></span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">///</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"> transport
is "buffered".<br /></span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">///</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier">
                    </span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">&lt;/summary&gt;<br />
///</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier">
                    </span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">&lt;param
name="buffer"&gt;</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier">Buffer
to wrap</span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">&lt;/param&gt;<br />
///</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier">
                    </span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">&lt;param
name="bufferManager"&gt;</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier">Buffer
manager to help with allocating a copy</span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">&lt;/param&gt;<br />
///</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier">
                    </span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">&lt;returns&gt;</span>
                    <span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier">Buffered
message</span>
                    <span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier">&lt;/returns&gt;<br /></span>
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">public</span>
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">
                      <span style="COLOR: blue">override</span>
                      <span style="COLOR: teal">Message</span> ReadMessage(<span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;
buffer, <span style="COLOR: teal">BufferManager</span> bufferManager)<br />
{<br />
   <span style="COLOR: blue">return</span><span style="COLOR: blue">new</span><span style="COLOR: teal">PoxBufferedMessage</span>(buffer,
bufferManager);<br />
}<br /><br /><span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br />
///</span><span style="COLOR: green"> Reads an incoming stream containing a message
and<br /></span><span style="COLOR: gray">///</span><span style="COLOR: green"> wraps it with
a streamed message. The assumption is that the incoming 
<br /></span><span style="COLOR: gray">///</span><span style="COLOR: green"> data stream
is </span><span style="COLOR: gray">&lt;i&gt;</span><span style="COLOR: green">not</span><span style="COLOR: gray">&lt;/i&gt;</span><span style="COLOR: green"> a
SOAP envelope, but rather an unencapsulated<br /></span><span style="COLOR: gray">///</span><span style="COLOR: green"> data item,
may it be some raw binary, an XML document or HTML form<br /></span><span style="COLOR: gray">///</span><span style="COLOR: green"> postback data.
This method is called if the inbound transfer mode of the 
<br /></span><span style="COLOR: gray">///</span><span style="COLOR: green"> transport is
"streamed".<br /></span><span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br />
///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param name="stream"&gt;</span><span style="COLOR: green">Input
stream</span><span style="COLOR: gray">&lt;/param&gt;<br />
///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param name="maxSizeOfHeaders"&gt;</span><span style="COLOR: green">Maximum
size of headers in bytes</span><span style="COLOR: gray">&lt;/param&gt;<br />
///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Stream
message</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span><span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: teal">Message</span> ReadMessage(System.IO.<span style="COLOR: teal">Stream</span> stream, <span style="COLOR: blue">int</span> maxSizeOfHeaders)<br />
{<br />
   <span style="COLOR: blue">return</span><span style="COLOR: blue">new</span><span style="COLOR: teal">PoxStreamedMessage</span>(stream,
maxSizeOfHeaders);<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
Both variants take the raw incoming data (whatever it is) and hand it to the <i>PoxStreamMessage</i> class
or <i>PoxBufferedMessage </i>class that adopt the buffer or stream as their body content,
respectively. I’ll explain those in Part 7.
</p>
          <p>
Happy New Year!
</p>
        </div>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=51327201-07c7-4a30-b79c-53842cda1e77" />
      </body>
      <title>Teaching Indigo to do REST/POX: Part 6</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,51327201-07c7-4a30-b79c-53842cda1e77.aspx</guid>
      <link>http://vasters.com/clemensv/2006/01/02/Teaching+Indigo+To+Do+RESTPOX+Part+6.aspx</link>
      <pubDate>Mon, 02 Jan 2006 08:51:43 GMT</pubDate>
      <description>&lt;div class=Section1&gt;
&lt;p&gt;
&lt;span lang=DE&gt;&lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx"&gt;&lt;span lang=EN-US&gt;Part
1&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"&gt;&lt;span lang=EN-US&gt;Part
2&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx"&gt;&lt;span lang=EN-US&gt;Part
3&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx"&gt;&lt;span lang=EN-US&gt;Part
4&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx"&gt;Part
5&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
I threw a lot of unexplained code at you in Part 5 and that wasn’t really fair. 
&lt;/p&gt;
&lt;p&gt;
The &lt;i&gt;PoxEncoder &lt;/i&gt;class is a replacement for Indigo’s default &lt;i&gt;TextMessageEncoder &lt;/i&gt;class
that’s used by the HTTP transport unless you explicitly configure something different.
Indigo comes with three built-in encoders, namely:
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-FAMILY: Symbol"&gt;·&lt;/span&gt;&lt;span style="FONT-SIZE: 7pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;The &lt;i&gt;TextMessageEncoder&lt;/i&gt; serializes
Indigo’s internal &lt;i&gt;Message &lt;/i&gt;into SOAP 1.1 or SOAP 1.2 envelopes using (applies
only to the latter) the desired character encodings (UTF-8, UTF-16, etc.) and of course
it also deserializes incoming SOAP envelopes into the Indigo representation.
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-FAMILY: Symbol"&gt;·&lt;/span&gt;&lt;span style="FONT-SIZE: 7pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;The &lt;i&gt;MtomMessageEncoder&lt;/i&gt; serializes
messages into SOAP 1.2 messages as specified by the &lt;i&gt;&lt;a href="http://www.w3.org/TR/2005/REC-soap12-mtom-20050125/"&gt;MTOM&lt;/a&gt;&lt;/i&gt; specification,
which allows for a much more compact transmission of binary-heavy SOAP envelopes than
if you were simply using base64Binary encoded element data. MTOM is a good choice
whenever the size of binary content in a SOAP envelope far exceeds the size of the
rest of the data. Your mileage may vary, so that’s a thing to measure carefully unless
it’s blatantly obvious such as in the case of writing a service for a digital imaging
library.
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
&lt;span style="FONT-FAMILY: Symbol"&gt;·&lt;/span&gt;&lt;span style="FONT-SIZE: 7pt"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;The &lt;i&gt;BinaryMessageEncoder&lt;/i&gt; serializes
messages into SOAP 1.2 envelopes, but does so in a very compact binary format that
preserves the XML information set, but is not at all like XML text. The gist of the
binary encoding is the assumption that if both communicating parties are implemented
with Indigo and share the same contract, the metadata existing at both ends reduces
the hints that need to go on the wire. In other words: The binary encoding doesn’t
need to throw all&amp;nbsp; these lengthy XML tag names and namespace names explicitly
onto the wire, but can refer to them by pointing to a dictionary that’s identically
constructed on both ends. The binary encoding in Indigo is a bit like the modern-day,
loosely coupled grand-child of &lt;a href="http://www.opengroup.org/onlinepubs/9629399/chap14.htm"&gt;NDR&lt;/a&gt; and
“&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/midl/midl/ oi.asp"&gt;midl.exe
/Oicf&lt;/a&gt;” if you like. What’s important to note about this encoding is that its primary
design goal is performance and interoperability is in fact a non-goal. The &lt;i&gt;BinaryMessageEncoder&lt;/i&gt; assumes
Indigo endpoints. If you don’t like that, you can always use the text encoding, which
is designed for interoperability.
&lt;/p&gt;
&lt;p&gt;
Our &lt;i&gt;PoxEncoder&lt;/i&gt; here differs from all three Indigo encoders in that it does
specifically &lt;b&gt;not&lt;/b&gt; serialize SOAP messages, but rather just the body contents
of a &lt;i&gt;Message.&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
In order for you to understand what’s happening here, I’ll pick the most relevant
methods and explain them in detail. We will start with the &lt;i&gt;Initialize() &lt;/i&gt;method
that is invoked by all three constructor overloads:
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;///&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
///&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt; Initializes
common properties of the encoder.&lt;br&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;///&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;private&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Initialize()&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.MessageVersion.Envelope
== &lt;span style="COLOR: teal"&gt;EnvelopeVersion&lt;/span&gt;.Soap12)&lt;br&gt;
&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;// set the aprorpiate media type for
SOAP 1.2&lt;br&gt;
&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;. mediaType = &lt;span style="COLOR: maroon"&gt;"application/soap+xml"&lt;/span&gt;;&lt;br&gt;
&amp;nbsp; }&lt;br&gt;
&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;/span&gt; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.MessageVersion.Envelope
== &lt;span style="COLOR: teal"&gt;EnvelopeVersion&lt;/span&gt;.Soap11)&lt;br&gt;
&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;// set the appropriate media type for
SOAP 1.1&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;. mediaType = &lt;span style="COLOR: maroon"&gt;"text/xml"&lt;/span&gt;;&lt;br&gt;
&amp;nbsp; }&lt;br&gt;
&amp;nbsp; &lt;span style="COLOR: green"&gt;// compose the content type from charset and media
type&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;. contentType = &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="COLOR: teal"&gt;CultureInfo&lt;/span&gt;.InvariantCulture, &lt;span style="COLOR: maroon"&gt;"{0};
charset={1}"&lt;/span&gt;, mediaType, textEncoding.WebName);&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
It is required for each &lt;i&gt;MessageEncoder-&lt;/i&gt;derived class to implement the abstract
properties &lt;i&gt;MediaType&lt;/i&gt;, &lt;i&gt;ContentType&lt;/i&gt;, and &lt;i&gt;MessageVersion&lt;/i&gt;, and therefore
we have to initialize the backing fields for these properties properly and return
meaningful values even though the &lt;i&gt;PoxEncoder &lt;/i&gt;is exactly the “anti-SOAP” encoder.
The message version specified in the encoder is relevant for Indigo higher up on the
stack, because it needs to know what rules and constraints apply to &lt;i&gt;Message&lt;/i&gt; instances
as they are constructed and processed. The content type and media types are required
by the transports so that they know what content and/or media type to specify as metadata
in their transport frame (eg. the &lt;i&gt;Content-Type&lt;/i&gt; header in HTTP). If we initialize
the encoder with the Soap12 message version, it will consequently report the &lt;i&gt;application/soap+xml&lt;/i&gt; media
type, even though the encoder doesn’t ever write such envelopes to the wire. You might
consider that a bug in the &lt;i&gt;PoxEncoder&lt;/i&gt; and you might be right, but it doesn’t
really matter. Because any methods can return all sorts of payloads, we will override
the content-type on the message-level so that this information has really no effect.
I do need to clean this up a little. Later.
&lt;/p&gt;
&lt;p&gt;
Now let’s look at the parts that actually do the work. I will start with the two &lt;i&gt;WriteMessage&lt;/i&gt; overloads.
&lt;/p&gt;
&lt;p&gt;
The first overload’s signature is&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;public override ArraySegment&amp;lt;byte&amp;gt; WriteMessage(Message
msg, int maxMessageSize, BufferManager bufferManager, int messageOffset)&lt;br&gt;
&lt;/i&gt;and is invoked by the transport whenever a message must be wire-encoded and the
output transfer mode is set to &lt;i&gt;TransferMode.Buffered&lt;/i&gt; or &lt;i&gt;TransferMode.StreamedRequest &lt;/i&gt;(which
implies a buffered response). The second overload’s signature is&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;i&gt;public override void WriteMessage(Message msg, System.IO.Stream
stream)&lt;br&gt;
&lt;/i&gt;and is invoked by the transport whenever a message must be wire-encoded and the
output transfer mode is set of &lt;i&gt;TransferMode.Streamed&lt;/i&gt; or &lt;i&gt;TransferMode.StreamedResponse&lt;/i&gt; (which
implies a streamed response). 
&lt;/p&gt;
&lt;p&gt;
The transfer-mode property is configurable on all of the pre-built HTTP bindings and
on the &lt;i&gt;&amp;lt;httpTransport&amp;gt;&lt;/i&gt; binding element. “Buffered” encoding means that
the entire message is encoded at once and written into a buffer, which is then given
to the the transport for sending. “Streamed” encoding means that the message is pushed
into to a stream, whereby the stream is typically immediately layered directly over
the transport. That means that whenever our encoder writes data to that stream, it
is immediately pushed to the remote communication partner. The “streamed” mode is
the optimal choice for sending very large messages that are, for instance, too big
to be reasonably handled as a single memory block. The buffered mode is better (and
faster) for compact messages. I’ll dissect the buffered variant first:
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;
WriteMessage(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg, &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; maxMessageSize, &lt;span style="COLOR: teal"&gt;BufferManager&lt;/span&gt; bufferManager, &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; messageOffset)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (msg.IsEmpty)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;// if the message is empty
(no body defined) the result is an empty 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;// byte array.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[]
buffer = bufferManager.TakeBuffer(maxMessageSize);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;(buffer,
0, 0);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&amp;nbsp;&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
If the message is empty (that means: the body is empty), we request a buffer from
the buffer manager and return an empty slice of that buffer, because this encoder’s
output is “nothing” if the body is empty.The &lt;i&gt;BufferManager&lt;/i&gt; is an Indigo helper
class that manages a pool of pre-allocated buffers and serves to optimize memory management
by avoiding the allocation and the discarding of buffers for every message. And encoder
should therefore use the buffer manager argument and use it to obtain the buffers
backing the array segment that is to be returned. Once the message has been handled
by the transport, the transport will return the buffer into the pool. 
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;else&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: green"&gt;// check RawBinary
bit in the message property&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; rawBinary
= &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (msg.Properties.ContainsKey(&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;.Name))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rawBinary = ((&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;)msg.Properties[&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;.Name]).RawBinary;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
If the message is not empty (we have a body), we check whether there is a &lt;i&gt;PoxEncoderMessageProperty&lt;/i&gt; present
in the message. This property is a plain CLR class that is part of my extensions and
has two significant properties: &lt;i&gt;Name&lt;/i&gt; is a static, constant string value used
as the key for the message properties collection and &lt;i&gt;RawBinary&lt;/i&gt; is a Boolean
instance value that contains and indicator for whether the encoder shall encode the
data as XML or as raw binary data. The &lt;i&gt;Message&lt;/i&gt; property collection is a simple
dictionary of objects keyed by strings. The properties allow application-level code
to interact with infrastructure-level code in the way illustrated by this property.
Whenever I want the encoder to use its “raw binary” mode, I add this property to the
message and the encoder can pick up the information. 
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;
retval = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[] buffer
= bufferManager.TakeBuffer(maxMessageSize);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (!rawBinary)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;// If
we're rendering XML data, we construct a memory stream&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
over the output buffer, layer an XMLDictionaryWriter on top of it&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
and have the message write the body content into the buffer as XML.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
The buffer is then wrapped into an array segment and returned.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;MemoryStream&lt;/span&gt; stream
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MemoryStream&lt;/span&gt;(buffer);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;XmlWriterSettings&lt;/span&gt; settings
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;XmlWriterSettings&lt;/span&gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;settings.OmitXmlDeclaration
= &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;settings.Indent = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;settings.Encoding = &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.
textEncoding;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;XmlWriter&lt;/span&gt; innerWriter
= &lt;span style="COLOR: teal"&gt;XmlWriter&lt;/span&gt;.Create(stream, settings);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;XmlDictionaryWriter&lt;/span&gt; writer
= &lt;span style="COLOR: teal"&gt;XmlDictionaryWriter&lt;/span&gt;.CreateDictionaryWriter(innerWriter, &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;msg.WriteBodyContents(writer);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;writer.Flush();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;retval = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;(buffer,
0, (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;)stream.Position);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
Next we take a buffer from the buffer manager and if we’re not in “raw binary” mode,
we’ll construct a memory stream over the buffer, construct an XmlDictionaryWriter
over that stream and ask the message to render its “body contents” into the writer
and therefore into the memory stream and into the buffer. The “body contents” of a
message is what would be the child nodes of the &amp;lt;soap:Body&amp;gt; element, if we were
using that (but we don’t). Once the body contents have been written, we flush the
writer to make sure that all buffered data is committed into the underlying stream
and then construct the return value as an array segment over the buffer with the length
of the bytes written to the stream. 
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;else&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;// If
we're rendering raw binary data, we grab at most 'buffer.Length'&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
bytes from the binary content of the base64Binary element (if that 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
exists) and return the result wrapped into an array segment.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;XmlDictionaryReader&lt;/span&gt; dictReader
= msg.GetReaderAtBodyContents();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (dictReader.NodeType
== &lt;span style="COLOR: teal"&gt;XmlNodeType&lt;/span&gt;.Element &amp;amp;&amp;amp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dictReader.LocalName
== &lt;span style="COLOR: maroon"&gt;"base64Binary"&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (dictReader.Read()
&amp;amp;&amp;amp; dictReader.NodeType == &lt;span style="COLOR: teal"&gt;XmlNodeType&lt;/span&gt;.Text)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;int&lt;/span&gt; size
= dictReader.ReadContentAsBase64(buffer, 0, buffer.Length);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;retval
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;(buffer,
0, size);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; retval;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;br&gt;
&amp;nbsp;&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
If the “raw binary” mode is to be used, we are making a bit of an assumption inside
the encoder. The assumption is that the body content consists of a single element
named “base64Binary” and that its content is just that: base64 binary encoded content.
That is of course the other side of the &lt;i&gt;PoxBase64XmlStreamReader &lt;/i&gt;trick I explained
in &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx"&gt;Part
5&lt;/a&gt;. For binary data we simply assume here that the body reader is our wrapper class
and this is how arbitrary binary data is smuggled through the Indigo infrastructure.
The array segment to be returned is constructed by reading the binary data into the
buffer and setting the array segment length to the number of bytes we could get from
the element content.
&lt;/p&gt;
&lt;p&gt;
The streamed version of &lt;i&gt;WriteMessage&lt;/i&gt; is quite different:
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; WriteMessage(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg,
System.IO.&lt;span style="COLOR: teal"&gt;Stream&lt;/span&gt; stream)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;try&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (!msg.IsEmpty)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
check RawBinary bit in the message property&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; rawBinary
= &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (msg.Properties.ContainsKey(&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;.Name))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
rawBinary = ((&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;)msg.Properties[&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;.Name]).RawBinary;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (!rawBinary)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
If we're rendering XML, we layer an XMLDictionaryWriter over the 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
output stream and have the message render its body content into&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
that writer and therefore onto the stream.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;XmlWriterSettings&lt;/span&gt; settings
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;XmlWriterSettings&lt;/span&gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;settings.OmitXmlDeclaration
= &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
settings.Indent = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
settings.Encoding = &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;. textEncoding;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;XmlWriter&lt;/span&gt; innerWriter
= &lt;span style="COLOR: teal"&gt;XmlWriter&lt;/span&gt;.Create(stream, settings);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;XmlDictionaryWriter&lt;/span&gt; writer
= &lt;span style="COLOR: teal"&gt;XmlDictionaryWriter&lt;/span&gt;.CreateDictionaryWriter(innerWriter, &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
msg.WriteBodyContents(writer);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
writer.Flush();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
The first significant difference is that if we’re using streams, we will simply ignore
empty messages and do nothing with them. In streaming mode, the transport will do
any setup work required for &amp;nbsp;sending a message before invoking the encoder and
ready the output network stream so that the encoder can write to it. When the encoder
returns, the transport considers the write action done. So if we don’t write to the
output stream, there’s no payload data hitting the wire and that happens to be what
we want.
&lt;/p&gt;
&lt;p&gt;
If we have data and we’re not in “raw binary” mode, the encoder will construct an &lt;i&gt;XmlDictionaryWriter&lt;/i&gt; over
the supplied stream and have the message write its body contents to it. That’s all.
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;Else&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
If we're rendering raw binary data, we grab chunks of at most 1MByte&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
from the 'base64Binary' content element (if that exists) and write them&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
out as binary data to the output stream. Chunking is done, because we&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
have to assume that the body content is arbitrarily large. To optimize the 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
behavior for large streams, we read and write concurrently and swap buffers.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;XmlDictionaryReader&lt;/span&gt; dictReader
= msg.GetReaderAtBodyContents();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (dictReader.NodeType
== &lt;span style="COLOR: teal"&gt;XmlNodeType&lt;/span&gt;.Element &amp;amp;&amp;amp; dictReader.LocalName
== &lt;span style="COLOR: maroon"&gt;"base64Binary"&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (dictReader.Read()
&amp;amp;&amp;amp; dictReader.NodeType == &lt;span style="COLOR: teal"&gt;XmlNodeType&lt;/span&gt;.Text)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[]
buffer1 = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[1024*1024],
buffer2 = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[1024*1024];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[] readBuffer = buffer1, writeBuffer =
buffer2;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; bytesRead
= 0;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
read the first chunk into the read buffer&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
bytesRead = dictReader.ReadContentAsBase64(readBuffer, 0, readBuffer.Length);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;do&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
the abort condition for the loop is that we can't read&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: green"&gt;//
any more bytes from the input because the base64Binary element is&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
exhausted.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (bytesRead
&amp;gt; 0 )&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
make the last read buffer the write buffer&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
writeBuffer = readBuffer;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
write the write buffer to the output stream asynchronously&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;IAsyncResult&lt;/span&gt; result
= stream.BeginWrite(writeBuffer, 0, bytesRead,&lt;span style="COLOR: blue"&gt;null&lt;/span&gt;,&lt;span style="COLOR: blue"&gt;null&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
swap the read buffer&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
readBuffer = (readBuffer == buffer1) ? buffer2 : buffer1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
read a new chunk into the 'other' buffer synchronously&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
bytesRead = dictReader.ReadContentAsBase64(readBuffer, 0, readBuffer.Length);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: green"&gt;//
wait for the write operation to complete&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
result.AsyncWaitHandle.WaitOne();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
stream.EndWrite(result);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;while&lt;/span&gt; (bytesRead
&amp;gt; 0);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;catch&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;// the client
may disconnect at any time, so that's an expected exception and absorbed.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
In streamed “raw binary” mode things get a bit more complicated. Under these circumstances
we assume that the output we are sending is HUGE. The use-case I had in mind when
I wrote this is the download of multi-GByte video recordings. Therefore I construct
two 1MByte buffers that are used in turns to read a chunk of data from the source
body reader (for which we make the same content assumption as for the buffered case:
This is believed to be a &lt;i&gt;PoxBase64XmlStreamReader&lt;/i&gt; compatible infoset) and asynchronously
push the read data into the output stream.
&lt;/p&gt;
&lt;p&gt;
Because it may take a while to get a huge data stream to the other side, a lot of
things can happen to the network connection during that time. Therefore the encoder
fully expects that the network connection terminates unexpectedly. If that happens,
we’ll catch and absorb the network exception and happily return to the caller as if
we’re done.
&lt;/p&gt;
&lt;p&gt;
Compared to all the complexity of the &lt;i&gt;WriteMessage &lt;/i&gt;&amp;nbsp;overloads, the respective &lt;i&gt;ReadMessage&lt;/i&gt; methods
look fairly innocent, simple, and similar:
&lt;/p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=0&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p style="MARGIN-BOTTOM: 12pt"&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;///&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
///&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt; Reads
an incoming array segment containing a message and&lt;br&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;///&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt; wraps
it with a buffered message. The assumption is that the incoming 
&lt;br&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;///&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt; data
stream is &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;&amp;lt;i&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt;not&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;&amp;lt;/i&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt; a
SOAP envelope, but rather an unencapsulated&lt;br&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;///&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt; data
item, may it be some raw binary, an XML document or HTML form&lt;br&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;///&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt; postback
data. This method is called if the inbound transfer mode of the 
&lt;br&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;///&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt; transport
is "buffered".&lt;br&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;///&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
///&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;&amp;lt;param
name="buffer"&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt;Buffer
to wrap&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
///&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;&amp;lt;param
name="bufferManager"&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt;Buffer
manager to help with allocating a copy&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
///&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: green; FONT-FAMILY: Courier"&gt;Buffered
message&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: gray; FONT-FAMILY: Courier"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;public&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; ReadMessage(&lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;
buffer, &lt;span style="COLOR: teal"&gt;BufferManager&lt;/span&gt; bufferManager)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxBufferedMessage&lt;/span&gt;(buffer,
bufferManager);&lt;br&gt;
}&lt;br&gt;
&lt;br&gt;
&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Reads an incoming stream containing a message
and&lt;br&gt;
&lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; wraps it with
a streamed message. The assumption is that the incoming 
&lt;br&gt;
&lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; data stream
is &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;i&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;not&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/i&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; a
SOAP envelope, but rather an unencapsulated&lt;br&gt;
&lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; data item,
may it be some raw binary, an XML document or HTML form&lt;br&gt;
&lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; postback data.
This method is called if the inbound transfer mode of the 
&lt;br&gt;
&lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; transport is
"streamed".&lt;br&gt;
&lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param name="stream"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Input
stream&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param name="maxSizeOfHeaders"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Maximum
size of headers in bytes&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Stream
message&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; ReadMessage(System.IO.&lt;span style="COLOR: teal"&gt;Stream&lt;/span&gt; stream, &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; maxSizeOfHeaders)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp; &amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxStreamedMessage&lt;/span&gt;(stream,
maxSizeOfHeaders);&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
Both variants take the raw incoming data (whatever it is) and hand it to the &lt;i&gt;PoxStreamMessage&lt;/i&gt; class
or &lt;i&gt;PoxBufferedMessage &lt;/i&gt;class that adopt the buffer or stream as their body content,
respectively. I’ll explain those in Part 7.
&lt;/p&gt;
&lt;p&gt;
Happy New Year!
&lt;/p&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=51327201-07c7-4a30-b79c-53842cda1e77" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,51327201-07c7-4a30-b79c-53842cda1e77.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=3712ee6b-cd80-4db3-a96c-c740491f588e</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=3712ee6b-cd80-4db3-a96c-c740491f588e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <div class="Section1">
          <p>
            <span lang="DE">
              <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx">
                <span lang="EN-US">Part
1</span>
              </a>
            </span>, <span lang="DE"><a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"><span lang="EN-US">Part
2</span></a></span>, <span lang="DE"><a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx"><span lang="EN-US">Part
3</span></a></span>, <span lang="DE"><a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx"><span lang="EN-US">Part
4</span></a></span></p>
          <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
            <p>
              <i>POX means “plain old XML” and I’ve also heard a definition saying that “POX is
REST without the dogma”, but that’s not really correct. POX is not really well defined,
but it’s clear that the “plain” is the focus and that means typically that folks who
talk about “POX web services” explicitly mean that those services don’t use SOAP.
You could see POX as an <a href="http://staff.newtelligence.net/clemensv/ct.ashx?id=2d61b97b-3a6e-46bd-89db-b1b20499ba18&amp;url=http%3a%2f%2fdictionary.reference.com%2fsearch%3fq%3dantonym"><span style="COLOR: windowtext; TEXT-DECORATION: none">antonym</span></a> for
SOAP.</i>
            </p>
          </blockquote>
          <p>
The design of Indigo (WCF) assumes that all messages that go onto the wire and come
from the wire have a shape that is aligned with SOAP. That means that they have a
“body” containing the user-defined message payload and a “header” section that contains
the out-of-band metadata that helps getting the message from one place to the next,
possibly through a chain of intermediaries. Most of the Indigo binding elements and
their implementations also assume that those metadata elements (headers) conform to
their respective WS-* standard that they are dealing with.
</p>
          <p>
However, Indigo isn’t hard-wired to a specific envelope format. The default “encoders”
that are responsible for turning a message into data stream (or a data package) that
a transport can throw down a TCP socket or into a message queue (or whatever else)
and which are likewise responsible for picking up the data from the wire to turn them
into <i>Message</i> objects have two envelope formats baked in: SOAP 1.1 and SOAP
1.2. But that doesn’t mean that you have to use those. If your envelope format were
different (there seem to be thousands, I’ll name <a href="http://www.adsml.org/">AdsML</a> [<a href="http://www.ifra.com/website/adsml.nsf/All/FE5EB7BDE5050A3EC1256CD2005DA5A8/$FILE/AdsML%20Specification%20AS-1%200%20122204.pdf">spec</a>]
as an example) and that’s what you want to use on the wire, you can assemble a binding
that will compose an Indigo transport with your encoder. Moving away from SOAP means,
though, that you can’t use the standard implementations of capabilities such as message-level
security, reliable delivery, and transaction flow, because all of these are built
on the assumption that you are exchanging WS-* headers with the other party and all
of these specs depend on the SOAP information model. But if there are comparable specifications
that come with your envelope format you can of course write Indigo extensions that
you can configure into a binding just like you can compose the default binding elements.
It’d be a lot of work to do that, but you’d still benefit greatly from the Indigo
architecture per-se. 
</p>
          <p>
When we want to use a REST/POX model, our envelope format is quite simple: We don’t
really have an envelope.
</p>
          <p>
The idea of POX is that there’s only payload and that out-of-band metadata is unnecessary
fluff. The idea of REST is that there is already and appropriate place for out-of-band
metadata and that’s the HTTP headers.
</p>
          <p>
In order to make REST/POX work, we therefore need to replace the Indigo default encoder
with an encoder that fulfills these requirements:
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
1.<span style="FONT: 7pt 'Times New Roman'">      </span>Extract
the message <i>body</i> XML content of any <b>outbound</b> message and format it for
the wire as-is and without a SOAP envelope around it and
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
2.<span style="FONT: 7pt 'Times New Roman'">      </span>Accept
an arbitrary <b>inbound</b> XML data and wrap it into a <i>Message</i>-derived class
so that Indigo can handle it.
</p>
          <p>
Since the use-case in whose context I’ve developed these extensions is a bit more
far reaching than POX, but I indeed want to support RESTful access to any data including
multi-GByte unencapsulated MPEG recordings I make on my Media PC, I’ve broadened these
two requirements a bit and left out the “XML” constraint:
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
1.<span style="FONT: 7pt 'Times New Roman'">      </span>Extract
the message <i>body</i><s>XML</s> content of any <b>outbound</b> message and format
it for the wire as-is and without a SOAP envelope around it and
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
2.<span style="FONT: 7pt 'Times New Roman'">      </span>Accept
an arbitrary <b>inbound</b><s>XML</s> data and wrap it into a <i>Message</i>-derived
class so that Indigo can handle it.
</p>
          <p>
XML aka POX is an interesting content-type to throw around, but it’s by no means the
only one and therefore let’s not restrict ourselves too much here. Any content is
good.
</p>
          <p>
But then again, Indigo is assuming that all messages flowing through its channels
contain XML payloads and therefore we’ve got a bit of a nut to crack when we want
to use Indigo for arbitrary, non-XML payloads of arbitrary size. Luckily, XML is just
an illusion.
</p>
          <p>
The Indigo <i>Message</i> holds the message body content inside an <i>XmlDictionaryReader</i> (which
is an optimized derivation of the well-known <i>XmlReader</i>). To construct a message,
you can walk up to the static <i>Message.CreateMessage(string action, XmlDictionaryReader
reader) </i>factory method and pass the readily formatted body content as a reader
object and the message will happily adopt it. But can we use the <i>XmlReader</i> to
smuggle arbitrary binary content into the message so that our own encoder can later
unwrap it and put it onto the wire in whatever raw binary format we like? Sure we
can! The class below may look a bit like an evil hack, but it’s a perfectly legal
construct:
</p>
          <table class="MsoTableGrid" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="1">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p>
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">
                      <font size="1">using</font>
                    </span>
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">
                      <font size="1"> System;<br /><span style="COLOR: blue">using</span> System.Collections.Generic;<br /><span style="COLOR: blue">using</span> System.Text;<br /><span style="COLOR: blue">using</span> System.Xml;<br /><span style="COLOR: blue">using</span> System.IO;<br /><span style="COLOR: blue">using</span> System.Xml.Schema;<br /><br /><span style="COLOR: blue">namespace</span> newtelligence.ServiceModelExtensions<br />
{<br />
   <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: teal">PoxBase64XmlStreamReader</span> : </font>
                      <font size="1">
                        <span style="COLOR: teal">XmlTextReader<br /></span>   {<br />
      <span style="COLOR: blue">private</span><span style="COLOR: blue">const</span><span style="COLOR: blue">string</span> xmlEnvelopeString
= 
<br />
           <span style="COLOR: maroon">"&lt;base64Binary
xmlns:xsi=\""</span> + <span style="COLOR: teal">XmlSchema</span>.InstanceNamespace
+ <span style="COLOR: maroon">"\" "</span> +<br />
           <span style="COLOR: maroon">"xmlns:xsd=\""</span> + <span style="COLOR: teal">XmlSchema</span>.Namespace
+ <span style="COLOR: maroon">"\" "</span> +<br />
           <span style="COLOR: maroon">"xsi:type=\"xsd:base64Binary\"&gt;placeholder&lt;/base64Binary&gt;"</span>;<br />
      <span style="COLOR: teal">Stream</span> innerStream;<br /><br />
      <span style="COLOR: gray">///</span><span style="COLOR: green"></span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;summary&gt;<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"> Initializes
a new instance of the </span><span style="COLOR: gray">&lt;see cref="T:PoxBase64XmlStreamReader"/&gt;</span></font>
                      <font size="1">
                        <span style="COLOR: green"> class.<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;/summary&gt;<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="stream"&gt;</span><span style="COLOR: green">The stream.</span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;/param&gt;<br /></span>      <span style="COLOR: blue">public</span> PoxBase64XmlStreamReader(<span style="COLOR: teal">Stream</span> stream)<br />
         : <span style="COLOR: blue">base</span>(<span style="COLOR: blue">new</span><span style="COLOR: teal">StringReader</span>(xmlEnvelopeString))<br />
      {<br />
         innerStream = stream;<br />
      }<br /><br />
      <span style="COLOR: gray">///</span><span style="COLOR: green"></span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;summary&gt;<br /></span>      <span style="COLOR: gray">///</span></font>
                      <font size="1">
                        <span style="COLOR: green"> Gets
The Common Language Runtime (CLR) type for the current node.<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;/summary&gt;<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;value&gt;&lt;/value&gt;<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">The
CLR type that corresponds to the typed value of the node. The default is System.String.</span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;/returns&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: teal">Type</span> ValueType<br />
      {<br />
         </font>
                      <font size="1">
                        <span style="COLOR: blue">get<br /></span>         {<br />
            <span style="COLOR: blue">if</span> (NodeType
== <span style="COLOR: teal">XmlNodeType</span>.Text &amp;&amp; <span style="COLOR: blue">base</span>.Value
== <span style="COLOR: maroon">"placeholder"</span>)<br />
            {<br />
               <span style="COLOR: blue">return</span><span style="COLOR: blue">typeof</span>(<span style="COLOR: teal">Byte</span>[]);<br />
            }<br />
            </font>
                      <font size="1">
                        <span style="COLOR: blue">else<br /></span>            {<br />
               <span style="COLOR: blue">return</span><span style="COLOR: blue">base</span>.ValueType;<br />
            }<br />
         }<br />
      }<br />
    
<br />
      <span style="COLOR: gray">///</span><span style="COLOR: green"></span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;summary&gt;<br /></span>      <span style="COLOR: gray">///</span></font>
                      <font size="1">
                        <span style="COLOR: green"> Gets
the text value of the current node.<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;/summary&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: blue">string</span> Value<br />
      {<br />
         </font>
                      <font size="1">
                        <span style="COLOR: blue">get<br /></span>         {<br />
            <span style="COLOR: blue">if</span> (NodeType
== <span style="COLOR: teal">XmlNodeType</span>.Text &amp;&amp; <span style="COLOR: blue">base</span>.Value
== <span style="COLOR: maroon">"placeholder"</span>)<br />
            {<br />
               <span style="COLOR: teal">BinaryReader</span> reader
= <span style="COLOR: blue">new</span><span style="COLOR: teal">BinaryReader</span>(innerStream);<br />
               <span style="COLOR: blue">return</span><span style="COLOR: teal">Convert</span>.ToBase64String(reader.ReadBytes((<span style="COLOR: blue">int</span>)(reader.BaseStream.Length
- reader.BaseStream.Position)));<br />
            }<br />
            <span style="COLOR: blue">return</span><span style="COLOR: blue">base</span>.Value;<br />
         }<br />
      }<br /><br />
      <span style="COLOR: gray">///</span><span style="COLOR: green"></span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;summary&gt;<br /></span>      <span style="COLOR: gray">///</span></font>
                      <font size="1">
                        <span style="COLOR: green"> Reads
the content and returns the Base64 decoded binary bytes.<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;/summary&gt;<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="buffer"&gt;</span><span style="COLOR: green">The buffer into which to copy the
resulting text. This value cannot be null.</span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;/param&gt;<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="index"&gt;</span><span style="COLOR: green">The offset into the buffer where
to start copying the result.</span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;/param&gt;<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="count"&gt;</span><span style="COLOR: green">The maximum number of bytes to copy
into the buffer. The actual number of bytes copied is returned from this method.</span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;/param&gt;<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;returns&gt;<br /></span>      <span style="COLOR: gray">///</span></font>
                      <font size="1">
                        <span style="COLOR: green"> The
number of bytes written to the buffer.<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span></font>
                      <font size="1">
                        <span style="COLOR: gray">&lt;/returns&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: blue">int</span> ReadContentAsBase64(<span style="COLOR: blue">byte</span>[]
buffer, <span style="COLOR: blue">int</span> index, <span style="COLOR: blue">int</span> count)<br />
      {<br />
         <span style="COLOR: blue">if</span> (NodeType
== <span style="COLOR: teal">XmlNodeType</span>.Text &amp;&amp; <span style="COLOR: blue">base</span>.Value
== <span style="COLOR: maroon">"placeholder"</span>)<br />
         {<br />
            <span style="COLOR: blue">return</span> innerStream.Read(buffer,
index, count);<br />
         }<br />
         </font>
                      <font size="1">
                        <span style="COLOR: blue">else<br /></span>         {<br />
            <span style="COLOR: blue">return</span><span style="COLOR: blue">base</span>.ReadContentAsBase64(buffer,
index, count);<br />
         }<br />
      }<br />
   }<br />
}</font>
                    </span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
The <i>PoxBase64XmlStreamReader</i> is a specialized XML reader reading a fixed info-set
constructed from a string that has a “placeholder” in whose place the content of a
wrapped data stream is returned “as base64 encoded content”. Of course that latter
statement is hogwash. The data is never encoded in base64 anywhere. But the consumer
of the reader <i>thinks</i> that it is and that’s really good enough for us here.
The <i>XmlReader</i> creates the illusion that the wrapped data stream were the “text”
node of a base64Binary typed element and if that’s what the client wants to believe,
we’re happy.  The implementation trick here is of course very simple. As long
as the reader isn’t hitting the text node with the “placeholder” all work is being
delegated to the base class. Once we arrive at that particular node, we change tactics
and return the data type (byte[]) and the content of the wrapped stream instead of
the “placeholder” string. After that we continue delegating to the base class. If
the client asks for the <i>Value</i> of the text node, we are returning a base64 encoded
string representation of the wrapped stream which might end up being pretty big. However,
if the client is a bit less naïve about the content, it will figure that the data
type is <i>byte[]</i> and therefore retrieve the data in binary chunks through the <i>ReadContentAsBase64()</i> method.
Let’s assume that the client will be that clever. 
</p>
          <p>
It doesn’t take too much imagination talent to do so, because I’ve got the client
right here. I used <a href="http://www.douglasp.com/">Doug Purdy</a>’s PoxEncoder
that he showed at PDC05 as a basis for this and extended it (quite) a bit:
</p>
          <table class="MsoTableGrid" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="1">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p>
                    <span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier">using</span>
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"> System;<br /><span style="COLOR: blue">using</span> System.IO;<br /><span style="COLOR: blue">using</span> System.Xml;<br /><span style="COLOR: blue">using</span> System.Text;<br /><span style="COLOR: blue">using</span> System.ServiceModel;<br /><span style="COLOR: blue">using</span> System.ServiceModel.Channels;<br /><span style="COLOR: blue">using</span> System.ServiceModel.Design;<br /><span style="COLOR: blue">using</span> System.Runtime.CompilerServices;<br /><span style="COLOR: blue">using</span> System.ServiceModel.Configuration;<br /><span style="COLOR: blue">using</span> System.Configuration;<br /><span style="COLOR: blue">using</span> System.Globalization;<br /><span style="COLOR: blue">using</span> System.Xml.Schema;<br /><span style="COLOR: blue">using</span> System.Diagnostics;<br /><br /><span style="COLOR: blue">namespace</span> newtelligence.ServiceModelExtensions<br />
{<br />
    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> This
class is a wire-format encoder for System.ServiceModel that renders<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> only
the content (body) of a </span><span style="COLOR: gray">&lt;see cref="T:Message"/&gt;</span><span style="COLOR: green"> onto
the wire, but not 
<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> the
surrounding SOAP message elements such as the enevlope, the headers or<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> the
body element. Likewise, the encoder expects input to be in 'raw', unwrapped<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> form
and will wrap it into a message for processing by the System.ServiceModel 
<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> infrastructure. 
<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>    <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: teal">PoxEncoder</span> : <span style="COLOR: teal">MessageEncoder<br /></span>   {<br />
      <span style="COLOR: blue">string</span> contentType;<br />
      <span style="COLOR: blue">string</span> mediaType;<br />
      <span style="COLOR: teal">Encoding</span> textEncoding;<br />
      <span style="COLOR: teal">MessageVersion</span> messageVersion;<br /><br />
      <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"> Creates
a new instance of PoxEncoder<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>      <span style="COLOR: blue">public</span> PoxEncoder()<br />
      {<br />
          messageVersion = <span style="COLOR: teal">MessageVersion</span>.Soap11Addressing1;<br />
          textEncoding = <span style="COLOR: teal">Encoding</span>.UTF8;<br />
         Initialize();<br />
      }<br /><br />
      <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"> Creates
a new instance of PoxEncoder<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="messageVersion"&gt;&lt;/param&gt;<br /></span>      <span style="COLOR: blue">public</span> PoxEncoder(<span style="COLOR: teal">MessageVersion</span> messageVersion)<br />
      {<br />
         <span style="COLOR: blue">this</span>.
messageVersion = messageVersion;<br />
          textEncoding = <span style="COLOR: teal">Encoding</span>.UTF8;<br />
         Initialize();<br />
      }<br /><br /><br />
      <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"> Creates
a new instance of PoxEncoder<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="textEncoding"&gt;&lt;/param&gt;<br /></span>      <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="messageVersion"&gt;&lt;/param&gt;<br /></span>      <span style="COLOR: blue">public</span> PoxEncoder(<span style="COLOR: teal">Encoding</span> textEncoding, <span style="COLOR: teal">MessageVersion</span> messageVersion)<br />
      {<br />
         <span style="COLOR: blue">this</span>.
textEncoding = textEncoding;<br />
         <span style="COLOR: blue">this</span>.
messageVersion = messageVersion;<br />
         Initialize();<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Initializes
common properties of the encoder.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>      <span style="COLOR: blue">private</span><span style="COLOR: blue">void</span> Initialize()<br />
      {<br />
         <span style="COLOR: blue">if</span> (<span style="COLOR: blue">this</span>.MessageVersion.Envelope
== <span style="COLOR: teal">EnvelopeVersion</span>.Soap12)<br />
         {<br />
                <span style="COLOR: green">//
set the aprorpiate media type for SOAP 1.2<br /></span>            <span style="COLOR: blue">this</span>.
mediaType = <span style="COLOR: maroon">"application/soap+xml"</span>;<br />
         }<br />
         <span style="COLOR: blue">else</span><span style="COLOR: blue">if</span> (<span style="COLOR: blue">this</span>.MessageVersion.Envelope
== <span style="COLOR: teal">EnvelopeVersion</span>.Soap11)<br />
         {<br />
                <span style="COLOR: green">//
set the appropriate media type for SOAP 1.1<br /></span>            <span style="COLOR: blue">this</span>.
mediaType = <span style="COLOR: maroon">"text/xml"</span>;<br />
         }<br />
            <span style="COLOR: green">//
compose the content type from charset and media type<br /></span>         <span style="COLOR: blue">this</span>.
contentType = <span style="COLOR: blue">string</span>.Format(<span style="COLOR: teal">CultureInfo</span>.InvariantCulture, <span style="COLOR: maroon">"{0};
charset={1}"</span>, mediaType, textEncoding.WebName);<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the content type for the encoder instance<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: blue">string</span> ContentType<br />
      {<br />
         <span style="COLOR: blue">get<br /></span>         {<br />
            <span style="COLOR: blue">return</span> contentType;<br />
         }<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the media type for the encoder instance<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: blue">string</span> MediaType<br />
      {<br />
         <span style="COLOR: blue">get<br /></span>         {<br />
            <span style="COLOR: blue">return</span> mediaType;<br />
         }<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
an indicator for whether a given input content type is 
<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> supported.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="contentType"&gt;</span><span style="COLOR: green">ContentType</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Indicates
whether the content type is supported</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;remarks&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> TODO:
This currently returns 'true' for all content types because the 
<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> encoder
isn't locked down in features yet and this easier to debug. 
<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> The
plan is to support at least: application/x-www-form-urlencoded, 
<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> text/xml,
application/soap+xml<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/remarks&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: blue">bool</span> IsContentTypeSupported(<span style="COLOR: blue">string</span> contentType)<br />
      {<br />
         <span style="COLOR: blue">return</span><span style="COLOR: blue">true</span>;<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the supported message version of this instance<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: teal">MessageVersion</span> MessageVersion<br />
      {<br />
         <span style="COLOR: blue">get<br /></span>         {<br />
            <span style="COLOR: blue">return</span> messageVersion;<br />
         }<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Reads
an incoming array segment containing a message and<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> wraps
it with a buffered message. The assumption is that the incoming 
<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> data
stream is </span><span style="COLOR: gray">&lt;i&gt;</span><span style="COLOR: green">not</span><span style="COLOR: gray">&lt;/i&gt;</span><span style="COLOR: green"> a
SOAP envelope, but rather an unencapsulated<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> data
item, may it be some raw binary, an XML document or HTML form<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> postback
data. This method is called if the inbound transfer mode of the 
<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> transport
is "buffered".<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="buffer"&gt;</span><span style="COLOR: green">Buffer to wrap</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="bufferManager"&gt;</span><span style="COLOR: green">Buffer manager to help with
allocating a copy</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Buffered
message</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>        <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: teal">Message</span> ReadMessage(<span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;
buffer, <span style="COLOR: teal">BufferManager</span> bufferManager)<br />
      {<br />
         <span style="COLOR: blue">return</span><span style="COLOR: blue">new</span><span style="COLOR: teal">PoxBufferedMessage</span>(buffer,
bufferManager);<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Transforms
an incoming message into a raw byte array that a transport can 
<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> literally
put on the wire as it is returned. This method is called if the outbound<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> transfer
mode of the transport is "buffered".<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="msg"&gt;</span><span style="COLOR: green">Input message</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="maxMessageSize"&gt;</span><span style="COLOR: green">Maximum message size to
be rendered</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="bufferManager"&gt;</span><span style="COLOR: green">Buffer manager to optimize
buffer allocation</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="messageOffset"&gt;</span><span style="COLOR: green">Offset into the message
to render.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Array
segment containing the binary data to be put onto the wire by the transport.</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;remarks&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;para&gt;</span><span style="COLOR: green">This
method is the "secret sauce" of the the PoxEncoder. Instead of encoding the 
<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> message
in its entirety, this encoder will unwrap the message body and toss out<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> the
envelope and all headers. The resulting "raw" message body (everything inside<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> and
not including soap:Body) will be written out to the transport.</span><span style="COLOR: gray">&lt;/para&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;para&gt;</span><span style="COLOR: green">The
encoder has an optional, "out of band" argument that is flowing into it<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> as
part of the message's Properties. By adding a </span><span style="COLOR: gray">&lt;see
cref="T:PoxEncoderMessageProperty"/&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> to
the </span><span style="COLOR: gray">&lt;see cref="Message.Properties"/&gt;</span><span style="COLOR: green"> and
setting its </span><span style="COLOR: gray">&lt;see cref="PoxEncoderMessageProperty.RawBinary"/&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> property
to 'true', you can switch the encoder into its 'raw binary' mode.</span><span style="COLOR: gray">&lt;/para&gt;</span><span style="COLOR: green"><br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;para&gt;</span><span style="COLOR: green"> In
'raw binary' mode, the encoder expects that the only child of the message<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> body
element is an element with a local name of "base64Binary" containing base64 encoded<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> binary
data. If that is the case, the encoder will read the content of that element<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> and
return it (not the XML wrapper) to the transport in binary form. If the content does<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> not
comply with this requirement, an empty array is returned.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/para&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/remarks&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;
WriteMessage(<span style="COLOR: teal">Message</span> msg, <span style="COLOR: blue">int</span> maxMessageSize, <span style="COLOR: teal">BufferManager</span> bufferManager, <span style="COLOR: blue">int</span> messageOffset)<br />
      {<br />
         <span style="COLOR: blue">if</span> (msg.IsEmpty)<br />
         {<br />
            <span style="COLOR: green">//
if the message is empty (no body defined) the result is an empty 
<br /></span>            <span style="COLOR: green">//
byte array.<br /></span>            <span style="COLOR: blue">byte</span>[]
buffer = bufferManager.TakeBuffer(maxMessageSize);<br />
            <span style="COLOR: blue">return</span><span style="COLOR: blue">new</span><span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;(buffer,
0, 0);<br />
         }<br />
         <span style="COLOR: blue">else<br /></span>         {<br />
            <span style="COLOR: green">//
check RawBinary bit in the message property<br /></span>                <span style="COLOR: blue">bool</span> rawBinary
= <span style="COLOR: blue">false</span>;<br />
                <span style="COLOR: blue">if</span> (msg.Properties.ContainsKey(<span style="COLOR: teal">PoxEncoderMessageProperty</span>.Name))<br />
            {<br />
               rawBinary
= ((<span style="COLOR: teal">PoxEncoderMessageProperty</span>)msg.Properties[<span style="COLOR: teal">PoxEncoderMessageProperty</span>.Name]).RawBinary;<br />
            }<br /><br />
            <span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;
retval = <span style="COLOR: blue">new</span><span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;();<br />
            <span style="COLOR: blue">byte</span>[]
buffer = bufferManager.TakeBuffer(maxMessageSize);<br />
            <span style="COLOR: blue">if</span> (!rawBinary)<br />
            {<br />
               <span style="COLOR: green">//
If we're rendering XML data, we construct a memory stream<br /></span>               <span style="COLOR: green">//
over the output buffer, layer an XMLDictionaryWriter on top of it<br /></span>               <span style="COLOR: green">//
and have the message write the body content into the buffer as XML.<br /></span>               <span style="COLOR: green">//
The buffer is then wrapped into an array segment and returned.<br /></span>               <span style="COLOR: teal">MemoryStream</span> stream
= <span style="COLOR: blue">new</span><span style="COLOR: teal">MemoryStream</span>(buffer);<br />
               <span style="COLOR: teal">XmlWriterSettings</span> settings
= <span style="COLOR: blue">new</span><span style="COLOR: teal">XmlWriterSettings</span>();<br />
               settings.OmitXmlDeclaration
= <span style="COLOR: blue">true</span>;<br />
               settings.Indent
= <span style="COLOR: blue">true</span>;<br />
               settings.Encoding
= <span style="COLOR: blue">this</span>. textEncoding;<br />
               <span style="COLOR: teal">XmlWriter</span> innerWriter
= <span style="COLOR: teal">XmlWriter</span>.Create(stream, settings);<br />
               <span style="COLOR: teal">XmlDictionaryWriter</span> writer
= <span style="COLOR: teal">XmlDictionaryWriter</span>.CreateDictionaryWriter(innerWriter, <span style="COLOR: blue">false</span>);<br />
               msg.WriteBodyContents(writer);<br />
               writer.Flush();<br />
               retval
= <span style="COLOR: blue">new</span><span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;(buffer,
0, (<span style="COLOR: blue">int</span>)stream.Position);<br />
            }<br />
            <span style="COLOR: blue">else<br /></span>            {<br />
               <span style="COLOR: green">//
If we're rendering raw binary data, we grab at most 'buffer.Length'<br /></span>               <span style="COLOR: green">//
bytes from the binary content of the base64Binary element (if that 
<br /></span>               <span style="COLOR: green">//
exists) and return the result wrapped into an array segment.<br /></span>               <span style="COLOR: teal">XmlDictionaryReader</span> dictReader
= msg.GetReaderAtBodyContents();<br />
               <span style="COLOR: blue">if</span> (dictReader.NodeType
== <span style="COLOR: teal">XmlNodeType</span>.Element &amp;&amp; 
<br />
                  dictReader.LocalName
== <span style="COLOR: maroon">"base64Binary"</span>)<br />
               {<br />
                  <span style="COLOR: blue">if</span> (dictReader.Read()
&amp;&amp; dictReader.NodeType == <span style="COLOR: teal">XmlNodeType</span>.Text)<br />
                  {<br />
                     <span style="COLOR: blue">int</span> size
= dictReader.ReadContentAsBase64(buffer, 0, buffer.Length);<br />
                     retval
= <span style="COLOR: blue">new</span><span style="COLOR: teal">ArraySegment</span>&lt;<span style="COLOR: blue">byte</span>&gt;(buffer,
0, size);<br />
                  }<br />
               }<br />
            }<br />
            <span style="COLOR: blue">return</span> retval;<br />
         }<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Reads
an incoming stream containing a message and<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> wraps
it with a streamed message. The assumption is that the incoming 
<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> data
stream is </span><span style="COLOR: gray">&lt;i&gt;</span><span style="COLOR: green">not</span><span style="COLOR: gray">&lt;/i&gt;</span><span style="COLOR: green"> a
SOAP envelope, but rather an unencapsulated<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> data
item, may it be some raw binary, an XML document or HTML form<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> postback
data. This method is called if the inbound transfer mode of the 
<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> transport
is "streamed".<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="stream"&gt;</span><span style="COLOR: green">Input stream</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="maxSizeOfHeaders"&gt;</span><span style="COLOR: green">Maximum size of headers
in bytes</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Stream
message</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: teal">Message</span> ReadMessage(System.IO.<span style="COLOR: teal">Stream</span> stream, <span style="COLOR: blue">int</span> maxSizeOfHeaders)<br />
      {<br />
         <span style="COLOR: blue">return</span><span style="COLOR: blue">new</span><span style="COLOR: teal">PoxStreamedMessage</span>(stream,
maxSizeOfHeaders);<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Transforms
an incoming message into a stream that a transport can 
<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> literally
put on the wire as it is filled. This method is called if the outbound<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> transfer
mode of the transport is "streamed".<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="msg"&gt;</span><span style="COLOR: green">Input message</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="stream"&gt;</span><span style="COLOR: green">Stream to write to</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> /// </span><span style="COLOR: gray">&lt;remarks&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;para&gt;</span><span style="COLOR: green">This
method is the "secret sauce" of the the PoxEncoder. Instead of encoding the 
<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> message
in its entirety, this encoder will unwrap the message body and toss out<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> the
envelope and all headers. The resulting "raw" message body (everything inside<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> and
not including soap:Body) will be written out to the transport.</span><span style="COLOR: gray">&lt;/para&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;para&gt;</span><span style="COLOR: green">The
encoder has an optional, "out of band" argument that is flowing into it<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> as
part of the message's Properties. By adding a </span><span style="COLOR: gray">&lt;see
cref="PoxEncoderMessageProperty"/&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> to
the </span><span style="COLOR: gray">&lt;see cref="Message.Properties"/&gt;</span><span style="COLOR: green"> and
setting its </span><span style="COLOR: gray">&lt;see cref="PoxEncoderMessageProperty.RawBinary"/&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> property
to 'true', you can switch the encoder into its 'raw binary' mode.</span><span style="COLOR: gray">&lt;/para&gt;</span><span style="COLOR: green"><br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;para&gt;</span><span style="COLOR: green"> In
'raw binary' mode, the encoder expects that the only child of the message<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> body
element is an element with a local name of "base64Binary" containing base64 encoded<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> binary
data. If that is the case, the encoder will read the content of that element<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> and
write it (not the XML wrapper) onto the stream in binary form and in at most 
<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> 1MByte
large chunks. If the content does not comply with this requirement, nothing is written.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/para&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/remarks&gt;<br /></span>        <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: blue">void</span> WriteMessage(<span style="COLOR: teal">Message</span> msg,
System.IO.<span style="COLOR: teal">Stream</span> stream)<br />
        {<br />
            <span style="COLOR: blue">try<br /></span>            {<br />
                <span style="COLOR: blue">if</span> (!msg.IsEmpty)<br />
               
{<br />
                    <span style="COLOR: green">//
check RawBinary bit in the message property<br /></span>                    <span style="COLOR: blue">bool</span> rawBinary
= <span style="COLOR: blue">false</span>;<br />
                    <span style="COLOR: blue">if</span> (msg.Properties.ContainsKey(<span style="COLOR: teal">PoxEncoderMessageProperty</span>.Name))<br />
                   
{<br />
                       
rawBinary = ((<span style="COLOR: teal">PoxEncoderMessageProperty</span>)msg.Properties[<span style="COLOR: teal">PoxEncoderMessageProperty</span>.Name]).RawBinary;<br />
                   
}<br /><br />
                    <span style="COLOR: blue">if</span> (!rawBinary)<br />
                   
{<br />
                        <span style="COLOR: green">//
If we're rendering XML, we layer an XMLDictionaryWriter over the 
<br /></span>                        <span style="COLOR: green">//
output stream and have the message render its body content into<br /></span>                        <span style="COLOR: green">//
that writer and therefore onto the stream.<br /></span>                        <span style="COLOR: teal">XmlWriterSettings</span> settings
= <span style="COLOR: blue">new</span><span style="COLOR: teal">XmlWriterSettings</span>();<br />
              
         settings.OmitXmlDeclaration
= <span style="COLOR: blue">true</span>;<br />
                       
settings.Indent = <span style="COLOR: blue">true</span>;<br />
                       
settings.Encoding = <span style="COLOR: blue">this</span>. textEncoding;<br />
                        <span style="COLOR: teal">XmlWriter</span> innerWriter
= <span style="COLOR: teal">XmlWriter</span>.Create(stream, settings);<br />
                        <span style="COLOR: teal">XmlDictionaryWriter</span> writer
= <span style="COLOR: teal">XmlDictionaryWriter</span>.CreateDictionaryWriter(innerWriter, <span style="COLOR: blue">false</span>);<br />
                       
msg.WriteBodyContents(writer);<br />
                       
writer.Flush();<br />
                   
}<br />
                    <span style="COLOR: blue">else<br /></span>                   
{<br />
                        <span style="COLOR: green">//
If we're rendering raw binary data, we grab chunks of at most 1MByte<br /></span>                        <span style="COLOR: green">//
from the 'base64Binary' content element (if that exists) and write them<br /></span>                        <span style="COLOR: green">//
out as binary data to the output stream. Chunking is done, because we<br /></span>                        <span style="COLOR: green">//
have to assume that the body content is arbitrarily large. To optimize the 
<br /></span>                        <span style="COLOR: green">//
behavior for large streams, we read and write concurrently and swap buffers.<br /></span>                        <span style="COLOR: teal">XmlDictionaryReader</span> dictReader
= msg.GetReaderAtBodyContents();<br />
                        <span style="COLOR: blue">if</span> (dictReader.NodeType
== <span style="COLOR: teal">XmlNodeType</span>.Element &amp;&amp; dictReader.LocalName
== <span style="COLOR: maroon">"base64Binary"</span>)<br />
                       
{<br />
                            <span style="COLOR: blue">if</span> (dictReader.Read()
&amp;&amp; dictReader.NodeType == <span style="COLOR: teal">XmlNodeType</span>.Text)<br />
                           
{<br />
                                <span style="COLOR: blue">byte</span>[]
buffer1 = <span style="COLOR: blue">new</span><span style="COLOR: blue">byte</span>[1024*1024],
buffer2 = <span style="COLOR: blue">new</span><span style="COLOR: blue">byte</span>[1024*1024];<br />
                              
 <span style="COLOR: blue">byte</span>[] readBuffer = buffer1, writeBuffer =
buffer2;<br />
                                
<br />
                                <span style="COLOR: blue">int</span> bytesRead
= 0;<br />
                                <span style="COLOR: green">//
read the first chunk into the read buffer<br /></span>                               
bytesRead = dictReader.ReadContentAsBase64(readBuffer, 0, readBuffer.Length);<br />
                                <span style="COLOR: blue">do<br /></span>                               
{<br />
                                    <span style="COLOR: green">//
the abort condition for the loop is that we can't read<br /></span>                        
           <span style="COLOR: green">//
any more bytes from the input because the base64Binary element is<br /></span>                                    <span style="COLOR: green">//
exhausted.<br /></span>                                    <span style="COLOR: blue">if</span> (bytesRead
&gt; 0 )<br />
                                   
{<br />
                                        <span style="COLOR: green">//
make the last read buffer the write buffer<br /></span>                                       
writeBuffer = readBuffer;<br />
                                        <span style="COLOR: green">//
write the write buffer to the output stream asynchronously<br /></span>                                        <span style="COLOR: teal">IAsyncResult</span> result
= stream.BeginWrite(writeBuffer, 0, bytesRead,<span style="COLOR: blue">null</span>,<span style="COLOR: blue">null</span>);<br />
                                        <span style="COLOR: green">//
swap the read buffer<br /></span>                                       
readBuffer = (readBuffer == buffer1) ? buffer2 : buffer1;<br />
                                        <span style="COLOR: green">//
read a new chunk into the 'other' buffer synchronously<br /></span>                                       
bytesRead = dictReader.ReadContentAsBase64(readBuffer, 0, readBuffer.Length);<br />
                 
                      <span style="COLOR: green">//
wait for the write operation to complete<br /></span>                                       
result.AsyncWaitHandle.WaitOne();<br />
                                       
stream.EndWrite(result);<br />
                                   
}<br />
                                }<br />
                                <span style="COLOR: blue">while</span> (bytesRead
&gt; 0);<br />
                           
}<br />
                       
}<br />
                   
}<br />
               
}<br />
            }<br />
            <span style="COLOR: blue">catch<br /></span>            {<br />
                <span style="COLOR: green">//
the client may disconnect at any time, so that's an expected exception and absorbed.<br /></span>            }<br />
        }<br />
   }<br />
}</span>
                    <span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier">
                      <br />
                      <br />
                    </span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
The encoder shown above fulfills my two requirements and it is aware of the <i>PoxBase64XmlReader</i> trickery.
It renders unencapsulated data onto the wire and accepts and wraps unencapsulated
data from the wire. Furthernore, it supports buffered messages and it supports Indigo’s
streaming mode, which allows sending messages of arbitrary size. What’s still missing
in the picture is how we hook the encoder into the binding and how we can control
whether the encoder works in “POX mode” rending XML or in “Raw Binary” mode rendering
arbitrary data content. I might also have to explain what a <i>PoxStreamedMessage</i> is.
I might also have to explain a bit better what the encoder does to begin with ;-)
</p>
          <p>
Well, at least you have the code already, Part 6 comes with the prose. 
</p>
        </div>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3712ee6b-cd80-4db3-a96c-c740491f588e" />
      </body>
      <title>Teaching Indigo to do REST/POX: Part 5</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx</guid>
      <link>http://vasters.com/clemensv/2005/12/29/Teaching+Indigo+To+Do+RESTPOX+Part+5.aspx</link>
      <pubDate>Thu, 29 Dec 2005 14:53:58 GMT</pubDate>
      <description>&lt;div class=Section1&gt;
&lt;p&gt;
&lt;span lang=DE&gt;&lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx"&gt;&lt;span lang=EN-US&gt;Part
1&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"&gt;&lt;span lang=EN-US&gt;Part
2&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx"&gt;&lt;span lang=EN-US&gt;Part
3&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx"&gt;&lt;span lang=EN-US&gt;Part
4&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;i&gt;POX means “plain old XML” and I’ve also heard a definition saying that “POX is
REST without the dogma”, but that’s not really correct. POX is not really well defined,
but it’s clear that the “plain” is the focus and that means typically that folks who
talk about “POX web services” explicitly mean that those services don’t use SOAP.
You could see POX as an &lt;a href="http://staff.newtelligence.net/clemensv/ct.ashx?id=2d61b97b-3a6e-46bd-89db-b1b20499ba18&amp;amp;url=http%3a%2f%2fdictionary.reference.com%2fsearch%3fq%3dantonym"&gt;&lt;span style="COLOR: windowtext; TEXT-DECORATION: none"&gt;antonym&lt;/span&gt;&lt;/a&gt; for
SOAP.&lt;/i&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
The design of Indigo (WCF) assumes that all messages that go onto the wire and come
from the wire have a shape that is aligned with SOAP. That means that they have a
“body” containing the user-defined message payload and a “header” section that contains
the out-of-band metadata that helps getting the message from one place to the next,
possibly through a chain of intermediaries. Most of the Indigo binding elements and
their implementations also assume that those metadata elements (headers) conform to
their respective WS-* standard that they are dealing with.
&lt;/p&gt;
&lt;p&gt;
However, Indigo isn’t hard-wired to a specific envelope format. The default “encoders”
that are responsible for turning a message into data stream (or a data package) that
a transport can throw down a TCP socket or into a message queue (or whatever else)
and which are likewise responsible for picking up the data from the wire to turn them
into &lt;i&gt;Message&lt;/i&gt; objects have two envelope formats baked in: SOAP 1.1 and SOAP
1.2. But that doesn’t mean that you have to use those. If your envelope format were
different (there seem to be thousands, I’ll name &lt;a href="http://www.adsml.org/"&gt;AdsML&lt;/a&gt; [&lt;a href="http://www.ifra.com/website/adsml.nsf/All/FE5EB7BDE5050A3EC1256CD2005DA5A8/$FILE/AdsML%20Specification%20AS-1%200%20122204.pdf"&gt;spec&lt;/a&gt;]
as an example) and that’s what you want to use on the wire, you can assemble a binding
that will compose an Indigo transport with your encoder. Moving away from SOAP means,
though, that you can’t use the standard implementations of capabilities such as message-level
security, reliable delivery, and transaction flow, because all of these are built
on the assumption that you are exchanging WS-* headers with the other party and all
of these specs depend on the SOAP information model. But if there are comparable specifications
that come with your envelope format you can of course write Indigo extensions that
you can configure into a binding just like you can compose the default binding elements.
It’d be a lot of work to do that, but you’d still benefit greatly from the Indigo
architecture per-se. 
&lt;/p&gt;
&lt;p&gt;
When we want to use a REST/POX model, our envelope format is quite simple: We don’t
really have an envelope.
&lt;/p&gt;
&lt;p&gt;
The idea of POX is that there’s only payload and that out-of-band metadata is unnecessary
fluff. The idea of REST is that there is already and appropriate place for out-of-band
metadata and that’s the HTTP headers.
&lt;/p&gt;
&lt;p&gt;
In order to make REST/POX work, we therefore need to replace the Indigo default encoder
with an encoder that fulfills these requirements:
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
1.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Extract
the message &lt;i&gt;body&lt;/i&gt; XML content of any &lt;b&gt;outbound&lt;/b&gt; message and format it for
the wire as-is and without a SOAP envelope around it and
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
2.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Accept
an arbitrary &lt;b&gt;inbound&lt;/b&gt; XML data and wrap it into a &lt;i&gt;Message&lt;/i&gt;-derived class
so that Indigo can handle it.
&lt;/p&gt;
&lt;p&gt;
Since the use-case in whose context I’ve developed these extensions is a bit more
far reaching than POX, but I indeed want to support RESTful access to any data including
multi-GByte unencapsulated MPEG recordings I make on my Media PC, I’ve broadened these
two requirements a bit and left out the “XML” constraint:
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
1.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Extract
the message &lt;i&gt;body&lt;/i&gt; &lt;s&gt;XML&lt;/s&gt; content of any &lt;b&gt;outbound&lt;/b&gt; message and format
it for the wire as-is and without a SOAP envelope around it and
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
2.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;Accept
an arbitrary &lt;b&gt;inbound&lt;/b&gt; &lt;s&gt;XML&lt;/s&gt; data and wrap it into a &lt;i&gt;Message&lt;/i&gt;-derived
class so that Indigo can handle it.
&lt;/p&gt;
&lt;p&gt;
XML aka POX is an interesting content-type to throw around, but it’s by no means the
only one and therefore let’s not restrict ourselves too much here. Any content is
good.
&lt;/p&gt;
&lt;p&gt;
But then again, Indigo is assuming that all messages flowing through its channels
contain XML payloads and therefore we’ve got a bit of a nut to crack when we want
to use Indigo for arbitrary, non-XML payloads of arbitrary size. Luckily, XML is just
an illusion.
&lt;/p&gt;
&lt;p&gt;
The Indigo &lt;i&gt;Message&lt;/i&gt; holds the message body content inside an &lt;i&gt;XmlDictionaryReader&lt;/i&gt; (which
is an optimized derivation of the well-known &lt;i&gt;XmlReader&lt;/i&gt;). To construct a message,
you can walk up to the static &lt;i&gt;Message.CreateMessage(string action, XmlDictionaryReader
reader) &lt;/i&gt;factory method and pass the readily formatted body content as a reader
object and the message will happily adopt it. But can we use the &lt;i&gt;XmlReader&lt;/i&gt; to
smuggle arbitrary binary content into the message so that our own encoder can later
unwrap it and put it onto the wire in whatever raw binary format we like? Sure we
can! The class below may look a bit like an evil hack, but it’s a perfectly legal
construct:
&lt;/p&gt;
&lt;table class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=1&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;&lt;font size=1&gt;using&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;&lt;font size=1&gt; System;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Text;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Xml;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.IO;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Xml.Schema;&lt;br&gt;
&lt;br&gt;
&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; newtelligence.ServiceModelExtensions&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxBase64XmlStreamReader&lt;/span&gt; : &lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: teal"&gt;XmlTextReader&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;const&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; xmlEnvelopeString
= 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: maroon"&gt;"&amp;lt;base64Binary
xmlns:xsi=\""&lt;/span&gt; + &lt;span style="COLOR: teal"&gt;XmlSchema&lt;/span&gt;.InstanceNamespace
+ &lt;span style="COLOR: maroon"&gt;"\" "&lt;/span&gt; +&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: maroon"&gt;"xmlns:xsd=\""&lt;/span&gt; + &lt;span style="COLOR: teal"&gt;XmlSchema&lt;/span&gt;.Namespace
+ &lt;span style="COLOR: maroon"&gt;"\" "&lt;/span&gt; +&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: maroon"&gt;"xsi:type=\"xsd:base64Binary\"&amp;gt;placeholder&amp;lt;/base64Binary&amp;gt;"&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;Stream&lt;/span&gt; innerStream;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Initializes
a new instance of the &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see cref="T:PoxBase64XmlStreamReader"/&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: green"&gt; class.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="stream"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The stream.&lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; PoxBase64XmlStreamReader(&lt;span style="COLOR: teal"&gt;Stream&lt;/span&gt; stream)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;: &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;(&lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;StringReader&lt;/span&gt;(xmlEnvelopeString))&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;innerStream = stream;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: green"&gt; Gets
The Common Language Runtime (CLR) type for the current node.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;value&amp;gt;&amp;lt;/value&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The
CLR type that corresponds to the typed value of the node. The default is System.String.&lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Type&lt;/span&gt; ValueType&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (NodeType
== &lt;span style="COLOR: teal"&gt;XmlNodeType&lt;/span&gt;.Text &amp;amp;&amp;amp; &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;.Value
== &lt;span style="COLOR: maroon"&gt;"placeholder"&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: teal"&gt;Byte&lt;/span&gt;[]);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: blue"&gt;else&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;.ValueType;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: green"&gt; Gets
the text value of the current node.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; Value&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (NodeType
== &lt;span style="COLOR: teal"&gt;XmlNodeType&lt;/span&gt;.Text &amp;amp;&amp;amp; &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;.Value
== &lt;span style="COLOR: maroon"&gt;"placeholder"&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;BinaryReader&lt;/span&gt; reader
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;BinaryReader&lt;/span&gt;(innerStream);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Convert&lt;/span&gt;.ToBase64String(reader.ReadBytes((&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;)(reader.BaseStream.Length
- reader.BaseStream.Position)));&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;.Value;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: green"&gt; Reads
the content and returns the Base64 decoded binary bytes.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="buffer"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The buffer into which to copy the
resulting text. This value cannot be null.&lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="index"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The offset into the buffer where
to start copying the result.&lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="count"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The maximum number of bytes to copy
into the buffer. The actual number of bytes copied is returned from this method.&lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: green"&gt; The
number of bytes written to the buffer.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; ReadContentAsBase64(&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[]
buffer, &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; index, &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; count)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (NodeType
== &lt;span style="COLOR: teal"&gt;XmlNodeType&lt;/span&gt;.Text &amp;amp;&amp;amp; &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;.Value
== &lt;span style="COLOR: maroon"&gt;"placeholder"&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; innerStream.Read(buffer,
index, count);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font size=1&gt;&lt;span style="COLOR: blue"&gt;else&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;.ReadContentAsBase64(buffer,
index, count);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/font&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
The &lt;i&gt;PoxBase64XmlStreamReader&lt;/i&gt; is a specialized XML reader reading a fixed info-set
constructed from a string that has a “placeholder” in whose place the content of a
wrapped data stream is returned “as base64 encoded content”. Of course that latter
statement is hogwash. The data is never encoded in base64 anywhere. But the consumer
of the reader &lt;i&gt;thinks&lt;/i&gt; that it is and that’s really good enough for us here.
The &lt;i&gt;XmlReader&lt;/i&gt; creates the illusion that the wrapped data stream were the “text”
node of a base64Binary typed element and if that’s what the client wants to believe,
we’re happy. &amp;nbsp;The implementation trick here is of course very simple. As long
as the reader isn’t hitting the text node with the “placeholder” all work is being
delegated to the base class. Once we arrive at that particular node, we change tactics
and return the data type (byte[]) and the content of the wrapped stream instead of
the “placeholder” string. After that we continue delegating to the base class. If
the client asks for the &lt;i&gt;Value&lt;/i&gt; of the text node, we are returning a base64 encoded
string representation of the wrapped stream which might end up being pretty big. However,
if the client is a bit less naïve about the content, it will figure that the data
type is &lt;i&gt;byte[]&lt;/i&gt; and therefore retrieve the data in binary chunks through the &lt;i&gt;ReadContentAsBase64()&lt;/i&gt; method.
Let’s assume that the client will be that clever. 
&lt;/p&gt;
&lt;p&gt;
It doesn’t take too much imagination talent to do so, because I’ve got the client
right here. I used &lt;a href="http://www.douglasp.com/"&gt;Doug Purdy&lt;/a&gt;’s PoxEncoder
that he showed at PDC05 as a basis for this and extended it (quite) a bit:
&lt;/p&gt;
&lt;table class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=1&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 8pt; COLOR: blue; FONT-FAMILY: Courier"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt; System;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.IO;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Xml;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Text;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel.Channels;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel.Design;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Runtime.CompilerServices;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel.Configuration;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Configuration;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Globalization;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Xml.Schema;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Diagnostics;&lt;br&gt;
&lt;br&gt;
&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; newtelligence.ServiceModelExtensions&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; This
class is a wire-format encoder for System.ServiceModel that renders&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; only
the content (body) of a &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see cref="T:Message"/&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; onto
the wire, but not 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; the
surrounding SOAP message elements such as the enevlope, the headers or&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; the
body element. Likewise, the encoder expects input to be in 'raw', unwrapped&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; form
and will wrap it into a message for processing by the System.ServiceModel 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; infrastructure. 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxEncoder&lt;/span&gt; : &lt;span style="COLOR: teal"&gt;MessageEncoder&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; contentType;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; mediaType;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;Encoding&lt;/span&gt; textEncoding;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;MessageVersion&lt;/span&gt; messageVersion;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Creates
a new instance of PoxEncoder&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; PoxEncoder()&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; messageVersion = &lt;span style="COLOR: teal"&gt;MessageVersion&lt;/span&gt;.Soap11Addressing1;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; textEncoding = &lt;span style="COLOR: teal"&gt;Encoding&lt;/span&gt;.UTF8;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Initialize();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Creates
a new instance of PoxEncoder&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="messageVersion"&amp;gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; PoxEncoder(&lt;span style="COLOR: teal"&gt;MessageVersion&lt;/span&gt; messageVersion)&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.
messageVersion = messageVersion;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; textEncoding = &lt;span style="COLOR: teal"&gt;Encoding&lt;/span&gt;.UTF8;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Initialize();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Creates
a new instance of PoxEncoder&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="textEncoding"&amp;gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="messageVersion"&amp;gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; PoxEncoder(&lt;span style="COLOR: teal"&gt;Encoding&lt;/span&gt; textEncoding, &lt;span style="COLOR: teal"&gt;MessageVersion&lt;/span&gt; messageVersion)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.
textEncoding = textEncoding;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.
messageVersion = messageVersion;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Initialize();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Initializes
common properties of the encoder.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Initialize()&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.MessageVersion.Envelope
== &lt;span style="COLOR: teal"&gt;EnvelopeVersion&lt;/span&gt;.Soap12)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
set the aprorpiate media type for SOAP 1.2&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.
mediaType = &lt;span style="COLOR: maroon"&gt;"application/soap+xml"&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;else&lt;/span&gt; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.MessageVersion.Envelope
== &lt;span style="COLOR: teal"&gt;EnvelopeVersion&lt;/span&gt;.Soap11)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
set the appropriate media type for SOAP 1.1&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.
mediaType = &lt;span style="COLOR: maroon"&gt;"text/xml"&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
compose the content type from charset and media type&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.
contentType = &lt;span style="COLOR: blue"&gt;string&lt;/span&gt;.Format(&lt;span style="COLOR: teal"&gt;CultureInfo&lt;/span&gt;.InvariantCulture, &lt;span style="COLOR: maroon"&gt;"{0};
charset={1}"&lt;/span&gt;, mediaType, textEncoding.WebName);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the content type for the encoder instance&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; ContentType&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; contentType;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the media type for the encoder instance&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; MediaType&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; mediaType;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
an indicator for whether a given input content type is 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; supported.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="contentType"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;ContentType&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Indicates
whether the content type is supported&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;remarks&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; TODO:
This currently returns 'true' for all content types because the 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; encoder
isn't locked down in features yet and this easier to debug. 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; The
plan is to support at least: application/x-www-form-urlencoded, 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; text/xml,
application/soap+xml&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/remarks&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; IsContentTypeSupported(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; contentType)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the supported message version of this instance&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MessageVersion&lt;/span&gt; MessageVersion&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; messageVersion;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Reads
an incoming array segment containing a message and&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; wraps
it with a buffered message. The assumption is that the incoming 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; data
stream is &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;i&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;not&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/i&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; a
SOAP envelope, but rather an unencapsulated&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; data
item, may it be some raw binary, an XML document or HTML form&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; postback
data. This method is called if the inbound transfer mode of the 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; transport
is "buffered".&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="buffer"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Buffer to wrap&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="bufferManager"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Buffer manager to help with
allocating a copy&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Buffered
message&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; ReadMessage(&lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;
buffer, &lt;span style="COLOR: teal"&gt;BufferManager&lt;/span&gt; bufferManager)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxBufferedMessage&lt;/span&gt;(buffer,
bufferManager);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Transforms
an incoming message into a raw byte array that a transport can 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; literally
put on the wire as it is returned. This method is called if the outbound&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; transfer
mode of the transport is "buffered".&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="msg"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Input message&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="maxMessageSize"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Maximum message size to
be rendered&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="bufferManager"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Buffer manager to optimize
buffer allocation&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="messageOffset"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Offset into the message
to render.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Array
segment containing the binary data to be put onto the wire by the transport.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;remarks&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;para&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;This
method is the "secret sauce" of the the PoxEncoder. Instead of encoding the 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; message
in its entirety, this encoder will unwrap the message body and toss out&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; the
envelope and all headers. The resulting "raw" message body (everything inside&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; and
not including soap:Body) will be written out to the transport.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/para&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;para&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The
encoder has an optional, "out of band" argument that is flowing into it&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; as
part of the message's Properties. By adding a &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see
cref="T:PoxEncoderMessageProperty"/&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; to
the &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see cref="Message.Properties"/&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; and
setting its &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see cref="PoxEncoderMessageProperty.RawBinary"/&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; property
to 'true', you can switch the encoder into its 'raw binary' mode.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/para&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;para&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; In
'raw binary' mode, the encoder expects that the only child of the message&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; body
element is an element with a local name of "base64Binary" containing base64 encoded&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; binary
data. If that is the case, the encoder will read the content of that element&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; and
return it (not the XML wrapper) to the transport in binary form. If the content does&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; not
comply with this requirement, an empty array is returned.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/para&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/remarks&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;
WriteMessage(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg, &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; maxMessageSize, &lt;span style="COLOR: teal"&gt;BufferManager&lt;/span&gt; bufferManager, &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; messageOffset)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (msg.IsEmpty)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
if the message is empty (no body defined) the result is an empty 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
byte array.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[]
buffer = bufferManager.TakeBuffer(maxMessageSize);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;(buffer,
0, 0);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;else&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: green"&gt;//
check RawBinary bit in the message property&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; rawBinary
= &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (msg.Properties.ContainsKey(&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;.Name))&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;rawBinary
= ((&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;)msg.Properties[&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;.Name]).RawBinary;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;
retval = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[]
buffer = bufferManager.TakeBuffer(maxMessageSize);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (!rawBinary)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
If we're rendering XML data, we construct a memory stream&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
over the output buffer, layer an XMLDictionaryWriter on top of it&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
and have the message write the body content into the buffer as XML.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
The buffer is then wrapped into an array segment and returned.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;MemoryStream&lt;/span&gt; stream
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;MemoryStream&lt;/span&gt;(buffer);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;XmlWriterSettings&lt;/span&gt; settings
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;XmlWriterSettings&lt;/span&gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;settings.OmitXmlDeclaration
= &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;settings.Indent
= &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;settings.Encoding
= &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;. textEncoding;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;XmlWriter&lt;/span&gt; innerWriter
= &lt;span style="COLOR: teal"&gt;XmlWriter&lt;/span&gt;.Create(stream, settings);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;XmlDictionaryWriter&lt;/span&gt; writer
= &lt;span style="COLOR: teal"&gt;XmlDictionaryWriter&lt;/span&gt;.CreateDictionaryWriter(innerWriter, &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;msg.WriteBodyContents(writer);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;writer.Flush();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;retval
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;(buffer,
0, (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt;)stream.Position);&lt;br&gt;
&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;else&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
If we're rendering raw binary data, we grab at most 'buffer.Length'&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
bytes from the binary content of the base64Binary element (if that 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
exists) and return the result wrapped into an array segment.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;XmlDictionaryReader&lt;/span&gt; dictReader
= msg.GetReaderAtBodyContents();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (dictReader.NodeType
== &lt;span style="COLOR: teal"&gt;XmlNodeType&lt;/span&gt;.Element &amp;amp;&amp;amp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;dictReader.LocalName
== &lt;span style="COLOR: maroon"&gt;"base64Binary"&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (dictReader.Read()
&amp;amp;&amp;amp; dictReader.NodeType == &lt;span style="COLOR: teal"&gt;XmlNodeType&lt;/span&gt;.Text)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;int&lt;/span&gt; size
= dictReader.ReadContentAsBase64(buffer, 0, buffer.Length);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;retval
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;ArraySegment&lt;/span&gt;&amp;lt;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;&amp;gt;(buffer,
0, size);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; retval;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Reads
an incoming stream containing a message and&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; wraps
it with a streamed message. The assumption is that the incoming 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; data
stream is &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;i&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;not&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/i&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; a
SOAP envelope, but rather an unencapsulated&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; data
item, may it be some raw binary, an XML document or HTML form&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; postback
data. This method is called if the inbound transfer mode of the 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; transport
is "streamed".&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="stream"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Input stream&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="maxSizeOfHeaders"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Maximum size of headers
in bytes&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Stream
message&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; ReadMessage(System.IO.&lt;span style="COLOR: teal"&gt;Stream&lt;/span&gt; stream, &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; maxSizeOfHeaders)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;PoxStreamedMessage&lt;/span&gt;(stream,
maxSizeOfHeaders);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Transforms
an incoming message into a stream that a transport can 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; literally
put on the wire as it is filled. This method is called if the outbound&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; transfer
mode of the transport is "streamed".&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="msg"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Input message&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="stream"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Stream to write to&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; /// &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;remarks&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;para&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;This
method is the "secret sauce" of the the PoxEncoder. Instead of encoding the 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; message
in its entirety, this encoder will unwrap the message body and toss out&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; the
envelope and all headers. The resulting "raw" message body (everything inside&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; and
not including soap:Body) will be written out to the transport.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/para&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;para&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The
encoder has an optional, "out of band" argument that is flowing into it&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; as
part of the message's Properties. By adding a &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see
cref="PoxEncoderMessageProperty"/&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; to
the &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see cref="Message.Properties"/&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; and
setting its &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see cref="PoxEncoderMessageProperty.RawBinary"/&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; property
to 'true', you can switch the encoder into its 'raw binary' mode.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/para&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;para&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; In
'raw binary' mode, the encoder expects that the only child of the message&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; body
element is an element with a local name of "base64Binary" containing base64 encoded&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; binary
data. If that is the case, the encoder will read the content of that element&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; and
write it (not the XML wrapper) onto the stream in binary form and in at most 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; 1MByte
large chunks. If the content does not comply with this requirement, nothing is written.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/para&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/remarks&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; WriteMessage(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg,
System.IO.&lt;span style="COLOR: teal"&gt;Stream&lt;/span&gt; stream)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;try&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (!msg.IsEmpty)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
check RawBinary bit in the message property&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; rawBinary
= &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (msg.Properties.ContainsKey(&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;.Name))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
rawBinary = ((&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;)msg.Properties[&lt;span style="COLOR: teal"&gt;PoxEncoderMessageProperty&lt;/span&gt;.Name]).RawBinary;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (!rawBinary)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
If we're rendering XML, we layer an XMLDictionaryWriter over the 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
output stream and have the message render its body content into&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
that writer and therefore onto the stream.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;XmlWriterSettings&lt;/span&gt; settings
= &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;XmlWriterSettings&lt;/span&gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;settings.OmitXmlDeclaration
= &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
settings.Indent = &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
settings.Encoding = &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;. textEncoding;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;XmlWriter&lt;/span&gt; innerWriter
= &lt;span style="COLOR: teal"&gt;XmlWriter&lt;/span&gt;.Create(stream, settings);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;XmlDictionaryWriter&lt;/span&gt; writer
= &lt;span style="COLOR: teal"&gt;XmlDictionaryWriter&lt;/span&gt;.CreateDictionaryWriter(innerWriter, &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
msg.WriteBodyContents(writer);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
writer.Flush();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
If we're rendering raw binary data, we grab chunks of at most 1MByte&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
from the 'base64Binary' content element (if that exists) and write them&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
out as binary data to the output stream. Chunking is done, because we&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
have to assume that the body content is arbitrarily large. To optimize the 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
behavior for large streams, we read and write concurrently and swap buffers.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;XmlDictionaryReader&lt;/span&gt; dictReader
= msg.GetReaderAtBodyContents();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (dictReader.NodeType
== &lt;span style="COLOR: teal"&gt;XmlNodeType&lt;/span&gt;.Element &amp;amp;&amp;amp; dictReader.LocalName
== &lt;span style="COLOR: maroon"&gt;"base64Binary"&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (dictReader.Read()
&amp;amp;&amp;amp; dictReader.NodeType == &lt;span style="COLOR: teal"&gt;XmlNodeType&lt;/span&gt;.Text)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[]
buffer1 = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[1024*1024],
buffer2 = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[1024*1024];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&lt;span style="COLOR: blue"&gt;byte&lt;/span&gt;[] readBuffer = buffer1, writeBuffer =
buffer2;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; bytesRead
= 0;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
read the first chunk into the read buffer&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
bytesRead = dictReader.ReadContentAsBase64(readBuffer, 0, readBuffer.Length);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;do&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
the abort condition for the loop is that we can't read&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: green"&gt;//
any more bytes from the input because the base64Binary element is&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
exhausted.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (bytesRead
&amp;gt; 0 )&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
make the last read buffer the write buffer&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
writeBuffer = readBuffer;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
write the write buffer to the output stream asynchronously&lt;br&gt;
&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;IAsyncResult&lt;/span&gt; result
= stream.BeginWrite(writeBuffer, 0, bytesRead,&lt;span style="COLOR: blue"&gt;null&lt;/span&gt;,&lt;span style="COLOR: blue"&gt;null&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
swap the read buffer&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
readBuffer = (readBuffer == buffer1) ? buffer2 : buffer1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
read a new chunk into the 'other' buffer synchronously&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
bytesRead = dictReader.ReadContentAsBase64(readBuffer, 0, readBuffer.Length);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: green"&gt;//
wait for the write operation to complete&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
result.AsyncWaitHandle.WaitOne();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
stream.EndWrite(result);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;while&lt;/span&gt; (bytesRead
&amp;gt; 0);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;catch&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
the client may disconnect at any time, so that's an expected exception and absorbed.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;&lt;span style="FONT-SIZE: 8pt; FONT-FAMILY: Courier"&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
The encoder shown above fulfills my two requirements and it is aware of the &lt;i&gt;PoxBase64XmlReader&lt;/i&gt; trickery.
It renders unencapsulated data onto the wire and accepts and wraps unencapsulated
data from the wire. Furthernore, it supports buffered messages and it supports Indigo’s
streaming mode, which allows sending messages of arbitrary size. What’s still missing
in the picture is how we hook the encoder into the binding and how we can control
whether the encoder works in “POX mode” rending XML or in “Raw Binary” mode rendering
arbitrary data content. I might also have to explain what a &lt;i&gt;PoxStreamedMessage&lt;/i&gt; is.
I might also have to explain a bit better what the encoder does to begin with ;-)
&lt;/p&gt;
&lt;p&gt;
Well, at least you have the code already, Part 6 comes with the prose.&amp;nbsp;
&lt;/p&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3712ee6b-cd80-4db3-a96c-c740491f588e" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=c45eb508-2269-4d0e-a730-dbd9c7d5f882</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=c45eb508-2269-4d0e-a730-dbd9c7d5f882</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <div class="Section1">
          <p>
            <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx">Part
1</a>, <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx">Part
2</a>, <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx">Part
3</a></p>
          <p>
The <i>SuffixFilter</i> that I have shown in Part 3 of this little series interacts
with the Indigo dispatch internals to figure out which endpoint shall receive an incoming
request. If the filter reports <i>true</i> from it’s <i>Match()</i> method, the service
endpoint that owns the particular filter is being picked and its channel gets the
message. But at that point we still don’t know which of the operations on the endpoint’s
contract shall be selected to handle the request.
</p>
          <p>
We’ll take a step back and recap what we have by citing one of the contract declarations
from Part 1:
</p>
          <table class="MsoTableGrid" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="1">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p class="MsoNormal">
                    <span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier">[<span style="COLOR: teal">ServiceContract,
HttpMethodOperationSelector</span>]<br /><span style="COLOR: blue">interface</span><span style="COLOR: teal">IMyApp<br /></span>{<br />
    [<span style="COLOR: teal">OperationContract</span>, <span style="COLOR: teal">HttpMethod</span>(<span style="COLOR: maroon">"GET"</span>,UriSuffix=<span style="COLOR: maroon">"/customers/*"</span>)]<br />
    <span style="COLOR: teal">CustomerInfo</span> GetCustomerInfo();<br />
    [<span style="COLOR: teal">OperationContract</span>, <span style="COLOR: teal">HttpMethod</span>(<span style="COLOR: maroon">"PUT"</span>,
UriSuffix = <span style="COLOR: maroon">"/customers/*"</span>)]<br />
    <span style="COLOR: blue">void</span> UpdateCustomerInfo(<span style="COLOR: teal">CustomerInfo</span> info);<br />
    [<span style="COLOR: teal">OperationContract</span>, <span style="COLOR: teal">HttpMethod</span>(<span style="COLOR: maroon">"DELETE"</span>,
UriSuffix = <span style="COLOR: maroon">"/customers/*"</span>)]<br />
    <span style="COLOR: blue">void</span> DeleteCustomerInfo();<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
If we implement this contract on a class and host the service endpoint for it at,
say, <b><i><span style="COLOR: green">http://www.example.com/myapp</span></i></b><i></i>this
particular endpoint will only accept requests on <b><i><span style="COLOR: green">http://www.example.com/myapp</span><span style="COLOR: maroon">/customers/*</span></i><span style="COLOR: maroon"></span></b>(whereby
‘*’ can really be any string) because our suffix filter that’s being hooked in my
the <i>HttpMethodOperationSelectorAttribute</i> and populated with “/customers/*”
suffix won’t let any other request pass. Only those requests for which a pattern match
can be found when combining an operation’s suffix pattern with the endpoint URI are
positively matched by the suffix filter. For a more complex example I’ll let you peek
at a (shortened) snippet of one the contracts of the TV server I am working on:
</p>
          <table class="MsoTableGrid" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="1">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p>
                    <span style="FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: Courier">///</span>
                    <span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Courier">
                    </span>
                    <span style="FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: Courier">&lt;summary&gt;<br />
///</span>
                    <span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Courier"> Contract
for the channel service<br /></span>
                    <span style="FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: Courier">///</span>
                    <span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Courier">
                    </span>
                    <span style="FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: Courier">&lt;/summary&gt;<br /></span>
                    <span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier">[<span style="COLOR: teal">ServiceContract</span>(Namespace
= <span style="COLOR: teal">Runtime</span>.ChannelServiceNamespaceURI), <span style="COLOR: teal">HttpMethodOperationSelector</span>]<br /><span style="COLOR: blue">public</span><span style="COLOR: blue">interface</span><span style="COLOR: teal">IChannelService<br /></span>{<br />
    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the default RSS for this channel.<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="message"&gt;</span><span style="COLOR: green">Input message.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Reply
message with 'text/xml' RSS content</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>    [<span style="COLOR: teal">OperationContract</span>, <span style="COLOR: teal">HttpMethod</span>(<span style="COLOR: maroon">"GET"</span>)]<br />
    <span style="COLOR: teal">Message</span> GetRss(<span style="COLOR: teal">Message</span> message);<br />
    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the channel logo as a raw binary image with appropriate<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> media
type, typically image/gif, image/jpeg or image/png<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="message"&gt;</span><span style="COLOR: green">Input message.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Reply
message with 'image/*' binary content</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>    [<span style="COLOR: teal">OperationContract</span>, <span style="COLOR: teal">HttpMethod</span>(<span style="COLOR: maroon">"GET"</span>,
UriSuffix = <span style="COLOR: maroon">"/logo"</span>)]<br />
    <span style="COLOR: teal">Message</span> GetLogo(<span style="COLOR: teal">Message</span> message);<br />
    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the RSS for "now", which is typically including 
<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> the
next 12 hours of guide data from the current time<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> onward
and including currently running shows.<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="message"&gt;</span><span style="COLOR: green">Input message.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Reply
message with 'text/xml' </span><span style="COLOR: gray">&lt;a href="http://blogs.law.harvard.edu/tech/rss"&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> RSS
2.0</span><span style="COLOR: gray">&lt;/a&gt;</span><span style="COLOR: green"> content</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>    [<span style="COLOR: teal">OperationContract</span>, <span style="COLOR: teal">HttpMethod</span>(<span style="COLOR: maroon">"GET"</span>,
UriSuffix = <span style="COLOR: maroon">"/now"</span>)]<br />
    <span style="COLOR: teal">Message</span> GetRssForNow(<span style="COLOR: teal">Message</span> message);<br />
    
<br />
    <span style="COLOR: gray">...<br /><br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
an ASX media metadata document containing a reference to<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> the
live TV stream for this channel and a reference to the<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> HTMLView
that provides the UI inside Windows Media Player.<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="message"&gt;</span><span style="COLOR: green">Input message.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Reply
message with 'video/x-ms-asf' </span><span style="COLOR: gray">&lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmplay10/mmp_sdk/asxelement.asp"&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> ASX
3.0</span><span style="COLOR: gray">&lt;/a&gt;</span><span style="COLOR: green"> content.</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>    [<span style="COLOR: teal">OperationContract</span>, <span style="COLOR: teal">HttpMethod</span>(<span style="COLOR: maroon">"GET"</span>,
UriSuffix = <span style="COLOR: maroon">"/media"</span>)]<br />
    <span style="COLOR: teal">Message</span> GetMedia(<span style="COLOR: teal">Message</span> message);<br />
    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
information about the current media session hosted by the provider.<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="message"&gt;</span><span style="COLOR: green">Input message.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Reply
message with 'text/xml' content</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>    [<span style="COLOR: teal">OperationContract</span>, <span style="COLOR: teal">HttpMethod</span>(<span style="COLOR: maroon">"GET"</span>,
UriSuffix = <span style="COLOR: maroon">"/media/session"</span>)]<br />
    <span style="COLOR: teal">Message</span> GetMediaSession(<span style="COLOR: teal">Message</span> message);<br />
    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the "media display envelope". This is an HTML stream that is loaded<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> by
Windows Media Player to render an AJAX UI for accessing this service.<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="message"&gt;</span><span style="COLOR: green">Input message.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Reply
message with 'text/html' content</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>    [<span style="COLOR: teal">OperationContract</span>, <span style="COLOR: teal">HttpMethod</span>(<span style="COLOR: maroon">"GET"</span>,
UriSuffix = <span style="COLOR: maroon">"/media/envelope"</span>)]<br />
    <span style="COLOR: teal">Message</span> GetMediaDisplayEnvelope(<span style="COLOR: teal">Message</span> message);<br />
    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
a media display envelope collateral data element. This method<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> acts
as a web-server and serves up binary files or text files referenced<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> by
the media display envelope. Requests to this endpoint are HTTP GET 
<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> requests
to the service base URL with the suffix '/media/envelope' with an<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> appended
'/' and the file name of the file that is being requested from the<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> service
runtime's 'envelope' directory.<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="message"&gt;</span><span style="COLOR: green">Input message.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Reply
message containing a raw binary file with appropriate media type</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>    [<span style="COLOR: teal">OperationContract</span>, <span style="COLOR: teal">HttpMethod</span>(<span style="COLOR: maroon">"GET"</span>,
UriSuffix = <span style="COLOR: maroon">"/media/envelope/*"</span>)]<br />
    <span style="COLOR: teal">Message</span> GetMediaDisplayEnvelopeCollateral(<span style="COLOR: teal">Message</span> message);<br />
    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> Gets
the detail information for a particular episode 
<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> in
the EPG guide data (linked from RSS) or for a given<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> recording.<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="message"&gt;</span><span style="COLOR: green">Input message.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Reply
message containing 'text/xml' with detail information.</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>    [<span style="COLOR: teal">OperationContract</span>, <span style="COLOR: teal">HttpMethod</span>(<span style="COLOR: maroon">"GET"</span>,
UriSuffix = <span style="COLOR: maroon">"/item/?"</span>)]<br />
    <span style="COLOR: teal">Message</span> GetItemDetail(<span style="COLOR: teal">Message</span> message);<br />
    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> Adds
detail information for a particular episode. Concretely this 
<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> allows
adding a recoding job to the episode data that will cause this 
<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> show
to be recorded.<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="message"&gt;</span><span style="COLOR: green">Input message.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Reply
message with HTTP 200 OK status code</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>    [<span style="COLOR: teal">OperationContract</span>, <span style="COLOR: teal">HttpMethod</span>(<span style="COLOR: maroon">"POST"</span>,
UriSuffix = <span style="COLOR: maroon">"/item/?"</span>)]<br />
    <span style="COLOR: teal">Message</span> PostItemDetail(<span style="COLOR: teal">Message</span> message);<br />
    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> Deletes
some of the item detail information for a particular episode.<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> This
is used to cacnel a recording for the episode. 
<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="message"&gt;</span><span style="COLOR: green">Input message.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Reply
message with HTTP 200 OK status code.</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>    [<span style="COLOR: teal">OperationContract</span>, <span style="COLOR: teal">HttpMethod</span>(<span style="COLOR: maroon">"DELETE"</span>,
UriSuffix = <span style="COLOR: maroon">"/item/?"</span>)]<br />
    <span style="COLOR: teal">Message</span> DeleteItemDetail(<span style="COLOR: teal">Message</span> message);<br />
    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> Method
receiving all unknown messages sent to this endpoint<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="message"&gt;</span><span style="COLOR: green">The message</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;<br /></span>    [<span style="COLOR: teal">OperationContract</span>(Action
= <span style="COLOR: maroon">"*"</span>)]<br />
    <span style="COLOR: teal">Message</span> HandleUnknownMessage(<span style="COLOR: teal">Message</span> message);<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
If you look at the individual operations in the above contract, you’ll see that the
suffix filter would – given a base address of <b><i><span style="COLOR: green">http://www.example.com/TV</span></i></b> –
match requests made on the URIs  <b><i><span style="COLOR: green">http://www.example.com/TV</span><span style="COLOR: maroon">/logo</span></i></b>, <b><i><span style="COLOR: green"> http://www.example.com/TV</span><span style="COLOR: maroon">/now</span></i></b>,
and<b><i><span style="COLOR: green"> http://www.example.com/TV</span><span style="COLOR: maroon">/media</span></i></b> to
name just a few. A special case is the <i>GetRss() </i>operation, which does not have
an explicit suffix defined and therefore causes the suffix filter to match on the
base address. An important aspect of the suffix filter is that it does not consider
the HTTP method (GET, POST). Matching the HTTP method to an operation is the job of
the <i>HttpMethodOperationSelectorBehavior</i>, which acts higher up on the endpoint
level and picks out the exact method that the call is being dispatched to. The filter
is only deciding whether the message is “ours” with respect to the namespace it is
targeting.
</p>
          <p>
The <i>HttpMethodOperationSelectorBehavior</i> is hooked into the service endpoint
by the <i>HttpMethodOperationSelectorAttribute</i>’s implementation of <i>IContractBehavior </i>that
you can look up in <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx">Part
3</a>. In <i>BindDispatch()</i>, the dispatcher’s <i>OperationSelector</i> property
is set to a new instance of our specialized operation selector. An “operation selector”
is a class that takes an incoing request on an endpoint and figures out the proper
operation to dispatch to. The default operation selector in Indigo acts according
to the SOAP dispatch rules that I explained in Part 1 (see “<a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx">Figuring
out a programming model</a>”).
</p>
          <p>
However, in our REST/POX world that we’re building here we do not have a concept of
“SOAP action”, but rather URIs and HTTP methods and therefore the default dispatch
mechanism doesn’t take us very far. Hence, we need to replace the operation selection
algorithm with our own and we do that by implementing <i>IDispatchOperationSelector</i>:
</p>
          <table class="MsoTableGrid" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="1">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p>
                    <span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: Courier">using</span>
                    <span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier"> System;<br /><span style="COLOR: blue">using</span> System.Collections.Generic;<br /><span style="COLOR: blue">using</span> System.Text;<br /><span style="COLOR: blue">using</span> System.Text.RegularExpressions;<br /><span style="COLOR: blue">using</span> System.ServiceModel;<br /><span style="COLOR: blue">using</span> System.ServiceModel.Configuration;<br /><span style="COLOR: blue">using</span> System.ServiceModel.Channels;<br /><br /><span style="COLOR: blue">namespace</span> newtelligence.ServiceModelExtensions<br />
{<br />
    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"><br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>   <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: teal">HttpMethodOperationSelectorBehavior</span> : <span style="COLOR: teal">IDispatchOperationSelector<br /></span>   {<br />
      <span style="COLOR: teal">ContractDescription</span> description;<br />
      <span style="COLOR: teal">IDispatchOperationSelector</span> defaultSelector;<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Initializes
a new instance of the </span><span style="COLOR: gray">&lt;see cref="T:HttpMethodOperationSelectorBehavior"/&gt;</span><span style="COLOR: green"> class.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="description"&gt;</span><span style="COLOR: green">The description.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="defaultSelector"&gt;</span><span style="COLOR: green">The default selector.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>      <span style="COLOR: blue">public</span> HttpMethodOperationSelectorBehavior(<span style="COLOR: teal">ContractDescription</span> description, <span style="COLOR: teal">IDispatchOperationSelector</span> defaultSelector)<br />
      {<br />
         <span style="COLOR: blue">this</span>.description
= description;<br />
         <span style="COLOR: blue">this</span>.defaultSelector
= defaultSelector;<br />
      }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Selects
the operation.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="message"&gt;</span><span style="COLOR: green">The message.</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;<br /></span>      <span style="COLOR: blue">public</span><span style="COLOR: blue">string</span> SelectOperation(<span style="COLOR: blue">ref</span><span style="COLOR: teal">Message</span> message)<br />
      {<br />
         <span style="COLOR: blue">if</span> (message.Properties.ContainsKey(<span style="COLOR: teal">HttpRequestMessageProperty</span>.Name))<br />
         {<br />
             <span style="COLOR: teal">HttpRequestMessageProperty</span> msgProp
= 
<br />
                
message.Properties[<span style="COLOR: teal">HttpRequestMessageProperty</span>.Name] <span style="COLOR: blue">as</span><span style="COLOR: teal">HttpRequestMessageProperty</span>;<br />
             <span style="COLOR: blue">string</span> baseUriPath
= message.Headers.To.AbsolutePath;<br />
             <span style="COLOR: teal">List</span>&lt;<span style="COLOR: teal">OperationDescription</span>&gt;
operationsWithSuffix = <span style="COLOR: blue">new</span><span style="COLOR: teal">List</span>&lt;<span style="COLOR: teal">OperationDescription</span>&gt;();<br /><br />
             <span style="COLOR: green">/*
Check methods with UriSuffix first. For that we first add 
<br />
              * operation
descriptions that have the correct http method into 
<br />
              * a
list and then sort that list by the processing order */<br /></span>             <span style="COLOR: blue">foreach</span> (<span style="COLOR: teal">OperationDescription</span> opDesc <span style="COLOR: blue">in</span> description.Operations)<br />
             {<br />
                 <span style="COLOR: teal">HttpMethodAttribute</span> methodAttribute
= opDesc.Behaviors.Find&lt;<span style="COLOR: teal">HttpMethodAttribute</span>&gt;();<br />
                 <span style="COLOR: blue">if</span> (methodAttribute
!= <span style="COLOR: blue">null</span> &amp;&amp;<br />
                      <span style="COLOR: teal">String</span>.Compare(methodAttribute.Method,
msgProp.Method, <span style="COLOR: blue">true</span>) == 0 &amp;&amp;<br />
                     
methodAttribute.UriSuffix != <span style="COLOR: blue">null</span>)<br />
                
{<br />
                     operationsWithSuffix.Add(opDesc);<br />
                
}<br />
             }<br /><br />
             <span style="COLOR: green">/*<br />
              * We
are sorting the list based on two criteria: 
<br />
              * a)
ProcessingPriority value, and if that's equal:<br />
              * b)
Length of the UriSuffix expression<br />
              */<br /></span>             operationsWithSuffix.Sort(<br />
                 <span style="COLOR: blue">delegate</span>(<span style="COLOR: teal">OperationDescription</span> descA, <span style="COLOR: teal">OperationDescription</span> descB)<br />
                
{<br />
                     <span style="COLOR: teal">HttpMethodAttribute</span> descAAttr
= descA.Behaviors.Find&lt;<span style="COLOR: teal">HttpMethodAttribute</span>&gt;();<br />
                     <span style="COLOR: teal">HttpMethodAttribute</span> descBAttr
= descB.Behaviors.Find&lt;<span style="COLOR: teal">HttpMethodAttribute</span>&gt;();<br />
                     <span style="COLOR: blue">int</span> result
= descAAttr.Priority.CompareTo(descBAttr.Priority);<br />
                     <span style="COLOR: blue">if</span> (result
== 0)<br />
                    
{<br />
                        
result = <span style="COLOR: teal">Math</span>.Sign(descAAttr.UriSuffix.Length - descBAttr.UriSuffix.Length);<br />
                    
}<br />
                     <span style="COLOR: blue">return</span> result;<br />
                 }<br />
             );<br /><br />
             <span style="COLOR: blue">for</span> (<span style="COLOR: blue">int</span> i
= operationsWithSuffix.Count-1; i &gt;= 0; i--)<br />
             {<br />
                 <span style="COLOR: teal">OperationDescription</span> opDesc
= operationsWithSuffix[i];<br />
                 <span style="COLOR: teal">HttpMethodAttribute</span> methodAttribute
= opDesc.Behaviors.Find&lt;<span style="COLOR: teal">HttpMethodAttribute</span>&gt;();<br />
                 <span style="COLOR: green">//
we have a method attribute, the attribute's method value matches<br /></span>                 <span style="COLOR: green">//
the incoming http request and we do have a regex.<br /></span>                 <span style="COLOR: teal">Match</span> match
= methodAttribute.UriSuffixRegex.Match(baseUriPath);<br />
                 <span style="COLOR: blue">if</span> (match
!= <span style="COLOR: blue">null</span> &amp;&amp; match.Success)<br />
                
{<br />
                     <span style="COLOR: blue">return</span> opDesc.Name;<br />
                
}<br />
             }<br />
             
<br /><br />
             <span style="COLOR: green">/*
now check the rest */<br /></span>             <span style="COLOR: blue">foreach</span> (<span style="COLOR: teal">OperationDescription</span> opDesc <span style="COLOR: blue">in</span> description.Operations)<br />
             {<br />
                 <span style="COLOR: teal">HttpMethodAttribute</span> methodAttribute
= opDesc.Behaviors.Find&lt;<span style="COLOR: teal">HttpMethodAttribute</span>&gt;();<br />
                 <span style="COLOR: blue">if</span> (methodAttribute
!= <span style="COLOR: blue">null</span> &amp;&amp; methodAttribute.UriSuffixRegex
== <span style="COLOR: blue">null</span>)<br />
                
{<br />
                     <span style="COLOR: green">//
we have a http method attribute and the method macthes the request<br /></span>                     <span style="COLOR: green">//
method: match<br /></span>                     <span style="COLOR: blue">if</span> (<span style="COLOR: teal">String</span>.Compare(methodAttribute.Method,
msgProp.Method, <span style="COLOR: blue">true</span>) == 0)<br />
                    
{<br />
                         <span style="COLOR: blue">return</span> opDesc.Name;<br />
                    
}<br />
                
}<br />
                 <span style="COLOR: blue">else</span><span style="COLOR: blue">if</span> (<span style="COLOR: teal">String</span>.Compare(opDesc.Name,
msgProp.Method, <span style="COLOR: blue">true</span>) == 0)<br />
                 {<br />
                     <span style="COLOR: green">//
we do not have a http method attribute, but the method name<br /></span>                     <span style="COLOR: green">//
equals the http method.<br /></span>                     <span style="COLOR: blue">return</span> opDesc.Name;<br />
                
}<br />
             }<br /><br />
             <span style="COLOR: green">//
No match so far. Now lets find a wildcard method. 
<br /></span>             <span style="COLOR: blue">foreach</span> (<span style="COLOR: teal">OperationDescription</span> opDesc <span style="COLOR: blue">in</span> description.Operations)<br />
             {<br />
                 <span style="COLOR: blue">if</span> (opDesc.Messages.Count
&gt; 0 &amp;&amp;<br />
                    
opDesc.Messages[0].Action == <span style="COLOR: maroon">"*"</span> &amp;&amp;<br />
                    
opDesc.Messages[0].Direction == <span style="COLOR: teal">TransferDirection</span>.Incoming)<br />
                
{<br />
                     <span style="COLOR: blue">return</span> opDesc.Name;<br />
                
}<br />
             }<br />
         }<br /><br />
            <span style="COLOR: green">//
No match so far, delegate to the default selector if one is present<br /></span>         <span style="COLOR: blue">if</span> (defaultSelector
!= <span style="COLOR: blue">null</span>)<br />
         {<br />
            <span style="COLOR: blue">return</span> defaultSelector.SelectOperation(<span style="COLOR: blue">ref</span> message);<br />
         }<br />
         <span style="COLOR: blue">return</span><span style="COLOR: maroon">""</span>;<br />
      }<br />
   }<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
As you can see, there is only one method: <i>SelectOperation</i>. The method will
only do work on its own if the incoming request is an HTTP request received by Indigo’s
HTTP transport. We can figure this out by looking into the message properties and
looking for the presence of a property with the name <i>HttpRequestMessageProperty.Name. </i>The
presence of this property is required, because that’s the vehicle through which Indigo
gives us access to the HTTP method that was used for the request. What we’re looking
for sits as an instance string property on <i>HttpRequestMessageProperty.Method.</i></p>
          <p>
The algorithm itself is fairly straightforward: 
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
1.<span style="FONT: 7pt 'Times New Roman'">      </span>We
grab all operations whose <i>HttpMethodAttribute</i>.<i>Method</i> property matches
(case-insensitively) the incoming HTTP method string <b><i>and</i></b> which have
a suffix expression and throw them into a list. 
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
2.<span style="FONT: 7pt 'Times New Roman'">      </span>We
sort the list by the priority of the attributes amongst each other. I introduced the
priorities, because I am allowing wildcards here and I want to allow the suffixes <i>/item/detail</i> and <i>/item/*</i> (read:
“anything except detail”) to coexist on the same endpoint, but I need a something
other than method order to specify that the match on the concrete expression should
be done before the wildcard expression. In absence of priorities and/or in the case
of collisions, longer suffixes always trump shorter expressions for matching priority.
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
3.<span style="FONT: 7pt 'Times New Roman'">      </span>We
match the sorted list in reverse order (higher priority is better) and return the
first operation in the list whose suffix expression matches the incoming messages
“To” header (which is the same as the HTTP request URI).
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
4.<span style="FONT: 7pt 'Times New Roman'">      </span>If
we don’t have a match, we proceed to iterate over all operations that do <i>not</i> have
a suffix and see whether we can find a match solely based on the  <i>HttpMethodAttribute</i>.<i>Method</i> value
or, if the <i>HttpMethodAttribute</i> is absent, on the plain method name. (So if
the method just named “Get” and there is no attribute, an HTTP GET request will still
match).
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
5.<span style="FONT: 7pt 'Times New Roman'">      </span>If
we still don’t have a match, we look for the common “all messages without a proper
home” method with an <i>OperationContract.Action</i> value of “*”.
</p>
          <p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in">
6.<span style="FONT: 7pt 'Times New Roman'">      </span>And
as the very last resort we fall back to the default selector if we have been given
one and else we fail out by returning an empty string, which means that there is no
match at at all.
</p>
          <p>
If we find a match, we return a string that’s the same as the name of the method we
want to dispatch to and Indigo will them promptly do the right thing and call the
respective method, either by passing the raw message outright (as in my TV app) or
by breaking up the message body using the <i>XmlFormatter</i> or the <i>XmlSerializer</i> and
passing a typed message or a set of parameters.
</p>
          <p>
Step 4 is noteworthy insofar as that the <i>[HttpMethod]</i> attributes aren’t strictly
necessary. If you name your methods exactly like the HTTP methods they should handle,
the operation selector will figure this out. If that’s what you want, you don’t even
need the <i>[HttpMethodOperationSelector]</i> attribute, if you choose to add that
information in the configuration file instead. To enable that. I’ve built the required
configuration class that you can register in the &lt;behaviorExtensions&gt; and map
to the &lt;behaviors&gt; section of an endpoint’s configuration. The class is very,
very simple:
</p>
          <table class="MsoTableGrid" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="1">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p>
                    <span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: Courier">using</span>
                    <span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier"> System;<br /><span style="COLOR: blue">using</span> System.Collections.Generic;<br /><span style="COLOR: blue">using</span> System.Text;<br /><span style="COLOR: blue">using</span> System.ServiceModel.Configuration;<br /><br /><span style="COLOR: blue">namespace</span> newtelligence.ServiceModelExtensions<br />
{<br />
   <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: teal">HttpMethodOperationSelectorSection</span> : <span style="COLOR: teal">BehaviorExtensionSection<br /></span>   {<br />
      <span style="COLOR: blue">public</span> HttpMethodOperationSelectorSection()<br />
      {<br />
      }<br /><br />
      <span style="COLOR: blue">protected</span><span style="COLOR: blue">override</span><span style="COLOR: blue">object</span> CreateBehavior()<br />
      {<br />
         <span style="COLOR: blue">return</span><span style="COLOR: blue">new</span><span style="COLOR: teal">HttpMethodOperationSelectorAttribute</span>();<br />
      }<br /><br />
      <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: blue">string</span> ConfiguredSectionName<br />
      {<br />
         <span style="COLOR: blue">get<br /></span>         {<br />
            <span style="COLOR: blue">return</span><span style="COLOR: maroon">"httpMethodOperationSelector"</span>;<br />
         }<br />
      }<br />
   }<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
Alright, so where are we? We’ve got dispatch metadata, we’ve got an endpoint dispatch
mechanism and we’ve got an operation dispatch mechanism. Furthermore we have a tool
that conveniently grabs “parameter segments” from the URI and maps them to an out-of-band
collection on the <i>UriArgumentsMessageProperty </i>from where we can conveniently
fetch them inside the service implementation.
</p>
          <p>
What we don’t have is POX. We’re still dealing with SOAP messages here. So the next
step is to modify the wire encoding in a way that we unwrap the content and throw
away the envelope on the way out and that we wrap incoming “raw” data into an envelope
to make Indigo happy with incoming requests. 
</p>
          <p>
That’s plenty of material for Part 5 and beyond. Stay tuned.
</p>
          <p>
            <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx">Go
to Part 5</a>
          </p>
        </div>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=c45eb508-2269-4d0e-a730-dbd9c7d5f882" />
      </body>
      <title>Teaching Indigo to do REST/POX: Part 4</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx</guid>
      <link>http://vasters.com/clemensv/2005/12/28/Teaching+Indigo+To+Do+RESTPOX+Part+4.aspx</link>
      <pubDate>Wed, 28 Dec 2005 19:15:53 GMT</pubDate>
      <description>&lt;div class=Section1&gt;
&lt;p&gt;
&lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx"&gt;Part
1&lt;/a&gt;, &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"&gt;Part
2&lt;/a&gt;, &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx"&gt;Part
3&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The &lt;i&gt;SuffixFilter&lt;/i&gt; that I have shown in Part 3 of this little series interacts
with the Indigo dispatch internals to figure out which endpoint shall receive an incoming
request. If the filter reports &lt;i&gt;true&lt;/i&gt; from it’s &lt;i&gt;Match()&lt;/i&gt; method, the service
endpoint that owns the particular filter is being picked and its channel gets the
message. But at that point we still don’t know which of the operations on the endpoint’s
contract shall be selected to handle the request.
&lt;/p&gt;
&lt;p&gt;
We’ll take a step back and recap what we have by citing one of the contract declarations
from Part 1:
&lt;/p&gt;
&lt;table class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=1&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p class=MsoNormal&gt;
&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;[&lt;span style="COLOR: teal"&gt;ServiceContract,
HttpMethodOperationSelector&lt;/span&gt;]&lt;br&gt;
&lt;span style="COLOR: blue"&gt;interface&lt;/span&gt; &lt;span style="COLOR: teal"&gt;IMyApp&lt;br&gt;
&lt;/span&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"GET"&lt;/span&gt;,UriSuffix=&lt;span style="COLOR: maroon"&gt;"/customers/*"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;CustomerInfo&lt;/span&gt; GetCustomerInfo();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"PUT"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/customers/*"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; UpdateCustomerInfo(&lt;span style="COLOR: teal"&gt;CustomerInfo&lt;/span&gt; info);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"DELETE"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/customers/*"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; DeleteCustomerInfo();&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
If we implement this contract on a class and host the service endpoint for it at,
say, &lt;b&gt;&lt;i&gt;&lt;span style="COLOR: green"&gt;http://www.example.com/myapp&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;&lt;i&gt; &lt;/i&gt;this
particular endpoint will only accept requests on &lt;b&gt;&lt;i&gt;&lt;span style="COLOR: green"&gt;http://www.example.com/myapp&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;/customers/*&lt;/span&gt;&lt;/i&gt;&lt;span style="COLOR: maroon"&gt; &lt;/span&gt;&lt;/b&gt;(whereby
‘*’ can really be any string) because our suffix filter that’s being hooked in my
the &lt;i&gt;HttpMethodOperationSelectorAttribute&lt;/i&gt; and populated with “/customers/*”
suffix won’t let any other request pass. Only those requests for which a pattern match
can be found when combining an operation’s suffix pattern with the endpoint URI are
positively matched by the suffix filter. For a more complex example I’ll let you peek
at a (shortened) snippet of one the contracts of the TV server I am working on:
&lt;/p&gt;
&lt;table class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=1&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: Courier"&gt;///&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Courier"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: Courier"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
///&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Courier"&gt; Contract
for the channel service&lt;br&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: Courier"&gt;///&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: green; FONT-FAMILY: Courier"&gt; &lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; COLOR: gray; FONT-FAMILY: Courier"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier"&gt;[&lt;span style="COLOR: teal"&gt;ServiceContract&lt;/span&gt;(Namespace
= &lt;span style="COLOR: teal"&gt;Runtime&lt;/span&gt;.ChannelServiceNamespaceURI), &lt;span style="COLOR: teal"&gt;HttpMethodOperationSelector&lt;/span&gt;]&lt;br&gt;
&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;interface&lt;/span&gt; &lt;span style="COLOR: teal"&gt;IChannelService&lt;br&gt;
&lt;/span&gt;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the default RSS for this channel.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="message"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Input message.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Reply
message with 'text/xml' RSS content&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"GET"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; GetRss(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; message);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the channel logo as a raw binary image with appropriate&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; media
type, typically image/gif, image/jpeg or image/png&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="message"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Input message.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Reply
message with 'image/*' binary content&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"GET"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/logo"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; GetLogo(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; message);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the RSS for "now", which is typically including 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; the
next 12 hours of guide data from the current time&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; onward
and including currently running shows.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="message"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Input message.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Reply
message with 'text/xml' &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;a href="http://blogs.law.harvard.edu/tech/rss"&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; RSS
2.0&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; content&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"GET"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/now"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; GetRssForNow(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; message);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;...&lt;br&gt;
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
an ASX media metadata document containing a reference to&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; the
live TV stream for this channel and a reference to the&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; HTMLView
that provides the UI inside Windows Media Player.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="message"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Input message.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Reply
message with 'video/x-ms-asf' &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmplay10/mmp_sdk/asxelement.asp"&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; ASX
3.0&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; content.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"GET"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/media"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; GetMedia(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; message);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
information about the current media session hosted by the provider.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="message"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Input message.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Reply
message with 'text/xml' content&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"GET"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/media/session"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; GetMediaSession(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; message);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the "media display envelope". This is an HTML stream that is loaded&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; by
Windows Media Player to render an AJAX UI for accessing this service.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="message"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Input message.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Reply
message with 'text/html' content&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"GET"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/media/envelope"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; GetMediaDisplayEnvelope(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; message);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
a media display envelope collateral data element. This method&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; acts
as a web-server and serves up binary files or text files referenced&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; by
the media display envelope. Requests to this endpoint are HTTP GET 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; requests
to the service base URL with the suffix '/media/envelope' with an&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; appended
'/' and the file name of the file that is being requested from the&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; service
runtime's 'envelope' directory.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="message"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Input message.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Reply
message containing a raw binary file with appropriate media type&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"GET"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/media/envelope/*"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; GetMediaDisplayEnvelopeCollateral(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; message);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Gets
the detail information for a particular episode 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; in
the EPG guide data (linked from RSS) or for a given&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; recording.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="message"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Input message.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Reply
message containing 'text/xml' with detail information.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"GET"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/item/?"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; GetItemDetail(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; message);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Adds
detail information for a particular episode. Concretely this 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; allows
adding a recoding job to the episode data that will cause this 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; show
to be recorded.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="message"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Input message.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Reply
message with HTTP 200 OK status code&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"POST"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/item/?"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; PostItemDetail(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; message);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Deletes
some of the item detail information for a particular episode.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; This
is used to cacnel a recording for the episode. 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="message"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Input message.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Reply
message with HTTP 200 OK status code.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"DELETE"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/item/?"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; DeleteItemDetail(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; message);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Method
receiving all unknown messages sent to this endpoint&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="message"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The message&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;(Action
= &lt;span style="COLOR: maroon"&gt;"*"&lt;/span&gt;)]&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; HandleUnknownMessage(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; message);&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
If you look at the individual operations in the above contract, you’ll see that the
suffix filter would – given a base address of &lt;b&gt;&lt;i&gt;&lt;span style="COLOR: green"&gt;http://www.example.com/TV&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; –
match requests made on the URIs &amp;nbsp;&lt;b&gt;&lt;i&gt;&lt;span style="COLOR: green"&gt;http://www.example.com/TV&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;/logo&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;, &lt;b&gt;&lt;i&gt;&lt;span style="COLOR: green"&gt;&amp;nbsp;http://www.example.com/TV&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;/now&lt;/span&gt;&lt;/i&gt;&lt;/b&gt;,
and&lt;b&gt;&lt;i&gt;&lt;span style="COLOR: green"&gt; http://www.example.com/TV&lt;/span&gt;&lt;span style="COLOR: maroon"&gt;/media&lt;/span&gt;&lt;/i&gt;&lt;/b&gt; to
name just a few. A special case is the &lt;i&gt;GetRss() &lt;/i&gt;operation, which does not have
an explicit suffix defined and therefore causes the suffix filter to match on the
base address. An important aspect of the suffix filter is that it does not consider
the HTTP method (GET, POST). Matching the HTTP method to an operation is the job of
the &lt;i&gt;HttpMethodOperationSelectorBehavior&lt;/i&gt;, which acts higher up on the endpoint
level and picks out the exact method that the call is being dispatched to. The filter
is only deciding whether the message is “ours” with respect to the namespace it is
targeting.
&lt;/p&gt;
&lt;p&gt;
The &lt;i&gt;HttpMethodOperationSelectorBehavior&lt;/i&gt; is hooked into the service endpoint
by the &lt;i&gt;HttpMethodOperationSelectorAttribute&lt;/i&gt;’s implementation of &lt;i&gt;IContractBehavior &lt;/i&gt;that
you can look up in &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx"&gt;Part
3&lt;/a&gt;. In &lt;i&gt;BindDispatch()&lt;/i&gt;, the dispatcher’s &lt;i&gt;OperationSelector&lt;/i&gt; property
is set to a new instance of our specialized operation selector. An “operation selector”
is a class that takes an incoing request on an endpoint and figures out the proper
operation to dispatch to. The default operation selector in Indigo acts according
to the SOAP dispatch rules that I explained in Part 1 (see “&lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx"&gt;Figuring
out a programming model&lt;/a&gt;”).
&lt;/p&gt;
&lt;p&gt;
However, in our REST/POX world that we’re building here we do not have a concept of
“SOAP action”, but rather URIs and HTTP methods and therefore the default dispatch
mechanism doesn’t take us very far. Hence, we need to replace the operation selection
algorithm with our own and we do that by implementing &lt;i&gt;IDispatchOperationSelector&lt;/i&gt;:
&lt;/p&gt;
&lt;table class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=1&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: Courier"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier"&gt; System;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Text;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Text.RegularExpressions;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel.Configuration;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel.Channels;&lt;br&gt;
&lt;br&gt;
&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; newtelligence.ServiceModelExtensions&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;HttpMethodOperationSelectorBehavior&lt;/span&gt; : &lt;span style="COLOR: teal"&gt;IDispatchOperationSelector&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;ContractDescription&lt;/span&gt; description;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;IDispatchOperationSelector&lt;/span&gt; defaultSelector;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Initializes
a new instance of the &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see cref="T:HttpMethodOperationSelectorBehavior"/&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt; class.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="description"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The description.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="defaultSelector"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The default selector.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; HttpMethodOperationSelectorBehavior(&lt;span style="COLOR: teal"&gt;ContractDescription&lt;/span&gt; description, &lt;span style="COLOR: teal"&gt;IDispatchOperationSelector&lt;/span&gt; defaultSelector)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.description
= description;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.defaultSelector
= defaultSelector;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Selects
the operation.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="message"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The message.&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; SelectOperation(&lt;span style="COLOR: blue"&gt;ref&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; message)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (message.Properties.ContainsKey(&lt;span style="COLOR: teal"&gt;HttpRequestMessageProperty&lt;/span&gt;.Name))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;HttpRequestMessageProperty&lt;/span&gt; msgProp
= 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
message.Properties[&lt;span style="COLOR: teal"&gt;HttpRequestMessageProperty&lt;/span&gt;.Name] &lt;span style="COLOR: blue"&gt;as&lt;/span&gt; &lt;span style="COLOR: teal"&gt;HttpRequestMessageProperty&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; baseUriPath
= message.Headers.To.AbsolutePath;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: teal"&gt;OperationDescription&lt;/span&gt;&amp;gt;
operationsWithSuffix = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: teal"&gt;OperationDescription&lt;/span&gt;&amp;gt;();&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;/*
Check methods with UriSuffix first. For that we first add 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * operation
descriptions that have the correct http method into 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * a
list and then sort that list by the processing order */&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;OperationDescription&lt;/span&gt; opDesc &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; description.Operations)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;HttpMethodAttribute&lt;/span&gt; methodAttribute
= opDesc.Behaviors.Find&amp;lt;&lt;span style="COLOR: teal"&gt;HttpMethodAttribute&lt;/span&gt;&amp;gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (methodAttribute
!= &lt;span style="COLOR: blue"&gt;null&lt;/span&gt; &amp;amp;&amp;amp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;String&lt;/span&gt;.Compare(methodAttribute.Method,
msgProp.Method, &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;) == 0 &amp;amp;&amp;amp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
methodAttribute.UriSuffix != &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;operationsWithSuffix.Add(opDesc);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;/*&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * We
are sorting the list based on two criteria: 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * a)
ProcessingPriority value, and if that's equal:&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; * b)
Length of the UriSuffix expression&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; */&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; operationsWithSuffix.Sort(&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;delegate&lt;/span&gt;(&lt;span style="COLOR: teal"&gt;OperationDescription&lt;/span&gt; descA, &lt;span style="COLOR: teal"&gt;OperationDescription&lt;/span&gt; descB)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;HttpMethodAttribute&lt;/span&gt; descAAttr
= descA.Behaviors.Find&amp;lt;&lt;span style="COLOR: teal"&gt;HttpMethodAttribute&lt;/span&gt;&amp;gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;HttpMethodAttribute&lt;/span&gt; descBAttr
= descB.Behaviors.Find&amp;lt;&lt;span style="COLOR: teal"&gt;HttpMethodAttribute&lt;/span&gt;&amp;gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;int&lt;/span&gt; result
= descAAttr.Priority.CompareTo(descBAttr.Priority);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (result
== 0)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
result = &lt;span style="COLOR: teal"&gt;Math&lt;/span&gt;.Sign(descAAttr.UriSuffix.Length - descBAttr.UriSuffix.Length);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; result;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;for&lt;/span&gt; (&lt;span style="COLOR: blue"&gt;int&lt;/span&gt; i
= operationsWithSuffix.Count-1; i &amp;gt;= 0; i--)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;OperationDescription&lt;/span&gt; opDesc
= operationsWithSuffix[i];&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;HttpMethodAttribute&lt;/span&gt; methodAttribute
= opDesc.Behaviors.Find&amp;lt;&lt;span style="COLOR: teal"&gt;HttpMethodAttribute&lt;/span&gt;&amp;gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
we have a method attribute, the attribute's method value matches&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
the incoming http request and we do have a regex.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Match&lt;/span&gt; match
= methodAttribute.UriSuffixRegex.Match(baseUriPath);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (match
!= &lt;span style="COLOR: blue"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; match.Success)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; opDesc.Name;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;/*
now check the rest */&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;OperationDescription&lt;/span&gt; opDesc &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; description.Operations)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;HttpMethodAttribute&lt;/span&gt; methodAttribute
= opDesc.Behaviors.Find&amp;lt;&lt;span style="COLOR: teal"&gt;HttpMethodAttribute&lt;/span&gt;&amp;gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (methodAttribute
!= &lt;span style="COLOR: blue"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; methodAttribute.UriSuffixRegex
== &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
we have a http method attribute and the method macthes the request&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
method: match&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;String&lt;/span&gt;.Compare(methodAttribute.Method,
msgProp.Method, &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;) == 0)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; opDesc.Name;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;/span&gt; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;String&lt;/span&gt;.Compare(opDesc.Name,
msgProp.Method, &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;) == 0)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
we do not have a http method attribute, but the method name&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
equals the http method.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; opDesc.Name;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
No match so far. Now lets find a wildcard method. 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;OperationDescription&lt;/span&gt; opDesc &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; description.Operations)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (opDesc.Messages.Count
&amp;gt; 0 &amp;amp;&amp;amp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
opDesc.Messages[0].Action == &lt;span style="COLOR: maroon"&gt;"*"&lt;/span&gt; &amp;amp;&amp;amp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
opDesc.Messages[0].Direction == &lt;span style="COLOR: teal"&gt;TransferDirection&lt;/span&gt;.Incoming)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; opDesc.Name;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
No match so far, delegate to the default selector if one is present&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (defaultSelector
!= &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; defaultSelector.SelectOperation(&lt;span style="COLOR: blue"&gt;ref&lt;/span&gt; message);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: maroon"&gt;""&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
As you can see, there is only one method: &lt;i&gt;SelectOperation&lt;/i&gt;. The method will
only do work on its own if the incoming request is an HTTP request received by Indigo’s
HTTP transport. We can figure this out by looking into the message properties and
looking for the presence of a property with the name &lt;i&gt;HttpRequestMessageProperty.Name. &lt;/i&gt;The
presence of this property is required, because that’s the vehicle through which Indigo
gives us access to the HTTP method that was used for the request. What we’re looking
for sits as an instance string property on &lt;i&gt;HttpRequestMessageProperty.Method.&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
The algorithm itself is fairly straightforward: 
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
1.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;We
grab all operations whose &lt;i&gt;HttpMethodAttribute&lt;/i&gt;.&lt;i&gt;Method&lt;/i&gt; property matches
(case-insensitively) the incoming HTTP method string &lt;b&gt;&lt;i&gt;and&lt;/i&gt;&lt;/b&gt; which have
a suffix expression and throw them into a list. 
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
2.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;We
sort the list by the priority of the attributes amongst each other. I introduced the
priorities, because I am allowing wildcards here and I want to allow the suffixes &lt;i&gt;/item/detail&lt;/i&gt; and &lt;i&gt;/item/*&lt;/i&gt; (read:
“anything except detail”) to coexist on the same endpoint, but I need a something
other than method order to specify that the match on the concrete expression should
be done before the wildcard expression. In absence of priorities and/or in the case
of collisions, longer suffixes always trump shorter expressions for matching priority.
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
3.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;We
match the sorted list in reverse order (higher priority is better) and return the
first operation in the list whose suffix expression matches the incoming messages
“To” header (which is the same as the HTTP request URI).
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
4.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;If
we don’t have a match, we proceed to iterate over all operations that do &lt;i&gt;not&lt;/i&gt; have
a suffix and see whether we can find a match solely based on the &amp;nbsp;&lt;i&gt;HttpMethodAttribute&lt;/i&gt;.&lt;i&gt;Method&lt;/i&gt; value
or, if the &lt;i&gt;HttpMethodAttribute&lt;/i&gt; is absent, on the plain method name. (So if
the method just named “Get” and there is no attribute, an HTTP GET request will still
match).
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
5.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;If
we still don’t have a match, we look for the common “all messages without a proper
home” method with an &lt;i&gt;OperationContract.Action&lt;/i&gt; value of “*”.
&lt;/p&gt;
&lt;p style="MARGIN-LEFT: 0.5in; TEXT-INDENT: -0.25in"&gt;
6.&lt;span style="FONT: 7pt 'Times New Roman'"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;And
as the very last resort we fall back to the default selector if we have been given
one and else we fail out by returning an empty string, which means that there is no
match at at all.
&lt;/p&gt;
&lt;p&gt;
If we find a match, we return a string that’s the same as the name of the method we
want to dispatch to and Indigo will them promptly do the right thing and call the
respective method, either by passing the raw message outright (as in my TV app) or
by breaking up the message body using the &lt;i&gt;XmlFormatter&lt;/i&gt; or the &lt;i&gt;XmlSerializer&lt;/i&gt; and
passing a typed message or a set of parameters.
&lt;/p&gt;
&lt;p&gt;
Step 4 is noteworthy insofar as that the &lt;i&gt;[HttpMethod]&lt;/i&gt; attributes aren’t strictly
necessary. If you name your methods exactly like the HTTP methods they should handle,
the operation selector will figure this out. If that’s what you want, you don’t even
need the &lt;i&gt;[HttpMethodOperationSelector]&lt;/i&gt; attribute, if you choose to add that
information in the configuration file instead. To enable that. I’ve built the required
configuration class that you can register in the &amp;lt;behaviorExtensions&amp;gt; and map
to the &amp;lt;behaviors&amp;gt; section of an endpoint’s configuration. The class is very,
very simple:
&lt;/p&gt;
&lt;table class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=1&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: Courier"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier"&gt; System;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Text;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel.Configuration;&lt;br&gt;
&lt;br&gt;
&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; newtelligence.ServiceModelExtensions&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;HttpMethodOperationSelectorSection&lt;/span&gt; : &lt;span style="COLOR: teal"&gt;BehaviorExtensionSection&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; HttpMethodOperationSelectorSection()&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="COLOR: blue"&gt;protected&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;object&lt;/span&gt; CreateBehavior()&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;HttpMethodOperationSelectorAttribute&lt;/span&gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; ConfiguredSectionName&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: maroon"&gt;"httpMethodOperationSelector"&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
Alright, so where are we? We’ve got dispatch metadata, we’ve got an endpoint dispatch
mechanism and we’ve got an operation dispatch mechanism. Furthermore we have a tool
that conveniently grabs “parameter segments” from the URI and maps them to an out-of-band
collection on the &lt;i&gt;UriArgumentsMessageProperty &lt;/i&gt;from where we can conveniently
fetch them inside the service implementation.
&lt;/p&gt;
&lt;p&gt;
What we don’t have is POX. We’re still dealing with SOAP messages here. So the next
step is to modify the wire encoding in a way that we unwrap the content and throw
away the envelope on the way out and that we wrap incoming “raw” data into an envelope
to make Indigo happy with incoming requests. 
&lt;/p&gt;
&lt;p&gt;
That’s plenty of material for Part 5 and beyond. Stay tuned.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,3712ee6b-cd80-4db3-a96c-c740491f588e.aspx"&gt;Go
to Part 5&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=c45eb508-2269-4d0e-a730-dbd9c7d5f882" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=3f40268c-dee2-44eb-829a-f621a4d40fbc</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=3f40268c-dee2-44eb-829a-f621a4d40fbc</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <div class="Section1">
          <p>
            <span lang="DE">
              <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx">
                <span lang="EN-US">Part
1</span>
              </a>
            </span>, <span lang="DE"><a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"><span lang="EN-US">Part
2</span></a></span></p>
          <p>
If you’ve read the first two parts of this series, you should know by now (if I’ve
done a reasonable job explaining) about the fundamental concepts of how incoming web
service messages (requests) are typically dispatched to their handler code and also
understand how my Indigo REST/POX extensions are helping to associate the metadata
required for dispatching plain, envelope-less HTTP requests with Indigo service operations
using the <i>HttpMethod</i> attribute and how the <i>HttpMethodParameterInspector</i> breaks
up the URI components into easily consumable, out-of-band parameters that flow into
the service code the <i>UriArgumentsMessageProperty.</i></p>
          <p>
What I have not explained is how the dispatching is actually done. There are two parts
to that story: Dispatching to services on the listener level (which I will cover here)
and dispatching to operations at the endpoint level (which I’ll cover in part 4).
</p>
          <p>
When an HTTP request is received on a namespace that Indigo has registered with HTTP.SYS,
the request is matched against a collection of “address filters”. “Registering a namespace”
means that if you configure a service-endpoint to listen at the endpoint <i>http://www.example.com/foo,</i> the
service-endpoint “owns” that URI. 
</p>
          <p>
What’s noteworthy is that if you have an Indigo/WCF application listening to endpoints
at <i>http://www.example.com/baz</i>, <i>http://www.example.com/foo</i> and <i>http://www.example.com/foo<b>/bar</b>, </i>the
demultiplexing (“demuxing” in short) of the requests is done by Indigo and not by
the network stack. HTTP.SYS will push requests from any registered URI namespace of
the particular application into the “shared” Indigo HTTP transport and leave it up
to Indigo to figure out the right endpoint to dispatch to. And that turns out to be
perfect for our purposes.
</p>
          <p>
Whenever an incoming message needs to be dispatched to an endpoint, the message is
matched against an address filter table. [For the very nosy: The place where it all
happens is in the internal <i>EndpointListenerTable</i> class’s <i>Lookup</i> method,
which you could probably look at if you had the <a href="http://www.aisto.com/roeder/dotnet/">right
tools</a>, but I didn’t say that.] 
</p>
          <p>
By default, the address filter that is used for any “regular” service is the <i><a href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/T_System_ServiceModel_EndpointAddressFilter.asp">EndpointAddressFilter</a></i>,
which reports a match if the incoming message’s “To” addressing header (which is constructed
from the HTTP header information if it’s not immediately contained in the incoming
message) is a match for the registered URI. Whether a match is found is dependent
on the URI’s port and host-name (controllable by the HostNameComparisonMode in the
HTTP binding configuration) and the URIs remaining path, which must be an exact match
for the registered service endpoint URI. Since we want to introduce a slightly different
dispatch scheme that is based on matching not only on the exact endpoint URI’s path
but also on suffixes appended to that URI, we must put a hook into the dispatch mechanism
and extend the default behavior. If a method marked up with <i>[HttpMethod(“GET”,UriSuffix=”/bar”)]</i> and
the endpoint is hosted at <i>http://www.example.com/foo</i>, we want any HTTP GET
request to <i>http://www.example.com/foo/bar</i> to be dispatched to that endpoint
and, subsequently, to that exact method.
</p>
          <p>
To infuse that behavior into Indigo, we need to tell it so. If you take a look at <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx">Part
2</a> and at the service contract declarations that I posted there, you will notice
the <i>HttpMethodOperationSelector</i> attribute alongside the <i>ServiceContract</i> attribute.
That attribute class does the trick:
</p>
          <table class="MsoTableGrid" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="1">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p>
                    <span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: Courier">using</span>
                    <span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier"> System;<br /><span style="COLOR: blue">using</span> System.Collections.Generic;<br /><span style="COLOR: blue">using</span> System.Text;<br /><span style="COLOR: blue">using</span> System.ServiceModel;<br /><br /><span style="COLOR: blue">namespace</span> newtelligence.ServiceModelExtensions<br />
{<br />
   <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: teal">HttpMethodOperationSelectorAttribute</span> : 
<br />
                  <span style="COLOR: teal">Attribute</span>, <span style="COLOR: teal">IContractBehavior</span>, <span style="COLOR: teal">IEndpointBehavior<br /></span>   {<br />
      <span style="COLOR: blue">public</span><span style="COLOR: blue">void</span> BindDispatch(<br />
                <span style="COLOR: teal">ContractDescription</span> description, 
<br />
                <span style="COLOR: teal">IEnumerable</span>&lt;<span style="COLOR: teal">ServiceEndpoint</span>&gt;
endpoints, 
<br />
                <span style="COLOR: teal">DispatchBehavior</span> dispatch, 
<br />
                <span style="COLOR: teal">BindingParameterCollection</span> parameters)<br />
      {<br />
         dispatch.OperationSelector = 
<br />
              <span style="COLOR: blue">new</span><span style="COLOR: teal">HttpMethodOperationSelectorBehavior</span>(description,
dispatch.OperationSelector);<br />
         <span style="COLOR: blue">foreach</span> (<span style="COLOR: teal">ServiceEndpoint</span> se <span style="COLOR: blue">in</span> endpoints)<br />
         {<br />
            <span style="COLOR: blue">if</span> (se.Behaviors.Find&lt;<span style="COLOR: teal">HttpMethodOperationSelectorAttribute</span>&gt;()
== <span style="COLOR: blue">null</span>)<br />
            {<br />
               se.Behaviors.Add(<span style="COLOR: blue">this</span>);<br />
            }<br />
         }<br />
            
<br />
      }<br /><br />
      <span style="COLOR: blue">public</span><span style="COLOR: blue">void</span> BindProxy(<br />
                     <span style="COLOR: teal">ContractDescription</span> description, 
<br />
                     <span style="COLOR: teal">ServiceEndpoint</span> endpoint, 
<br />
                     <span style="COLOR: teal">ProxyBehavior</span> proxy, 
<br />
                     <span style="COLOR: teal">BindingParameterCollection</span> parameters)<br />
      {<br /><br />
      }<br /><br />
      <span style="COLOR: blue">public</span><span style="COLOR: blue">bool</span> IsApplicableToContract(<span style="COLOR: teal">Type</span> contractType)<br />
      {<br />
         <span style="COLOR: blue">return</span><span style="COLOR: blue">true</span>;<br />
      }<br /><br />
      <span style="COLOR: blue">public</span><span style="COLOR: blue">void</span> BindServiceEndpoint(<br />
                     <span style="COLOR: teal">ServiceEndpoint</span> serviceEndpoint, 
<br />
                     <span style="COLOR: teal">EndpointListener</span> endpointListener, 
<br />
                     <span style="COLOR: teal">BindingParameterCollection</span> parameters)<br />
      {<br />
            <span style="COLOR: teal">SuffixFilter</span> suffixFilter
= <span style="COLOR: blue">null</span>;<br /><br />
            <span style="COLOR: blue">if</span> (endpointListener.AddressFilter
== <span style="COLOR: blue">null</span> || 
<br />
              
 !(endpointListener.AddressFilter <span style="COLOR: blue">is</span><span style="COLOR: teal">SuffixFilter</span>))<br />
            {<br />
               
suffixFilter = <span style="COLOR: blue">new</span><span style="COLOR: teal">SuffixFilter</span>(endpointListener,
endpointListener.AddressFilter);<br />
               
endpointListener.AddressFilter = suffixFilter;<br />
               
((<span style="COLOR: teal">Dispatcher</span>)endpointListener.Dispatcher).Filter
= suffixFilter;<br />
            }<br />
            <span style="COLOR: blue">else<br /></span>            {<br />
               
suffixFilter = endpointListener.AddressFilter <span style="COLOR: blue">as</span><span style="COLOR: teal">SuffixFilter</span>;<br />
            }<br /><br />
         <span style="COLOR: blue">foreach</span> (<span style="COLOR: teal">OperationDescription</span> opDesc <span style="COLOR: blue">in</span> serviceEndpoint.Contract.Operations)<br />
         {<br />
            <span style="COLOR: teal">HttpMethodAttribute</span> methodAttribute
= opDesc.Behaviors.Find&lt;<span style="COLOR: teal">HttpMethodAttribute</span>&gt;();<br />
            <span style="COLOR: blue">if</span> (methodAttribute
!= <span style="COLOR: blue">null</span>)<br />
            {<br />
               <span style="COLOR: blue">if</span> (methodAttribute.UriSuffixRegex
!= <span style="COLOR: blue">null</span>)<br />
               {<br />
                  suffixFilter.AddSuffix(methodAttribute.UriSuffixRegex);<br />
               }<br />
            }<br />
         }<br />
      }<br />
   }<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
            <br />
In the attribute’s implementation of <i>IEndpointBehavior</i>.<i>BindServiceEndpoint</i>,
which is invoked by Indigo as the endpoint is initialized (in response to <i>ServiceHost.Open()</i> ),
we replace the service’s default endpoint filter with our own <i>SuffixFilter</i> class.
Once we’ve done that, we iterate over the <i>HttpMethodAttribute</i> metadata elements
that sit on the individual operations/methods in the contract description (this is
the actual reason we put them there, see <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx">Part
2</a>) and add any suffix we find to the filter’s suffix table. We’ll get back to
this class in the next part while to investigate how the “operation selector” is hooked
in; let’s investigate the suffix filter first. 
</p>
          <table class="MsoTableGrid" style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing="0" cellpadding="0" width="100%" border="1">
            <tbody>
              <tr>
                <td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign="top" width="100%">
                  <p>
                    <span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: Courier">using</span>
                    <span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier"> System;<br /><span style="COLOR: blue">using</span> System.Collections.Generic;<br /><span style="COLOR: blue">using</span> System.Text;<br /><span style="COLOR: blue">using</span> System.Text.RegularExpressions;<br /><span style="COLOR: blue">using</span> System.ServiceModel;<br /><span style="COLOR: blue">using</span> System.ServiceModel.Configuration;<br /><span style="COLOR: blue">using</span> System.ServiceModel.Channels;<br /><br /><span style="COLOR: blue">namespace</span> newtelligence.ServiceModelExtensions<br />
{<br />
    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> This
class implements a specialized ServiceModel address filter<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> that
allows matching URL suffixes.<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;remarks&gt;<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"> The
class aggregates an EndpointAddressFilter to helpi with the matching logic. 
<br /></span>    <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/remarks&gt;<br /></span>    <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: teal">SuffixFilter</span> : <span style="COLOR: teal">Filter<br /></span>    {<br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> List
for the suffixes. 
<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: teal">List</span>&lt;<span style="COLOR: teal">Regex</span>&gt;
suffixes;<br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Original
filter that we delegate to if we can't match with this<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> one.<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: teal">Filter</span> originalFilter;<br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> The
endpoint listener that this filter is applied to<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: teal">EndpointListener</span> endpointListener;<br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> The
aggregated endpoint address filter<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: teal">EndpointAddressFilter</span> addressFilter;<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Creates
a new instance of SuffixFilter<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="endpointListener"&gt;</span><span style="COLOR: green">EndpointListener this
filter is attached to</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="originalFilter"&gt;</span><span style="COLOR: green">Original AddressFilter
of the EndpointListener</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: blue">public</span> SuffixFilter(<span style="COLOR: teal">EndpointListener</span> endpointListener, <span style="COLOR: teal">Filter</span> originalFilter)<br />
        {<br />
            <span style="COLOR: blue">this</span>.
suffixes = <span style="COLOR: blue">new</span><span style="COLOR: teal">List</span>&lt;<span style="COLOR: teal">Regex</span>&gt;();<br />
            <span style="COLOR: blue">this</span>.
originalFilter = originalFilter;<br />
            <span style="COLOR: blue">this</span>.
endpointListener = endpointListener;<br />
        }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Implements
the matching logic<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="message"&gt;</span><span style="COLOR: green">Message that shall be matched</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;</span><span style="COLOR: green">Returns
an indicator for whether the message is considered a match</span><span style="COLOR: gray">&lt;/returns&gt;<br /></span>        <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: blue">bool</span> Match(<span style="COLOR: teal">Message</span> message)<br />
        {<br />
            <span style="COLOR: green">//
Workaround for Nov2006 CTP bug. GetEndpointAddress() cannot be 
<br /></span>            <span style="COLOR: green">//
called on an EndpointListener before the listener is running.<br /></span>            <span style="COLOR: blue">if</span> (
addressFilter == <span style="COLOR: blue">null</span>)<br />
            {<br />
               
addressFilter = <span style="COLOR: blue">new</span><span style="COLOR: teal">EndpointAddressFilter</span>(
endpointListener.GetEndpointAddress(), <span style="COLOR: blue">false</span>);<br />
            }<br /><br />
            <span style="COLOR: green">//
check whether we have an immediate match, which means that the message's<br /></span>            <span style="COLOR: green">//
To Header is an excat match for the EndpointListener's address<br /></span>            <span style="COLOR: blue">if</span> (
addressFilter.Match(message))<br />
            {<br />
                <span style="COLOR: blue">return</span><span style="COLOR: blue">true</span>;<br />
            }<br />
            <span style="COLOR: blue">else<br /></span>            {<br />
                <span style="COLOR: green">//
no direct match. Save the original header value and chop off the 
<br /></span>                <span style="COLOR: green">//
query portion of the URI.<br /></span>                <span style="COLOR: teal">Uri</span> originalTo
= message.Headers.To;<br />
                <span style="COLOR: blue">string</span> baseUriPath
= originalTo.AbsolutePath;<br />
                <span style="COLOR: blue">string</span> baseUriRoot
= originalTo.GetLeftPart(<span style="COLOR: teal">UriPartial</span>.Authority);<br /><br />
                <span style="COLOR: green">//
match against the suffix list<br /></span>                <span style="COLOR: blue">foreach</span> (<span style="COLOR: teal">Regex</span> suffixExpression <span style="COLOR: blue">in</span> suffixes)<br />
               
{<br />
                    <span style="COLOR: teal">Match</span> match
= suffixExpression.Match(baseUriPath);<br />
                    <span style="COLOR: blue">if</span> (match
!= <span style="COLOR: blue">null</span> &amp;&amp; match.Success)<br />
                   
{<br />
                        <span style="COLOR: blue">string</span> filterUri
= baseUriRoot+baseUriPath.Remove(baseUriPath.LastIndexOf(match.Value));<br />
              
         message.Headers.To = <span style="COLOR: blue">new</span><span style="COLOR: teal">Uri</span>(filterUri);<br />
                        <span style="COLOR: blue">if</span> (
addressFilter.Match(message))<br />
                       
{<br />
                           
message.Headers.To = originalTo;<br />
                            <span style="COLOR: blue">return</span><span style="COLOR: blue">true</span>;<br />
                  
     }<br />
                       
message.Headers.To = originalTo;<br />
                   
}                        
<br />
               
}<br />
            }<br />
            <span style="COLOR: blue">if</span> (
originalFilter != <span style="COLOR: blue">null</span>)<br />
            {<br />
                <span style="COLOR: green">//
of no match has been found up to here, we match against the 
<br /></span>                <span style="COLOR: green">//
original filter if that was provided.<br /></span>                <span style="COLOR: blue">return</span> originalFilter.Match(message);<br />
            }<br />
            <span style="COLOR: blue">return</span><span style="COLOR: blue">false</span>;<br />
        }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Implements
the matching logic by constructing a Message over<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> a
MessageBuffer and delegating to the Match(Message) overload<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="buffer"&gt;&lt;/param&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;returns&gt;&lt;/returns&gt;<br /></span>        <span style="COLOR: blue">public</span><span style="COLOR: blue">override</span><span style="COLOR: blue">bool</span> Match(<span style="COLOR: teal">MessageBuffer</span> buffer)<br />
        {<br />
            <span style="COLOR: teal">Message</span> msg
= buffer.CreateMessage();<br />
            <span style="COLOR: blue">bool</span> result
= Match(msg);<br />
            msg.Close();<br />
            <span style="COLOR: blue">return</span> result;<br />
        }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Adds
a new suffix to the suffix table<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="suffix"&gt;</span><span style="COLOR: green">Suffix value</span><span style="COLOR: gray">&lt;/param&gt;<br /></span>        <span style="COLOR: blue">public</span><span style="COLOR: blue">void</span> AddSuffix(<span style="COLOR: teal">Regex</span> suffix)<br />
        {<br />
            suffixes.Add(suffix);<br />
        }<br /><br />
        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"> Removes
a suffix from the suffix table<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;/summary&gt;<br /></span>        <span style="COLOR: gray">///</span><span style="COLOR: green"></span><span style="COLOR: gray">&lt;param
name="suffix"&gt;&lt;/param&gt;<br /></span>        <span style="COLOR: blue">public</span><span style="COLOR: blue">void</span> RemoveSuffix(<span style="COLOR: teal">Regex</span> suffix)<br />
        {<br />
            suffixes.Remove(suffix);<br />
        }<br />
    }<br />
}</span>
                  </p>
                </td>
              </tr>
            </tbody>
          </table>
          <p>
            <span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier">
              <br />
            </span>The filter’s filet piece is in the <i>Match</i> method. To finally figure out
whether a message is a match, we employ the matching logic of the default <i>EndpointAddressFilter</i>,
which deals with matching the host names and the “base URI” at which the service was
registered. What the suffix filter does in addition is to match the suffix regex pattern
against the incoming message’s “To” header and if that is a match, the suffix is stripped
and the remaining URI is matched against the aggregated <i>EndpointAddressFilter</i>.
Only if we get a match for the suffix and for the remainder URI, we’ll report a positive
match back to the infrastructure by returning <i>true.</i> And in that case and only
in that case the service endpoint for which “this” suffix filter was installed and
populated gets the request.
</p>
          <p>
For each incoming request, Indigo goes through all registered endpoint address filters
and asks them whether they want to service it. And that really means “all”. Indigo
will refuse to service the request if two or more filters report ownership of the
respective request and will throw a traceable (using Indigo tracing) internal exception
that will cause none of the services to be picked due to this ambiguity. In the case
of overlapping dispatch namespaces, none is indeed better than “any random”.
</p>
          <p>
Next part: <i>HttpMethodOperationSelectorBehavior</i></p>
          <p>
            <a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx">Go
to Part 4</a>
          </p>
        </div>
        <img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3f40268c-dee2-44eb-829a-f621a4d40fbc" />
      </body>
      <title>Teaching Indigo to do REST/POX: Part 3</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx</guid>
      <link>http://vasters.com/clemensv/2005/12/27/Teaching+Indigo+To+Do+RESTPOX+Part+3.aspx</link>
      <pubDate>Tue, 27 Dec 2005 18:20:50 GMT</pubDate>
      <description>&lt;div class=Section1&gt;
&lt;p&gt;
&lt;span lang=DE&gt;&lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx"&gt;&lt;span lang=EN-US&gt;Part
1&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;, &lt;span lang=DE&gt;&lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"&gt;&lt;span lang=EN-US&gt;Part
2&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
If you’ve read the first two parts of this series, you should know by now (if I’ve
done a reasonable job explaining) about the fundamental concepts of how incoming web
service messages (requests) are typically dispatched to their handler code and also
understand how my Indigo REST/POX extensions are helping to associate the metadata
required for dispatching plain, envelope-less HTTP requests with Indigo service operations
using the &lt;i&gt;HttpMethod&lt;/i&gt; attribute and how the &lt;i&gt;HttpMethodParameterInspector&lt;/i&gt; breaks
up the URI components into easily consumable, out-of-band parameters that flow into
the service code the &lt;i&gt;UriArgumentsMessageProperty.&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
What I have not explained is how the dispatching is actually done. There are two parts
to that story: Dispatching to services on the listener level (which I will cover here)
and dispatching to operations at the endpoint level (which I’ll cover in part 4).
&lt;/p&gt;
&lt;p&gt;
When an HTTP request is received on a namespace that Indigo has registered with HTTP.SYS,
the request is matched against a collection of “address filters”. “Registering a namespace”
means that if you configure a service-endpoint to listen at the endpoint &lt;i&gt;http://www.example.com/foo,&lt;/i&gt; the
service-endpoint “owns” that URI. 
&lt;/p&gt;
&lt;p&gt;
What’s noteworthy is that if you have an Indigo/WCF application listening to endpoints
at &lt;i&gt;http://www.example.com/baz&lt;/i&gt;, &lt;i&gt;http://www.example.com/foo&lt;/i&gt; and &lt;i&gt;http://www.example.com/foo&lt;b&gt;/bar&lt;/b&gt;, &lt;/i&gt;the
demultiplexing (“demuxing” in short) of the requests is done by Indigo and not by
the network stack. HTTP.SYS will push requests from any registered URI namespace of
the particular application into the “shared” Indigo HTTP transport and leave it up
to Indigo to figure out the right endpoint to dispatch to. And that turns out to be
perfect for our purposes.
&lt;/p&gt;
&lt;p&gt;
Whenever an incoming message needs to be dispatched to an endpoint, the message is
matched against an address filter table. [For the very nosy: The place where it all
happens is in the internal &lt;i&gt;EndpointListenerTable&lt;/i&gt; class’s &lt;i&gt;Lookup&lt;/i&gt; method,
which you could probably look at if you had the &lt;a href="http://www.aisto.com/roeder/dotnet/"&gt;right
tools&lt;/a&gt;, but I didn’t say that.] 
&lt;/p&gt;
&lt;p&gt;
By default, the address filter that is used for any “regular” service is the &lt;i&gt;&lt;a href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/T_System_ServiceModel_EndpointAddressFilter.asp"&gt;EndpointAddressFilter&lt;/a&gt;&lt;/i&gt;,
which reports a match if the incoming message’s “To” addressing header (which is constructed
from the HTTP header information if it’s not immediately contained in the incoming
message) is a match for the registered URI. Whether a match is found is dependent
on the URI’s port and host-name (controllable by the HostNameComparisonMode in the
HTTP binding configuration) and the URIs remaining path, which must be an exact match
for the registered service endpoint URI. Since we want to introduce a slightly different
dispatch scheme that is based on matching not only on the exact endpoint URI’s path
but also on suffixes appended to that URI, we must put a hook into the dispatch mechanism
and extend the default behavior. If a method marked up with &lt;i&gt;[HttpMethod(“GET”,UriSuffix=”/bar”)]&lt;/i&gt; and
the endpoint is hosted at &lt;i&gt;http://www.example.com/foo&lt;/i&gt;, we want any HTTP GET
request to &lt;i&gt;http://www.example.com/foo/bar&lt;/i&gt; to be dispatched to that endpoint
and, subsequently, to that exact method.
&lt;/p&gt;
&lt;p&gt;
To infuse that behavior into Indigo, we need to tell it so. If you take a look at &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"&gt;Part
2&lt;/a&gt; and at the service contract declarations that I posted there, you will notice
the &lt;i&gt;HttpMethodOperationSelector&lt;/i&gt; attribute alongside the &lt;i&gt;ServiceContract&lt;/i&gt; attribute.
That attribute class does the trick:
&lt;/p&gt;
&lt;table class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=1&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: Courier"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier"&gt; System;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Text;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel;&lt;br&gt;
&lt;br&gt;
&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; newtelligence.ServiceModelExtensions&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;HttpMethodOperationSelectorAttribute&lt;/span&gt; : 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Attribute&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;IContractBehavior&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;IEndpointBehavior&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; BindDispatch(&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;ContractDescription&lt;/span&gt; description, 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;IEnumerable&lt;/span&gt;&amp;lt;&lt;span style="COLOR: teal"&gt;ServiceEndpoint&lt;/span&gt;&amp;gt;
endpoints, 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;DispatchBehavior&lt;/span&gt; dispatch, 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;BindingParameterCollection&lt;/span&gt; parameters)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; dispatch.OperationSelector = 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;HttpMethodOperationSelectorBehavior&lt;/span&gt;(description,
dispatch.OperationSelector);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;ServiceEndpoint&lt;/span&gt; se &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; endpoints)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (se.Behaviors.Find&amp;lt;&lt;span style="COLOR: teal"&gt;HttpMethodOperationSelectorAttribute&lt;/span&gt;&amp;gt;()
== &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;se.Behaviors.Add(&lt;span style="COLOR: blue"&gt;this&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; BindProxy(&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;ContractDescription&lt;/span&gt; description, 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;ServiceEndpoint&lt;/span&gt; endpoint, 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;ProxyBehavior&lt;/span&gt; proxy, 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;BindingParameterCollection&lt;/span&gt; parameters)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; IsApplicableToContract(&lt;span style="COLOR: teal"&gt;Type&lt;/span&gt; contractType)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; BindServiceEndpoint(&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;ServiceEndpoint&lt;/span&gt; serviceEndpoint, 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;EndpointListener&lt;/span&gt; endpointListener, 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;BindingParameterCollection&lt;/span&gt; parameters)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;SuffixFilter&lt;/span&gt; suffixFilter
= &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (endpointListener.AddressFilter
== &lt;span style="COLOR: blue"&gt;null&lt;/span&gt; || 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;!(endpointListener.AddressFilter &lt;span style="COLOR: blue"&gt;is&lt;/span&gt; &lt;span style="COLOR: teal"&gt;SuffixFilter&lt;/span&gt;))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
suffixFilter = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;SuffixFilter&lt;/span&gt;(endpointListener,
endpointListener.AddressFilter);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
endpointListener.AddressFilter = suffixFilter;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
((&lt;span style="COLOR: teal"&gt;Dispatcher&lt;/span&gt;)endpointListener.Dispatcher).Filter
= suffixFilter;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
suffixFilter = endpointListener.AddressFilter &lt;span style="COLOR: blue"&gt;as&lt;/span&gt; &lt;span style="COLOR: teal"&gt;SuffixFilter&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;OperationDescription&lt;/span&gt; opDesc &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; serviceEndpoint.Contract.Operations)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: teal"&gt;HttpMethodAttribute&lt;/span&gt; methodAttribute
= opDesc.Behaviors.Find&amp;lt;&lt;span style="COLOR: teal"&gt;HttpMethodAttribute&lt;/span&gt;&amp;gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (methodAttribute
!= &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (methodAttribute.UriSuffixRegex
!= &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;suffixFilter.AddSuffix(methodAttribute.UriSuffixRegex);&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
&lt;br&gt;
In the attribute’s implementation of &lt;i&gt;IEndpointBehavior&lt;/i&gt;.&lt;i&gt;BindServiceEndpoint&lt;/i&gt;,
which is invoked by Indigo as the endpoint is initialized (in response to &lt;i&gt;ServiceHost.Open()&lt;/i&gt; ),
we replace the service’s default endpoint filter with our own &lt;i&gt;SuffixFilter&lt;/i&gt; class.
Once we’ve done that, we iterate over the &lt;i&gt;HttpMethodAttribute&lt;/i&gt; metadata elements
that sit on the individual operations/methods in the contract description (this is
the actual reason we put them there, see &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx"&gt;Part
2&lt;/a&gt;) and add any suffix we find to the filter’s suffix table. We’ll get back to
this class in the next part while to investigate how the “operation selector” is hooked
in; let’s investigate the suffix filter first. 
&lt;/p&gt;
&lt;table class=MsoTableGrid style="BORDER-RIGHT: medium none; BORDER-TOP: medium none; BACKGROUND: #f3f3f3; BORDER-LEFT: medium none; WIDTH: 100%; BORDER-BOTTOM: medium none; BORDER-COLLAPSE: collapse" cellspacing=0 cellpadding=0 width="100%" border=1&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; WIDTH: 100%; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid" valign=top width="100%"&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: Courier"&gt;using&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier"&gt; System;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Text;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Text.RegularExpressions;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel.Configuration;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel.Channels;&lt;br&gt;
&lt;br&gt;
&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; newtelligence.ServiceModelExtensions&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; This
class implements a specialized ServiceModel address filter&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; that
allows matching URL suffixes.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;remarks&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; The
class aggregates an EndpointAddressFilter to helpi with the matching logic. 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/remarks&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;SuffixFilter&lt;/span&gt; : &lt;span style="COLOR: teal"&gt;Filter&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; List
for the suffixes. 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: teal"&gt;Regex&lt;/span&gt;&amp;gt;
suffixes;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Original
filter that we delegate to if we can't match with this&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; one.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Filter&lt;/span&gt; originalFilter;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; The
endpoint listener that this filter is applied to&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;EndpointListener&lt;/span&gt; endpointListener;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; The
aggregated endpoint address filter&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;EndpointAddressFilter&lt;/span&gt; addressFilter;&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Creates
a new instance of SuffixFilter&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="endpointListener"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;EndpointListener this
filter is attached to&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="originalFilter"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Original AddressFilter
of the EndpointListener&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; SuffixFilter(&lt;span style="COLOR: teal"&gt;EndpointListener&lt;/span&gt; endpointListener, &lt;span style="COLOR: teal"&gt;Filter&lt;/span&gt; originalFilter)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.
suffixes = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: teal"&gt;Regex&lt;/span&gt;&amp;gt;();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.
originalFilter = originalFilter;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;this&lt;/span&gt;.
endpointListener = endpointListener;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Implements
the matching logic&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="message"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Message that shall be matched&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Returns
an indicator for whether the message is considered a match&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; Match(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; message)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
Workaround for Nov2006 CTP bug. GetEndpointAddress() cannot be 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
called on an EndpointListener before the listener is running.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (
addressFilter == &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
addressFilter = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;EndpointAddressFilter&lt;/span&gt;(
endpointListener.GetEndpointAddress(), &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
check whether we have an immediate match, which means that the message's&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
To Header is an excat match for the EndpointListener's address&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (
addressFilter.Match(message))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;else&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
no direct match. Save the original header value and chop off the 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
query portion of the URI.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Uri&lt;/span&gt; originalTo
= message.Headers.To;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; baseUriPath
= originalTo.AbsolutePath;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; baseUriRoot
= originalTo.GetLeftPart(&lt;span style="COLOR: teal"&gt;UriPartial&lt;/span&gt;.Authority);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
match against the suffix list&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: teal"&gt;Regex&lt;/span&gt; suffixExpression &lt;span style="COLOR: blue"&gt;in&lt;/span&gt; suffixes)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Match&lt;/span&gt; match
= suffixExpression.Match(baseUriPath);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (match
!= &lt;span style="COLOR: blue"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; match.Success)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; filterUri
= baseUriRoot+baseUriPath.Remove(baseUriPath.LastIndexOf(match.Value));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;message.Headers.To = &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: teal"&gt;Uri&lt;/span&gt;(filterUri);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (
addressFilter.Match(message))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
message.Headers.To = originalTo;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;true&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
message.Headers.To = originalTo;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;if&lt;/span&gt; (
originalFilter != &lt;span style="COLOR: blue"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
of no match has been found up to here, we match against the 
&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;//
original filter if that was provided.&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; originalFilter.Match(message);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;false&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Implements
the matching logic by constructing a Message over&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; a
MessageBuffer and delegating to the Match(Message) overload&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="buffer"&amp;gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;override&lt;/span&gt; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; Match(&lt;span style="COLOR: teal"&gt;MessageBuffer&lt;/span&gt; buffer)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg
= buffer.CreateMessage();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;bool&lt;/span&gt; result
= Match(msg);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; msg.Close();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; result;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Adds
a new suffix to the suffix table&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="suffix"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;Suffix value&lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; AddSuffix(&lt;span style="COLOR: teal"&gt;Regex&lt;/span&gt; suffix)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; suffixes.Add(suffix);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Removes
a suffix from the suffix table&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="suffix"&amp;gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; RemoveSuffix(&lt;span style="COLOR: teal"&gt;Regex&lt;/span&gt; suffix)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; suffixes.Remove(suffix);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier"&gt;
&lt;br&gt;
&lt;/span&gt;The filter’s filet piece is in the &lt;i&gt;Match&lt;/i&gt; method. To finally figure out
whether a message is a match, we employ the matching logic of the default &lt;i&gt;EndpointAddressFilter&lt;/i&gt;,
which deals with matching the host names and the “base URI” at which the service was
registered. What the suffix filter does in addition is to match the suffix regex pattern
against the incoming message’s “To” header and if that is a match, the suffix is stripped
and the remaining URI is matched against the aggregated &lt;i&gt;EndpointAddressFilter&lt;/i&gt;.
Only if we get a match for the suffix and for the remainder URI, we’ll report a positive
match back to the infrastructure by returning &lt;i&gt;true.&lt;/i&gt; And in that case and only
in that case the service endpoint for which “this” suffix filter was installed and
populated gets the request.
&lt;/p&gt;
&lt;p&gt;
For each incoming request, Indigo goes through all registered endpoint address filters
and asks them whether they want to service it. And that really means “all”. Indigo
will refuse to service the request if two or more filters report ownership of the
respective request and will throw a traceable (using Indigo tracing) internal exception
that will cause none of the services to be picked due to this ambiguity. In the case
of overlapping dispatch namespaces, none is indeed better than “any random”.
&lt;/p&gt;
&lt;p&gt;
Next part: &lt;i&gt;HttpMethodOperationSelectorBehavior&lt;/i&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,c45eb508-2269-4d0e-a730-dbd9c7d5f882.aspx"&gt;Go
to Part 4&lt;/a&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://vasters.com/clemensv/aggbug.ashx?id=3f40268c-dee2-44eb-829a-f621a4d40fbc" /&gt;</description>
      <comments>http://vasters.com/clemensv/CommentView,guid,3f40268c-dee2-44eb-829a-f621a4d40fbc.aspx</comments>
      <category>Technology/Indigo</category>
    </item>
    <item>
      <trackback:ping>http://vasters.com/clemensv/Trackback.aspx?guid=4e2a7d26-342c-4402-8000-a0d15860c5fc</trackback:ping>
      <pingback:server>http://vasters.com/clemensv/pingback.aspx</pingback:server>
      <pingback:target>http://vasters.com/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx</pingback:target>
      <dc:creator>
      </dc:creator>
      <wfw:comment>http://vasters.com/clemensv/CommentView,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx</wfw:comment>
      <wfw:commentRss>http://vasters.com/clemensv/SyndicationService.asmx/GetEntryCommentsRss?guid=4e2a7d26-342c-4402-8000-a0d15860c5fc</wfw:commentRss>
      <slash:comments>2</slash:comments>
      <title>Teaching Indigo to do REST/POX, Part 2</title>
      <guid isPermaLink="false">http://vasters.com/clemensv/PermaLink,guid,4e2a7d26-342c-4402-8000-a0d15860c5fc.aspx</guid>
      <link>http://vasters.com/clemensv/2005/12/12/Teaching+Indigo+To+Do+RESTPOX+Part+2.aspx</link>
      <pubDate>Mon, 12 Dec 2005 14:38:51 GMT</pubDate>
      <description>&lt;p&gt;
In the &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx"&gt;first
part&lt;/a&gt; of this series, I gave you a little introduction to REST/POX in contrast
to SOAP and also explained some of the differences in how incoming requests are dispatched.
Now I’ll start digging into how we can teach Indigo a RESTish dispatch mechanism that
dispatches based on the &lt;a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html"&gt;HTTP
method&lt;/a&gt; and by matching on the URI against a &lt;i style="mso-bidi-font-style: normal"&gt;suffix
pattern&lt;/i&gt;&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;. 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/p&gt;
&lt;p&gt;
The idea here is that we have a service implementation that takes care of a certain
resource namespace. To stick with the example from Part 1, we assume that the resources
managed within this (URI) namespace are customers and data related to customers. Mind
that this might not be all data of a respective customer, but that some data may very
well be residing in completely different namespaces (and on different servers).&lt;o:p&gt;&lt;/o:p&gt;
&lt;/p&gt;
&lt;p&gt;
As a reminder: When I write “namespaces” I specifically mean that we’re creating hierarchical
scopes for data. All customer representations managed by our imaginary service are
subordinates of the namespace &lt;i style="mso-bidi-font-style: normal"&gt;http://www.example.com/customers&lt;/i&gt;,
the representation of the customer identified by customer-id 00212332 occupies the
namespace &lt;i style="mso-bidi-font-style: normal"&gt;http://www.example.com/customers/00212332&lt;/i&gt;,
all communication (phone) numbers of that customer are subordinates of &lt;i style="mso-bidi-font-style: normal"&gt;http://www.example.com/customers/00212332/&lt;/i&gt;comm
and the home phone number might be identified by &lt;i style="mso-bidi-font-style: normal"&gt;http://www.example.com/customers/00212332/comm/home-phone&lt;/i&gt;.
However, all orders made by that respective customer might be found somewhere completely
different; maybe here: &lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;i style="mso-bidi-font-style: normal"&gt;http://www.tempuri.org/ordersystem/customer-orders/00212332.&lt;/i&gt; The
data representation of the customer would contain that link, but the customer service
would not manage those resources (the orders), at all.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/p&gt;
&lt;p&gt;
Purists might (and &lt;a href="http://www.markbaker.ca/2002/09/Blog/2005/12/08#2005-12-clemens-indigo-rest"&gt;do&lt;/a&gt;)
argue that plain HTTP handlers (or “servlets”, in Java terms) representing exactly
one resource type are the best way to implement the processing logic for this URI/HTTP
centric model, but since I am much more a pragmatist than a purist, I prefer using
a infrastructure that maps incoming requests to a programming model that’s easy enough
for most programmers to deal with. It turns out that a class with methods that deal
with related stuff (a customer and his addresses and phone numbers) is something that
most programmers can handle pretty well by now and there’s nothing wrong with co-locating
related handlers for data from a given data source on one flat interface, even if
the outside representation of that data suggests that the data and its “endpoints”
are ordered hierarchically. In the end, the namespace organization is just a smokescreen
that we put in front of our implementation. Just to make &lt;a href="http://www.markbaker.ca/2002/09/Blog/2005/12/08#2005-12-clemens-indigo-rest"&gt;Mark&lt;/a&gt; happy,
I’ll show a very HTTP and service-per-object aligned contract model and, later in
the next part, also a more readable model for the rest of us to explain how the dispatch
works. I’ll start with the model for idealists:&lt;o:p&gt;&lt;/o:p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse; mso-padding-alt: 0in 0in 0in 0in" cellspacing=0 cellpadding=0 border=0&gt;
&lt;tbody&gt;
&lt;tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 5.4pt; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent" valign=top&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-layout-grid-align: none"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier; mso-no-proof: yes"&gt;&lt;font size=2&gt;[&lt;span style="COLOR: teal"&gt;ServiceContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethodOperationSelector&lt;/span&gt;]&lt;br&gt;
&lt;span style="COLOR: blue"&gt;interface&lt;/span&gt; &lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: teal"&gt;ICustomerResource&lt;br&gt;
&lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, 
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"GET"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/customers/?"&lt;/span&gt;)]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; Get(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg);&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, 
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"PUT"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/customers/?"&lt;/span&gt;)]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; Put(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg);&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, 
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"POST"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/customers/?"&lt;/span&gt;)]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; Post(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg);&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, 
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"DELETE"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/customers/?"&lt;/span&gt;)]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; Delete(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg);&lt;br&gt;
}&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: Verdana"&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 0in; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; BORDER-LEFT: #ece9d8; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent; mso-border-left-alt: solid windowtext 1.0pt" valign=top&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;
&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier; mso-no-proof: yes"&gt;&lt;font size=2&gt;[&lt;span style="COLOR: teal"&gt;ServiceContract&lt;/span&gt;, &lt;span style="COLOR: teal"&gt;HttpMethodOperationSelector&lt;/span&gt;]&lt;br&gt;
&lt;span style="COLOR: blue"&gt;interface&lt;/span&gt; &lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: teal"&gt;ICommunicationResource&lt;br&gt;
&lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, 
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"GET"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/customers/?/comm/?"&lt;/span&gt;)]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; Get(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg);&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, 
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"PUT"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/customers/?/comm/?"&lt;/span&gt;)]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; Put(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg);&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, 
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"POST"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/customers/?/comm/?"&lt;/span&gt;)]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; Post(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg);&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style="COLOR: teal"&gt;OperationContract&lt;/span&gt;, 
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;HttpMethod&lt;/span&gt;(&lt;span style="COLOR: maroon"&gt;"DELETE"&lt;/span&gt;,
UriSuffix = &lt;span style="COLOR: maroon"&gt;"/customers/?/comm/?"&lt;/span&gt;)]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; Delete(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg);&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;}&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier"&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p&gt;
We have two different contracts here, one for the “customers” namespace and one for
the “comm” sub-namespace, and the implementation of these two contracts could be sitting
on the same implementation class or on two different classes whereby they could be
co-located at the exact same root address or sitting on different machines. All of
that doesn’t really matter, since the filtering/dispatch logic we’ll use here will
figure out the right thing to do, meaning the right handler method to dispatch to.
Also mind that there’s a difference to the examples I show in &lt;a href="http://staff.newtelligence.net/clemensv/PermaLink,guid,2d61b97b-3a6e-46bd-89db-b1b20499ba18.aspx"&gt;Part
1&lt;/a&gt; in that I am now using messages.&lt;o:p&gt;&lt;/o:p&gt;
&lt;/p&gt;
&lt;p&gt;
The &lt;i style="mso-bidi-font-style: normal"&gt;UriSuffix&lt;/i&gt; of the &lt;i style="mso-bidi-font-style: normal"&gt;HttpMethodAttribute &lt;/i&gt;serves
three purposes. First, it is used to construct a regular expression that is used to
match incoming messages to the right endpoint using a custom endpoint &lt;i style="mso-bidi-font-style: normal"&gt;&lt;a href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/T_System_ServiceModel_Filter.asp"&gt;Filter&lt;/a&gt;&lt;/i&gt;.
Second, the same regular expression is used to figure out which method the message
shall be dispatched on at that endpoint using a custom implementation of &lt;i style="mso-bidi-font-style: normal"&gt;&lt;a href="http://winfx.msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/T_System_ServiceModel_IDispatchOperationSelector.asp"&gt;IDispatchOperation&lt;/a&gt;&lt;/i&gt;.
Third, the regular expression is also used to isolate the URI-embedded parameters
and make them easily accessible on a message property. So for the &lt;i style="mso-bidi-font-style: normal"&gt;ICommunicationResource.Get()&lt;/i&gt; operation
above, the handler implementation would start out as follows and would make the values
occurring at the two “?” of the suffix available in the &lt;i style="mso-bidi-font-style: normal"&gt;UriArgumentsMessageProperty.InUrlArgs&lt;/i&gt; collection
that is shown further below:&lt;i style="mso-bidi-font-style: normal"&gt; &lt;/i&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse; mso-padding-alt: 0in 0in 0in 0in" cellspacing=0 cellpadding=0 border=0&gt;
&lt;tbody&gt;
&lt;tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 0in; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent" valign=top&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;
&lt;span style="FONT-SIZE: 10pt; COLOR: teal; FONT-FAMILY: Courier; mso-no-proof: yes"&gt;Message&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier; mso-no-proof: yes"&gt; &lt;span style="COLOR: teal"&gt;ICommunicationResource&lt;/span&gt;.Get(&lt;span style="COLOR: teal"&gt;Message&lt;/span&gt; msg)&lt;br&gt;
{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: teal"&gt;UriArgumentsMessageProperty&lt;/span&gt; uriArgs
= &lt;span style="COLOR: teal"&gt;UriArgumentsMessageProperty&lt;/span&gt;.FromOperationContext();&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; customerid
= uriArgs.InUrlArgs[0];&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; commid
= uriArgs.InUrlArgs[1];&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;...&lt;/span&gt;&lt;span style="FONT-SIZE: 10pt; FONT-FAMILY: Courier"&gt;
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/span&gt;
&lt;/p&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/p&gt;
&lt;p&gt;
The expressions for &lt;i style="mso-bidi-font-style: normal"&gt;UriSuffix&lt;/i&gt; support two
different wildcards. The “*”wildcard will match any character and the “?” wildcard
will match any character except the forward slash. If you would, for instance, want
to build an operation that behaves like a web server and might serve up data from
a directory and its subdirectories, you’d use something as global as “/*” and any
URI would match the respective endpoint/method. If you want to match/extract segments
of a namespace path as we do here, you use the “?”. 
&lt;o:p&gt;&lt;/o:p&gt;
&lt;/p&gt;
&lt;p&gt;
And so here is the complete and rather straightforward implementation of the &lt;i style="mso-bidi-font-style: normal"&gt;HttpMethodAttribute&lt;/i&gt;:&lt;o:p&gt;&lt;/o:p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;table class=MsoNormalTable style="BACKGROUND: #f3f3f3; WIDTH: 100%; BORDER-COLLAPSE: collapse; mso-padding-alt: 0in 0in 0in 0in" cellspacing=0 cellpadding=0 border=0&gt;
&lt;tbody&gt;
&lt;tr style="mso-yfti-irow: 0; mso-yfti-firstrow: yes; mso-yfti-lastrow: yes"&gt;
&lt;td style="BORDER-RIGHT: windowtext 1pt solid; PADDING-RIGHT: 0in; BORDER-TOP: windowtext 1pt solid; PADDING-LEFT: 0in; PADDING-BOTTOM: 0in; BORDER-LEFT: windowtext 1pt solid; PADDING-TOP: 0in; BORDER-BOTTOM: windowtext 1pt solid; BACKGROUND-COLOR: transparent" valign=top&gt;
&lt;p class=MsoNormal style="MARGIN: 0in 0in 0pt; mso-margin-top-alt: auto; mso-margin-bottom-alt: auto"&gt;
&lt;span style="FONT-SIZE: 9pt; COLOR: blue; FONT-FAMILY: Courier; mso-no-proof: yes"&gt;&lt;font size=2&gt;using&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 9pt; FONT-FAMILY: Courier; mso-no-proof: yes"&gt;&lt;font size=2&gt; System;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Collections.Generic;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Text;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel;&lt;br&gt;
&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.Text.RegularExpressions;&lt;br&gt;
&lt;br&gt;
&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; newtelligence.ServiceModelExtensions&lt;br&gt;
{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: green"&gt; The
HttpMethodAttribute is used to declare the HTTP method and 
&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: green"&gt; an
optional suffix for the REST/POX extensions to dispatch on. In absence of&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: green"&gt; this
attribute, the dispatch mechanism will attempt to dispatch on the 
&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: green"&gt; name
of the operation and try matching by name it to the HTTP method used.&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;[&lt;span style="COLOR: teal"&gt;AttributeUsage&lt;/span&gt;(&lt;span style="COLOR: teal"&gt;AttributeTargets&lt;/span&gt;.Method)]&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: teal"&gt;HttpMethodAttribute&lt;/span&gt; : &lt;span style="COLOR: teal"&gt;Attribute&lt;/span&gt;, &lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: teal"&gt;IOperationBehavior&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; Initializes
a new instance of the &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;see cref="T:HttpMethodAttribute"/&amp;gt;&lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: green"&gt; class.&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;param
name="method"&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The method.&lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/param&amp;gt;&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; HttpMethodAttribute(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; method)&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;_Method
= method;&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;br&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; _Method;&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: green"&gt; Gets
the HTTP method. See http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/summary&amp;gt;&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;value&amp;gt;&lt;/span&gt;&lt;span style="COLOR: green"&gt;The
method.&lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;/value&amp;gt;&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; Method&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: blue"&gt;get&lt;br&gt;
&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;{&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="COLOR: blue"&gt;return&lt;/span&gt; _Method;&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/span&gt;}&lt;br&gt;
&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: blue"&gt;private&lt;/span&gt; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; _UriSuffix;&lt;br&gt;
&lt;span style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: gray"&gt;///&lt;/span&gt;&lt;span style="COLOR: green"&gt; &lt;/span&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;span style="COLOR: gray"&gt;&amp;lt;summary&amp;gt;&lt;