<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>A Tryst With SOA</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/dhrubach/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/dhrubach/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 04:03:28 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>WCF Security Interoperability Guidelines – 2 : Reference Style of a Primary Signing Token inside a request</title>
      <link>https://docs.microsoft.com/archive/blogs/dhrubach/wcf-security-interoperability-guidelines-2-reference-style-of-a-primary-signing-token-inside-a-request</link>
      <pubDate>Fri, 18 Jun 2010 08:59:00 GMT</pubDate>
      <dc:creator><![CDATA[dhruba]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhrubach/2010/06/18/wcf-security-interoperability-guidelines-2-reference-style-of-a-primary-signing-token-inside-a-request/</guid>
      <description><![CDATA[In my last post, I had discussed the supported ways to reference a primary...]]></description>
      <content:encoded><![CDATA[<p>
<meta content="text/html; charset=utf-8" />
<meta content="Word.Document" name="ProgId" />
<meta content="Microsoft Word 14" name="Generator" />
<meta content="Microsoft Word 14" name="Originator" />
<link href="file:///C:\Users\ADMINI~1\AppData\Local\Temp\msohtmlclip1\01\clip_filelist.xml" rel="File-List" />
<link href="file:///C:\Users\ADMINI~1\AppData\Local\Temp\msohtmlclip1\01\clip_themedata.thmx" rel="themeData" />
<link href="file:///C:\Users\ADMINI~1\AppData\Local\Temp\msohtmlclip1\01\clip_colorschememapping.xml" rel="colorSchemeMapping" />

<b><span style="text-decoration: underline;"><span style="font-size: 9pt; line-height: 115%; font-family: 'Verdana','sans-serif';"><o:p><span style="text-decoration: none;"></span></o:p></span></span></b>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';">In my last post, I had discussed the supported ways to reference a primary signing token inside a response. We will focus on request this time round. Consider a scenario where we have a non-.NET client consuming a WCF service, security requirements of the underlying communication remaining the same as my last post:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';"><o:p>&nbsp;</o:p></span><span style="font-size: 10pt; line-height: 115%;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';">Security is implemented at the message layer with either parties communicating over HTTP.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';">Both client and service mutually authenticates via X509 certificates.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';">Additional client authentication in terms of a supporting username token.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';">Sometimes we might choose to pass only a pointer to X509Certificate (may be its issuer name and serial number) instead of the whole certificate encapsulated within a binary security token (BST). In such a case, incoming security header to a WCF service will look as follows:</span><span style="font-size: 8pt; line-height: 115%; font-family: 'Verdana','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; line-height: 115%; font-family: 'Verdana','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:Security s:mustUnderstand</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">="</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">1</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">" </span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: red;">xmlns:o</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">="</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: red;">https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">"&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">u:Timestamp u:Id</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">="</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">uuid-31bf49bd-df18-41d4-9c9d-559e56a99045-1</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">"&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">u:Created</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">2010-05-24T21:48:37.010Z</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">u:Created</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">u:Expires</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">2010-05-24T21:53:37.010Z</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">u:Expires</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">u:Timestamp</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:UsernameToken u:Id</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">="</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">uuid-86024b35-af0f-40f9-8ba7-9e73381a9599-1</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">"&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:Username</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;!-- </span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #888888;">Removed</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">--&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:Username</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:Password</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;!-- </span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #888888;">Removed</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">--&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:Password</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:UsernameToken</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">Signature </span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: red;">xmlns</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">="</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: red;">https://www.w3.org/2000/09/xmldsig#</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">"&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">SignedInfo</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">.<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">.<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">SignatureValue</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">GKClvYiiqAIbcjSnWXJoxuoaziY5Yg&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;&hellip;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">SignatureValue</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">KeyInfo</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:SecurityTokenReference</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">&lt;X509Data</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509IssuerSerial</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509IssuerName</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">CN=XXXX</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509IssuerName</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509SerialNumber</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">665497663279805416273</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509SerialNumber</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509IssuerSerial</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509Data</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:SecurityTokenReference</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">KeyInfo</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span></b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">Signature</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:Security</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; line-height: 115%; font-family: 'Verdana','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';">Such a request will fail at the service end with the following exception:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; line-height: 115%; font-family: 'Verdana','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">Exception</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ExceptionType</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">System.ServiceModel.Security.MessageSecurityException</span></b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ExceptionType</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">Message</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">Cannot resolve KeyInfo for verifying signature: KeyInfo 'SecurityKeyIdentifier</span></b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><span>&nbsp;&nbsp;&nbsp; </span>(<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><span>&nbsp;&nbsp;&nbsp; </span>IsReadOnly = False,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><span>&nbsp;&nbsp;&nbsp; </span>Count = 1,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><span>&nbsp;&nbsp;&nbsp; </span>Clause[0] = X509IssuerSerialKeyIdentifierClause(Issuer = 'CN=XXXX', Serial = '665497663279805416273')<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><span>&nbsp;&nbsp;&nbsp; </span>)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">', available tokens 'SecurityTokenResolver<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><span>&nbsp;&nbsp;&nbsp; </span>(<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><span>&nbsp;&nbsp;&nbsp; </span>TokenCount = 0,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><span>&nbsp;&nbsp;&nbsp; </span>)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">'.</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">Message</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">StackTrace</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">at System.ServiceModel.Security.<span style="background: none repeat scroll 0% 0% yellow;">WSSecurityOneDotZeroReceiveSecurityHeader.ResolveSignatureToken</span>(SecurityKeyIdentifier keyIdentifier, <span style="background: none repeat scroll 0% 0% yellow;">SecurityTokenResolver</span> resolver, Boolean isPrimarySignature)</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">at System.ServiceModel.Security.WSSecurityOneDotZeroReceiveSecurityHeader.VerifySignature(SignedXml signedXml, Boolean isPrimarySignature, <span style="background: none repeat scroll 0% 0% yellow;">SecurityHeaderTokenResolver</span> resolver, Object signatureTarget, String id)</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">at System.ServiceModel.Security.ReceiveSecurityHeader.ProcessPrimarySignature(SignedXml signedXml, Boolean isFromDecryptedSource)</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">at System.ServiceModel.Security.ReceiveSecurityHeader.ExecuteFullPass(XmlDictionaryReader reader)</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">at System.ServiceModel.Security.ReceiveSecurityHeader.Process(TimeSpan timeout)</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">at System.ServiceModel.Security.MessageSecurityProtocol.ProcessSecurityHeader(ReceiveSecurityHeader securityHeader, Message&amp;amp; message, SecurityToken requiredSigningToken, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">at System.ServiceModel.Security.AsymmetricSecurityProtocol.VerifyIncomingMessageCore(Message&amp;amp; message, String actor, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">at System.ServiceModel.Security.MessageSecurityProtocol.VerifyIncomingMessage(Message&amp;amp; message, TimeSpan timeout, SecurityProtocolCorrelationState[] correlationStates)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';">Let us first see why the request fails at the service end. To start with, we need to understand what a <i><span style="color: #002060;">System.ServiceModel.Security.SecurityTokenResolver</span></i> is. This is a utility class used to retrieve security tokens from a message given a key identifier or a key identifier clause. More details about this class are available </span><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';"><a href="https://msdn.microsoft.com/en-us/library/system.identitymodel.selectors.securitytokenresolver(VS.90).aspx"><span>here</span></a></span><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';">. WCF runtime, upon receipt of a request, populates this class with the tokens present inside the security header. Corresponding call stack of such a add operation is as follows:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; line-height: 115%; font-family: 'Verdana','sans-serif';">0000000002cde4a8 000007fee4edc845 <b>System.ServiceModel.Security.SecurityHeaderTokenResolver.Add</b>(System.IdentityModel.Tokens.SecurityToken, System.ServiceModel.Security.Tokens.SecurityTokenReferenceStyle, System.ServiceModel.Security.Tokens.SecurityTokenParameters)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; line-height: 115%; font-family: 'Verdana','sans-serif';">0000000002cde4b0 000007fee403b85d System.ServiceModel.Security.ReceiveSecurityHeader.ReadToken(System.Xml.XmlDictionaryReader, Int32, Byte[], System.IdentityModel.Tokens.SecurityToken, System.String, System.TimeSpan)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; line-height: 115%; font-family: 'Verdana','sans-serif';">0000000002cde560 000007fee403afb9 System.ServiceModel.Security.ReceiveSecurityHeader.ExecuteFullPass(System.Xml.XmlDictionaryReader)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; line-height: 115%; font-family: 'Verdana','sans-serif';">0000000002cde5e0 000007fee403ab8b System.ServiceModel.Security.ReceiveSecurityHeader.Process(System.TimeSpan)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; line-height: 115%; font-family: 'Verdana','sans-serif';">0000000002cde680 000007fee4a41f02 System.ServiceModel.Security.MessageSecurityProtocol.ProcessSecurityHeader(System.ServiceModel.Security.ReceiveSecurityHeader, System.ServiceModel.Channels.Message ByRef, System.IdentityModel.Tokens.SecurityToken, System.TimeSpan, System.ServiceModel.Security.SecurityProtocolCorrelationState[])<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; line-height: 115%; font-family: 'Verdana','sans-serif';">0000000002cde700 000007fee4039e2c System.ServiceModel.Security.AsymmetricSecurityProtocol.VerifyIncomingMessageCore(System.ServiceModel.Channels.Message ByRef, System.String, System.TimeSpan, System.ServiceModel.Security.SecurityProtocolCorrelationState[])<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; line-height: 115%; font-family: 'Verdana','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; line-height: 115%; font-family: 'Verdana','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';">Going by the security header mentioned in the beginning, <i><span style="color: #002060;">SecurityHeaderTokenResolver.Add</span></i> (it is also referred to as &lsquo;<span style="color: #002060;">primaryTokenResolver</span>&rsquo;) method is called once for <span style="color: #002060;">UsernameToken</span> present in the request. A pertinent question at this point: what happens to the <span style="color: #002060;">X509SecurityToken</span> referenced inside <span style="color: blue;">&lt;</span><span style="color: #990000;">KeyInfo</span><span style="color: blue;">&gt; </span>element? Why are we ignoring that while populating the resolver with security tokens? Such a token is referred to as an &lsquo;<i><span style="color: #002060;">outOfBandToken</span></i>&rsquo;. We need to handle such a token via a custom <i><span style="color: #002060;">outOfBandTokenResolver</span></i>. WCF runtime does not populate primaryTokenResolver with such outOfBandTokens. Neither does it use an outOfBandTokenResolver while processing a primary signature. You can verify that from <i><span style="color: #002060;">ReceiveSecurityHeader.ProcessPrimarySignature</span></i> method:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">private</span><span style="font-size: 9.5pt; font-family: Consolas;"> <span style="color: blue;">void</span> ProcessPrimarySignature(SignedXml signedXml, <span style="color: blue;">bool</span> isFromDecryptedSource)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this</span><span style="font-size: 9.5pt; font-family: Consolas;">.orderTracker.OnProcessSignature(isFromDecryptedSource);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">this</span>.primarySignatureValue = signedXml.GetSignatureValue();<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">if</span> (<span style="color: blue;">this</span>.nonceCache != <span style="color: blue;">null</span>)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>CheckNonce(<span style="color: blue;">this</span>.nonceCache, <span style="color: blue;">this</span>.primarySignatureValue);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SecurityToken</span><span style="font-size: 9.5pt; font-family: Consolas;"> token = <span style="color: blue;">this</span>.VerifySignature(signedXml, <span style="color: blue;">true</span>, <span style="color: blue; background: none repeat scroll 0% 0% yellow;">this</span><span style="background: none repeat scroll 0% 0% yellow;">.primaryTokenResolver</span>, <span style="color: blue;">null</span>, <span style="color: blue;">null</span>);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; line-height: 115%; font-family: 'Verdana','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';">What we have is a supporting username token inside primary token resolver and a <i><span style="color: #002060;">X509IssuerKeyIdentifierClause</span></i> key identifier passed to </span><i><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; color: #002060;">System.ServiceModel.Security.SecurityHeaderTokenResolver.ResolveToken</span></i><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';"> method. Unable to resolve the referenced token, this method returns a NULL. Eventually a MessageSecurityException is thrown from <span style="color: #002060;">WSSecurityOneDotZeroReceiveSecurityHeader.ResolveSignatureToken:<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">if</span><span style="font-size: 9.5pt; font-family: Consolas;"> (token == <span style="color: blue;">null</span>)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw</span><span style="font-size: 9.5pt; font-family: Consolas;"> DiagnosticUtility.ExceptionUtility.ThrowHelperError(<span style="color: blue;">new</span> <span style="color: #2b91af;">MessageSecurityException</span>(SR.GetString(<span style="color: #a31515;">"UnableToResolveKeyInfoForVerifyingSignature"</span>, <span style="color: blue;">new</span> <span style="color: blue;">object</span>[] { keyIdentifier,&nbsp; resolver })));<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';">So how a primary signing token should be referenced inside a request security header? ONLY way supported by WCF is passing an X509SecurityToken inside a BST. Working security header:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:Security s:mustUnderstand</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">="</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">1</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">" </span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: red;">xmlns:o</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">="</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: red;">https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">"&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">u:Timestamp u:Id</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">="</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">uuid-4244331a-1cd0-4c16-9385-318ef75a6f81-1</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">"&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">u:Created</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">2010-05-24T21:47:47.061Z</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">u:Created</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">u:Expires</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">2010-05-24T21:52:47.061Z</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">u:Expires</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">u:Timestamp</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:BinarySecurityToken</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!-- </span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #888888;">Removed</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">--&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:BinarySecurityToken</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:UsernameToken u:Id</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">="</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">uuid-f79a13e9-6edd-4bae-aa88-64381cd0324d-1</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">"&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:Username</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!-- </span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #888888;">Removed</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">--&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:Username</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:Password</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;!-- </span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #888888;">Removed</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">--&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:Password</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:UsernameToken</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">Signature </span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: red;">xmlns</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">="</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: red;">https://www.w3.org/2000/09/xmldsig#</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">"&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">SignedInfo</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">SignatureValue</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">aAP88k0ECFC3ao5S98mSA&hellip;&hellip;&hellip;..</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">SignatureValue</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">KeyInfo</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:SecurityTokenReference</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:Reference URI</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">="</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">#uuid-f7913e9-6edd-4bae-aa88-64381cd0324d-3</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">"&gt;&lt;/</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:Reference</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:SecurityTokenReference</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal"><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">KeyInfo</span></b><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></b></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">Signature</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:Security</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';">Next time you have a non-.NET client talking with a WCF service and you run into a similar security exception, make sure to place your primary signing token within a BST. </span><span style="font-size: 10pt; line-height: 115%; font-family: 'Eras Medium ITC','sans-serif';"><o:p></o:p></span></p>
</p>]]></content:encoded>
    </item>
    <item>
      <title>WCF Security Interoperability Guidelines – 1 : Reference Style of a Primary Signing Token inside a response</title>
      <link>https://docs.microsoft.com/archive/blogs/dhrubach/wcf-security-interoperability-guidelines-1-reference-style-of-a-primary-signing-token-inside-a-response</link>
      <pubDate>Fri, 11 Jun 2010 00:36:00 GMT</pubDate>
      <dc:creator><![CDATA[dhruba]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhrubach/2010/06/11/wcf-security-interoperability-guidelines-1-reference-style-of-a-primary-signing-token-inside-a-response/</guid>
      <description><![CDATA[Making things work with a disparate entity is always a difficult task to accomplish. Things are no...]]></description>
      <content:encoded><![CDATA[<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">Making things work with a disparate entity is always a difficult task to accomplish. Things are no different in WCF Interoperability space. While significant developments have been made over the years to standardize various protocols and develop products which adhere to these protocols, differences are always there. Through the course of this article and subsequent ones, I will present certain painful interoperability issues which we have encountered in WCF support life cycle so far. Note that these are simple guidelines of what works and what does not as it stands today. Workarounds will be presented for some, while the rest are by design.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">Such issues are always manifested by either communicating parties&rsquo; inability to process a request / response generated by their counterpart. It&rsquo;s always either &lsquo;a WCF service not able to process a request generated by a non - WCF client&rsquo; or &lsquo;a WCF client notable to process a response received from a non &ndash; WCF web service&rsquo;. My intention is to pick a couple such scenarios and perform a post &ndash; mortem.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;<o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="text-decoration: underline;"><span style="font-family: 'Eras Medium ITC','sans-serif';">Scenario: Reference Style of a Primary Signing Token inside a response</span></span></b><span style="font-family: 'Eras Medium ITC','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;</span></b><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">Consider a WCF client consuming a non &ndash; .NET web service. Following are the security attributes of the underlying communication:<o:p></o:p></span></p>
<p><span style="line-height: normal; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p></o:p></span><span style="line-height: normal; font-family: 'Verdana','sans-serif'; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;"><span style="mso-list: Ignore;"></span></span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">-</span><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Security is implemented at the message layer with either parties communicating over HTTP.<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">-</span><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Both client and service mutually authenticates via X509 certificates.<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">-</span><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Additional client authentication in terms of a supporting username token.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">One of the key requirements is to understand how any given security scenario can be represented in WCF world. Given the above points, we need to implement a custom binding (no standard binding can meet all the above requirements) which looks as follows:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New'; color: #2b91af;">HttpTransportBindingElement</span><span style="font-size: 9pt; font-family: 'Courier New';"> http = <span style="color: blue;">new</span> <span style="color: #2b91af;">HttpTransportBindingElement</span>();</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New'; color: #2b91af;">X509SecurityTokenParameters</span><span style="font-size: 9pt; font-family: 'Courier New';"> initiatorToken = <span style="color: blue;">new</span> <span style="color: #2b91af;">X509SecurityTokenParameters</span>();</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">initiatorToken.RequireDerivedKeys = <span style="color: blue;">false</span>;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New'; color: #2b91af;">X509SecurityTokenParameters</span><span style="font-size: 9pt; font-family: 'Courier New';"> receipientToken = <span style="color: blue;">new</span> <span style="color: #2b91af;">X509SecurityTokenParameters</span>();</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">receipientToken.RequireDerivedKeys = <span style="color: blue;">false</span>;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New'; color: #2b91af;">AsymmetricSecurityBindingElement</span><span style="font-size: 9pt; font-family: 'Courier New';"> asbe = <span style="color: blue;">new</span> <span style="color: #2b91af;">AsymmetricSecurityBindingElement</span>(receipientToken,initiatorToken);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">asbe.IncludeTimestamp = <span style="color: blue;">true</span>;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">asbe.RequireSignatureConfirmation = <span style="color: blue;">false</span>;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New'; color: #2b91af;">UserNameSecurityTokenParameters</span><span style="font-size: 9pt; font-family: 'Courier New';"> username = <span style="color: blue;">new</span> <span style="color: #2b91af;">UserNameSecurityTokenParameters</span>();</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">username.InclusionMode = SecurityTokenInclusionMode.AlwaysToRecipient;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">username.RequireDerivedKeys = <span style="color: blue;">false</span>;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">asbe.EndpointSupportingTokenParameters.Signed.Add(username);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New'; color: #2b91af;">TextMessageEncodingBindingElement</span><span style="font-size: 9pt; font-family: 'Courier New';"> tmbe = <span style="color: blue;">new</span> <span style="color: #2b91af;">TextMessageEncodingBindingElement</span>(<span style="color: #2b91af;">MessageVersion</span>.Soap11,System.Text.<span style="color: #2b91af;">Encoding</span>.UTF8);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New'; color: blue;">return</span><span style="font-size: 9pt; font-family: 'Courier New';"> <span style="color: blue;">new</span> <span style="color: #2b91af;">CustomBinding</span>(tmbe, asbe, http);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">Let&rsquo;s now get to the issue. With this binding in place, a call to a non - .NET web service fails with the following exception:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">Exception</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ExceptionType</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">System.Xml.XmlException</span></b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">, System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089<span style="color: blue;">&lt;/</span><span style="color: #990000;">ExceptionType</span><span style="color: blue;">&gt;</span></span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">Message</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">There was an error deserializing the security key identifier clause XML. Please see the inner exception for more details</span></b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">.<span style="color: blue;">&lt;/</span><span style="color: #990000;">Message</span><span style="color: blue;">&gt;</span></span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">StackTrace</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.ServiceModel.Security.WSSecurityTokenSerializer.ReadKeyIdentifierClauseCore(XmlReader reader)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.IdentityModel.Selectors.SecurityTokenSerializer.ReadKeyIdentifierClause(XmlReader reader)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.ServiceModel.Security.XmlDsigSep2000.KeyInfoEntry.ReadKeyIdentifierCore(XmlDictionaryReader reader)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.ServiceModel.Security.WSSecurityTokenSerializer.ReadKeyIdentifierCore(XmlReader reader)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.IdentityModel.Selectors.SecurityTokenSerializer.ReadKeyIdentifier(XmlReader reader)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.IdentityModel.Signature.ReadFrom(XmlDictionaryReader reader, DictionaryManager dictionaryManager)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.IdentityModel.SignedXml.ReadFrom(XmlDictionaryReader reader)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.ServiceModel.Security.WSSecurityOneDotZeroReceiveSecurityHeader.ReadSignatureCore(XmlDictionaryReader signatureReader)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.ServiceModel.Security.ReceiveSecurityHeader.ReadSignature(XmlDictionaryReader reader, Int32 position, Byte[] decryptedBuffer)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.ServiceModel.Security.ReceiveSecurityHeader.ExecuteFullPass(XmlDictionaryReader reader)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.ServiceModel.Security.StrictModeSecurityHeaderElementInferenceEngine.ExecuteProcessingPasses(ReceiveSecurityHeader securityHeader, XmlDictionaryReader reader)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.ServiceModel.Security.<span style="background: none repeat scroll 0% 0% yellow;">ReceiveSecurityHeader.Process</span>(TimeSpan timeout)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; .</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">A look at the above stack trace shows that processing of response security header throws an exception. How do we know that? Note the highlighted last line of the exception stack trace. Following is the inner exception:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">InnerException</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ExceptionType</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">System.ArgumentNullException</span></b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089<span style="color: blue;">&lt;/</span><span style="color: #990000;">ExceptionType</span><span style="color: blue;">&gt;</span></span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">Message</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">Value cannot be null.</span></b><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Parameter name: certificate</span></b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">Message</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">StackTrace</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.IdentityModel.Tokens.X509RawDataKeyIdentifierClause.GetRawData(X509Certificate certificate)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.IdentityModel.Tokens.X509RawDataKeyIdentifierClause..ctor(X509Certificate2 certificate)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.ServiceModel.Security.<span style="background: none repeat scroll 0% 0% yellow;">XmlDsigSep2000.X509CertificateClauseEntry.ReadKeyIdentifierClauseCore</span>(XmlDictionaryReader reader)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; at System.ServiceModel.Security.WSSecurityTokenSerializer.ReadKeyIdentifierClauseCore(XmlReader reader)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">StackTrace</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">InnerException</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">So we are failing to retrieve key identifiers of primary signing token from the received signature. Let&rsquo;s have a look at the received primary signing token:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:KeyInfo</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509Data</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509IssuerSerial</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509IssuerName</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">XXXXXXXXXXXXXXXXXXX</span></b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;"> &lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509IssuerName</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509SerialNumber</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">74990459506171493075258200981073178724</span></b><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509SerialNumber</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509IssuerSerial</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509Data</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:KeyInfo</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">So what&rsquo;s wrong with this? Why are we trying to construct a <i><span style="color: #002060;">System.IdentityModel.Tokens.X509RawDataKeyIdentifierClause </span></i>(based on the stack trace shared above) when the service has passed an <i>IssuerSerial</i> of the signing certificate? Let me explain a bit of what happens at the background. Take a look at the reflected code of <i><span style="color: #002060;">System.ServiceModel.Security.WSSecurityTokenSerializer.ReadKeyIdentifierClauseCore</span></i>:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;protected</span><span style="font-size: 9pt; font-family: 'Courier New';"> <span style="color: blue;">override</span> <span style="color: #2b91af;">SecurityKeyIdentifierClause</span> <span style="background: none repeat scroll 0% 0% yellow;">ReadKeyIdentifierClauseCore</span>(<span style="color: #2b91af;">XmlReader</span> reader)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span><span style="font-size: 9pt; font-family: 'Courier New';"></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span><span style="font-size: 9pt; font-family: 'Courier New'; color: #2b91af;"></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New'; color: #2b91af;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; XmlDictionaryReader</span><span style="font-size: 9pt; font-family: 'Courier New';"> reader2 = <span style="color: #2b91af;">XmlDictionaryReader</span>.CreateDictionaryReader(reader);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue;">for</span> (<span style="color: blue;">int</span> i = 0; i &lt; <span style="color: blue;">this</span>.keyIdentifierClauseEntries.Count; i++)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; KeyIdentifierClauseEntry entry = <span style="color: blue;">this</span>.keyIdentifierClauseEntries[i];</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;<span style="color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if</span> (entry.CanReadKeyIdentifierClauseCore(reader2))</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue;">try</span></span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="color: blue;">return</span> entry.ReadKeyIdentifierClauseCore(reader2);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">Couple of points to note at this point:<o:p></o:p></span></p>
<p class="MsoNormal"><i><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif'; color: #002060;">&nbsp;</span></i><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><i><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif'; color: #002060;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.&nbsp;&nbsp;&nbsp; System.ServiceModel.Security.WSSecurityTokenSerializer+KeyIdentifierClauseEntry</span></i><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">: It represents core identifying properties of an X509Token. This is derived by a number of classes, one being<i><span style="color: #002060;">&nbsp; </span></i></span><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';"><i><span style="color: #002060;">System.ServiceModel.Security.XmlDsigSep2000.X509CertificateClauseEntry</span></i>. This class is of interest to us since it appears in the failing inner exception stack trace.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><i><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif'; color: #002060;">2.&nbsp;&nbsp;&nbsp; KeyIdentifierClauseEntry.CanReadKeyIdentifierClauseCore</span></i><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';"> method: this method determines which KeyIdentifierClauseEntry class is used to retrieve key identifier. Reflected code of the method:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Courier New'; color: blue;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; public</span><span style="font-size: 9pt; font-family: 'Courier New';"> <span style="color: blue;">virtual</span> <span style="color: blue;">bool</span> <span style="background: none repeat scroll 0% 0% yellow;">CanReadKeyIdentifierClauseCore</span>(<span style="color: #2b91af;">XmlDictionaryReader</span> reader)</span><span style="font-size: 12pt; font-family: 'Courier New';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {</span><span style="font-size: 12pt; font-family: 'Courier New';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return</span><span style="font-size: 9pt; font-family: 'Courier New';"> reader.IsStartElement(<span style="color: blue;">this</span>.LocalName, <span style="color: blue;">this</span>.NamespaceUri);</span><span style="font-size: 12pt; font-family: 'Courier New';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9pt; font-family: 'Courier New';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="font-size: 12pt; font-family: 'Courier New';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">Consider the iteration when the value of <i><span style="color: #002060;">entry</span></i> variable in the above <i>ReadKeyIdentifierClauseCore</i> method is set to <i><span style="color: #002060;">X509CertificateClauseEntry</span></i>. At the same time:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; a.&nbsp;&nbsp;&nbsp;&nbsp; <i><span style="color: #002060;">reader</span></i> is pointing to <span style="color: blue;">&lt;</span><span style="color: #990000;">ds:X509Data</span><span style="color: blue;">&gt; </span>&nbsp;element <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; b.&nbsp;&nbsp;&nbsp;&nbsp; this.LocalName inside CanReadKeyIdentifierClauseCore is set to X509Data<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;<o:p></o:p></span></p>
<p class="MsoNormal"><i><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif'; color: #002060;">CanReadKeyIdentifierClauseCore</span></i><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';"> returns true and control gets into <i><span style="color: #002060;">X509CertificateClauseEntry.ReadKeyIdentifierClauseCore.</span></i> Inside this method, we try to generate <i><span style="color: #002060;">X509RawDataKeyIdentifierClause</span></i> which fails. From this we can conclude that <i><span style="color: #002060;">CanReadKeyIdentifierClauseCore</span></i> method should not return <b>TRUE</b> in the first place. While the value of <i><span style="color: #002060;">X509CertificateClauseEntry.LocalName</span></i> is predefined (X509Data), it means that there is something wrong with the structure of primary token. There are 2 possibilities here:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">a.&nbsp;&nbsp;&nbsp;&nbsp; Either <span style="color: blue;">&lt;</span><span style="color: #990000;">ds:X509Data</span><span style="color: blue;">&gt; </span>should not be the immediate child element of <span style="color: blue;">&lt;</span><span style="color: #990000;">ds:KeyInfo</span><span style="color: blue;">&gt;.</span><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">b.&nbsp;&nbsp;&nbsp;&nbsp; If <span style="color: blue;">&lt;</span><span style="color: #990000;">ds:X509Data</span><span style="color: blue;">&gt; </span>is the immediate child of <span style="color: blue;">&lt;</span><span style="color: #990000;">ds:KeyInfo</span><span style="color: blue;">&gt;</span>, the key identifier clauses should be different.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;&nbsp;</span><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">So how a primary signing token should be referenced? WCF supports 4 ways of referencing a primary X509 token. This is defined by <i>System.ServiceModel.Security.Tokens.<span style="color: #2b91af;">X509KeyIdentifierClauseType</span></i><span style="color: #2b91af;"> </span>which is an enumeration type. Following are its possible values (<i>SubjectKeyIdentifier</i> is based on subject key identifier extension and is not explained below):<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-family: 'Eras Medium ITC','sans-serif';">1.&nbsp;&nbsp;&nbsp;&nbsp; <span style="text-decoration: underline;">Any / IssuerSerial (default)</span>&nbsp;&nbsp;&nbsp;&nbsp;<span style="text-decoration: underline;"> </span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">KeyInfo</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:SecurityTokenReference</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509Data</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509IssuerSerial</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509IssuerName</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">CN=XXXXX</span></b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509IssuerName</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509SerialNumber</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">-128364659718044525824792132</span></b><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509SerialNumber</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509IssuerSerial</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509Data</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:SecurityTokenReference</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">KeyInfo</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-family: 'Eras Medium ITC','sans-serif';">2.&nbsp;&nbsp;&nbsp;&nbsp; <span style="text-decoration: underline;">RawDataKeyIdentifier</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">KeyInfo</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509Data</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509Certificate</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">MIICAjCCAWugAwIBAgIQwZyW5YOCXZxHg1MBV2CpvDANBgkhkiG9w0BAQnEdD9tI7IYAAoK4O+35EOzcXbvc4Kzz7BQnulQ=</span></b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509Certificate</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">X509Data</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">KeyInfo</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-family: 'Eras Medium ITC','sans-serif';">3.&nbsp;&nbsp;&nbsp;&nbsp; <span style="text-decoration: underline;">Thumbprint</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">KeyInfo</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:SecurityTokenReference</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:KeyIdentifier ValueType</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">="</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">https://docs.oasis-open.org/wss/oasis-wss-soap-message-security1.1#ThumbprintSHA1<span style="color: blue;">"&gt;</span><b>9JscCwWHk5IvR/6JLTSayTY7M=</b><span style="color: blue;">&lt;/</span><span style="color: #990000;">o:KeyIdentifier</span><span style="color: blue;">&gt;</span></span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">o:SecurityTokenReference</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">KeyInfo</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">Hence to answer (a) and (b):-<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">a.&nbsp;&nbsp;&nbsp;&nbsp; When passing <span style="color: blue;">&lt;</span><span style="color: #990000;">X509IssuerSerial</span><span style="color: blue;">&gt;</span>, <span style="color: blue;">&lt;</span><span style="color: #990000;">X509Data</span><span style="color: blue;">&gt; </span>element should be child to a <span style="color: blue;">&lt;</span><span style="color: #990000;">o:SecurityTokenReference</span><span style="color: blue;">&gt; </span>element, not <span style="color: blue;">&lt;</span><span style="color: #990000;">KeyInfo</span><span style="color: blue;">&gt; </span>element.<o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">b.&nbsp;&nbsp;&nbsp;&nbsp; When <span style="color: blue;">&lt;</span><span style="color: #990000;">X509Data</span><span style="color: blue;">&gt; </span>is passed as immediate child element to <span style="color: blue;">&lt;</span><span style="color: #990000;">KeyInfo</span><span style="color: blue;">&gt;</span>, its child element should be <span style="color: blue;">&lt;</span><span style="color: #990000;">X509Certificate</span><span style="color: blue;">&gt;</span>. This proves why we see <i>X509CertificateClauseEntry</i> in the exception stack trace.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;</span><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">Now that we know why the response failed at the client end, let&rsquo;s talk about a workaround. A simple workaround will be to modify the incoming response using a custom channel. I will not get into the intricacies of how to write a custom channel in this blog article. That is available under &lsquo;channel extensibility samples&rsquo; </span><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';"><a href="https://msdn.microsoft.com/en-us/library/aa967568%28VS.90%29.aspx"><span style="color: blue;">here</span></a></span><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">. &nbsp;Going by the primary signing token shared earlier:</span><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:KeyInfo</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue; background: none repeat scroll 0% 0% yellow;"><span style="background-color: #ffffff;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000; background: none repeat scroll 0% 0% yellow;">o:SecurityTokenReference</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue; background: none repeat scroll 0% 0% yellow;">&gt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;"> ----------------------- INSERT THIS ELEMENT</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509Data</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509IssuerSerial</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509IssuerName</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">XXXXXXXXXXXXXXXXXXX</span></b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;"> &lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509IssuerName</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509SerialNumber</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <b><span style="font-size: 8pt; font-family: 'Verdana','sans-serif';">74990459506171493075258200981073178724</span></b><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509SerialNumber</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509IssuerSerial</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:X509Data</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="background: none repeat scroll 0% 0% yellow;">&lt;/</span></span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000; background: none repeat scroll 0% 0% yellow;">o:SecurityTokenReference</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue; background: none repeat scroll 0% 0% yellow;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&lt;/</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: #990000;">ds:KeyInfo</span><span style="font-size: 8pt; font-family: 'Verdana','sans-serif'; color: blue;">&gt;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">Following are the steps achieve that (assuming that the message is only signed):</span><span style="font-size: 12pt; font-family: 'Eras Medium ITC','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">&nbsp;</span><span style="font-size: 12pt; font-family: 'Eras Medium ITC','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="text-decoration: underline;"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">A.Operate on a message object to insert necessary element as highlighted above</span></span></b><span style="font-size: 12pt; font-family: 'Eras Medium ITC','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">private</span><span style="font-size: 9.5pt; font-family: Consolas;"> <span style="color: #2b91af;">Message</span> <span style="background: none repeat scroll 0% 0% yellow;">OnReceiveMessage</span>(<span style="color: #2b91af;">Message</span> response)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">{</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;&nbsp;&nbsp;&nbsp; MemoryStream</span><span style="font-size: 9.5pt; font-family: Consolas;"> responseStream = <span style="color: blue;">new</span> MemoryStream();</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;&nbsp;&nbsp;&nbsp; MessageBuffer</span><span style="font-size: 9.5pt; font-family: Consolas;"> responseBuffer = response.CreateBufferedCopy(<span style="color: #2b91af;">Int32</span>.MaxValue);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp; responseBuffer.WriteMessage(responseStream);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp; responseStream.Position = 0;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp; byte</span><span style="font-size: 9.5pt; font-family: Consolas;">[] respArr = responseStream.ToArray();</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp; string</span><span style="font-size: 9.5pt; font-family: Consolas;"> responseMessage = System.Text.<span style="color: #2b91af;">Encoding</span>.ASCII.GetString(respArr);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;&nbsp;&nbsp;&nbsp; XmlDocument</span><span style="font-size: 9.5pt; font-family: Consolas;"> resDom = <span style="color: blue;">new</span> XmlDocument();</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp; resDom.LoadXml(responseMessage);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: green;">&nbsp;&nbsp;&nbsp;&nbsp; /*</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: green;">&nbsp;&nbsp;&nbsp;&nbsp; * Fetch &lt;X509Data&gt; element from the received response message </span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: green;">&nbsp;&nbsp;&nbsp;&nbsp; */</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;&nbsp;&nbsp;&nbsp; XmlNodeList</span><span style="font-size: 9.5pt; font-family: Consolas;"> x509DataElement = resDom.GetElementsByTagName(<span style="color: #a31515;">"X509Data"</span>);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp; bool</span><span style="font-size: 9.5pt; font-family: Consolas;"> modificationRequired = <span style="color: blue;">true</span>;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp; if</span><span style="font-size: 9.5pt; font-family: Consolas;"> (x509DataElement[0].FirstChild.Name.Equals("X509Certificate"))</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp; {</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&nbsp;&nbsp; return</span><span style="font-size: 9.5pt; font-family: Consolas;"> response;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp; else</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp; {</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;&nbsp; modificationRequired = <span style="color: blue;">true</span>;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp; if</span><span style="font-size: 9.5pt; font-family: Consolas;"> (modificationRequired)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp; {</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;&nbsp; XmlElement</span><span style="font-size: 9.5pt; font-family: Consolas;"> securityTokenReference = resDom.CreateElement(<span style="color: #a31515;">"o"</span>, "SecurityTokenReference", WSSecurityURI);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;&nbsp; securityTokenReference.AppendChild(x509DataElement[0]);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;&nbsp; XmlNodeList</span><span style="font-size: 9.5pt; font-family: Consolas;"> keyInfoElement = resDom.GetElementsByTagName(<span style="color: #a31515;">"KeyInfo"</span>);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;&nbsp; keyInfoElement[0].AppendChild(securityTokenReference);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp; string</span><span style="font-size: 9.5pt; font-family: Consolas;"> modifiedResponseMessageStr = resDom.InnerXml;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp; byte</span><span style="font-size: 9.5pt; font-family: Consolas;">[] modifedResponseMessageInBytes = System.Text.Encoding.UTF8.GetBytes(modifiedResponseMessageStr);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;&nbsp;&nbsp;&nbsp; XmlDictionaryReaderQuotas</span><span style="font-size: 9.5pt; font-family: Consolas;"> quotas = <span style="color: blue;">new</span> <span style="color: #2b91af;">XmlDictionaryReaderQuotas</span>();</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;&nbsp;&nbsp;&nbsp; XmlDictionaryReader</span><span style="font-size: 9.5pt; font-family: Consolas;"> reader = XmlDictionaryReader.CreateTextReader(modifedResponseMessageInBytes, quotas);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;&nbsp;&nbsp;&nbsp; Message</span><span style="font-size: 9.5pt; font-family: Consolas;"> newResponseMessage = <span style="color: #2b91af;">Message</span>.CreateMessage(reader, 2147483647, response.Version);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;&nbsp;&nbsp;&nbsp; MessageBuffer</span><span style="font-size: 9.5pt; font-family: Consolas;"> modifiedResponseBuffer = newResponseMessage.CreateBufferedCopy(Int32.MaxValue);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp; return</span><span style="font-size: 9.5pt; font-family: Consolas;"> modifiedResponseBuffer.CreateMessage();&nbsp;&nbsp; </span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">}</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><b><span style="text-decoration: underline;"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">B. Call ReceiveMessage from IRequestChannel.Request method implementation</span></span></b><span style="font-size: 12pt; font-family: 'Eras Medium ITC','sans-serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">public</span><span style="font-size: 9.5pt; font-family: Consolas;"> <span style="color: #2b91af;">Message</span> Request(<span style="color: #2b91af;">Message</span> message)</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">{</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;&nbsp;&nbsp;&nbsp; Message</span><span style="font-size: 9.5pt; font-family: Consolas;"> retmsg = m_InnerRequestChannel.Request(message);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: #2b91af;">&nbsp;&nbsp;&nbsp;&nbsp; MessageBuffer</span><span style="font-size: 9.5pt; font-family: Consolas;"> responseBufferCopy = retmsg.CreateBufferedCopy(<span style="color: #2b91af;">Int16</span>.MaxValue);</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas; color: blue;">&nbsp;&nbsp;&nbsp;&nbsp; return</span><span style="font-size: 9.5pt; font-family: Consolas;"> <span style="background: none repeat scroll 0% 0% yellow;">OnReceiveMessage</span>(responseBufferCopy.CreateMessage());</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 9.5pt; font-family: Consolas;">}</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt;">&nbsp;</span><span style="font-size: 12pt; font-family: 'Times New Roman','serif';"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';">With that we know what X509ReferenceStyles are supported by WCF and how to work around any mismatch arising out of it. Next up we will see interoperability issues arising from </span><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif'; color: blue;">&lt;</span><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif'; color: #990000;">o:BinarySecurityToken</span><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif'; color: blue;">&gt;</span><span style="font-size: 10pt; font-family: 'Eras Medium ITC','sans-serif';"> present within a request security header.</span> </p>]]></content:encoded>
    </item>
    <item>
      <title>SSL Offloader Using WCF 4.0 Routing Service</title>
      <link>https://docs.microsoft.com/archive/blogs/dhrubach/ssl-offloader-using-wcf-4-0-routing-service</link>
      <pubDate>Wed, 02 Jun 2010 15:04:00 GMT</pubDate>
      <dc:creator><![CDATA[dhruba]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhrubach/2010/06/02/ssl-offloader-using-wcf-4-0-routing-service/</guid>
      <description><![CDATA[WCF Routing Service is a new feature introduced with WCF 4.0. While this article is not about...]]></description>
      <content:encoded><![CDATA[<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="text-decoration: underline;"><span style="font-family: 'Verdana','sans-serif';"><o:p><span style="text-decoration: none;"><span style="font-size: small;"></span></span></o:p></span></span></b></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">WCF Routing Service is a new feature introduced with WCF 4.0. While this article is not about explaining what it is (complete details about WCF Routing Service is available </span><a href="https://msdn.microsoft.com/en-us/library/ee517423.aspx"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">here</span></a><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">), I must admit that this new feature is simply awesome. It has made pain points like protocol bridging and handling communication exceptions a no brainer for any developer. Just get your configurations correct, everything else will be taken care of by the routing service. Through this example, I have covered the following features of routing service:<o:p></o:p></span></p>
<p><span style="line-height: normal; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p></o:p></span><span style="line-height: normal; font-family: 'Verdana','sans-serif'; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;"><span style="mso-list: Ignore;"></span></span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p></o:p></span></p>
<p class="MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-<span style="line-height: 115%; font-family: 'Verdana','sans-serif'; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;"><span style="mso-list: Ignore;"><span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Content Based Routing<o:p></o:p></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Verdana','sans-serif'; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;"><span style="mso-list: Ignore;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp; </span></span></span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Error Handling</span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Verdana','sans-serif'; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;"><span style="mso-list: Ignore;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;-<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp; </span></span></span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Protocol Bridging</span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">&nbsp;</span><span style="line-height: 115%; font-family: 'Verdana','sans-serif'; font-size: 10pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: Verdana;"><span style="mso-list: Ignore;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; -<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;</span></span></span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Custom Filters<o:p></o:p></span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p>&nbsp;</o:p></span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">A SSL Offloader is an intermediary device which accepts an incoming HTTPS request, offloads SSL and forwards HTTP traffic to backend servers. Certain SSL Offloaders even do the work of authenticating a client. With the work of authentication delegated away, service performance improves. In this example, SSL Offloader does the following work:<o:p></o:p></span></p>
<p class="MsoListParagraphCxSpFirst">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt; mso-bidi-font-family: 'Eras Medium ITC'; mso-fareast-font-family: 'Eras Medium ITC';"><span style="mso-list: Ignore;">1.<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Receives a HTTPS request from a client.<o:p></o:p></span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt; mso-bidi-font-family: 'Eras Medium ITC'; mso-fareast-font-family: 'Eras Medium ITC';"><span style="mso-list: Ignore;">2.<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Authenticates the client.<o:p></o:p></span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt; mso-bidi-font-family: 'Eras Medium ITC'; mso-fareast-font-family: 'Eras Medium ITC';"><span style="mso-list: Ignore;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Offloads SSL and forwards HTTP request to backend available service.<o:p></o:p></span></p>
<p class="MsoListParagraphCxSpLast"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt; mso-bidi-font-family: 'Eras Medium ITC'; mso-fareast-font-family: 'Eras Medium ITC';"><span style="mso-list: Ignore;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4.<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Load balances incoming requests in round robin manner between 2 backend services.<o:p></o:p></span></p>
<p class="MsoListParagraphCxSpLast"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p>&nbsp;</o:p></span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Now let&rsquo;s get into implementation specifics. In this example, we have 2 backend services: Primary Calculator Service and Secondary Calculator Service. Contracts of both these services are identical to enable round robin load balancing of requests in between these services. Following are their bindings and endpoints:</span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p></o:p></span></p>
<p class="MsoListParagraphCxSpLast"><span style="line-height: 115%; font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p>&nbsp;</o:p></span><b style="mso-bidi-font-weight: normal;"><span style="text-decoration: underline;"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Service Binding</span></span></b></p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="text-decoration: underline;"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"></span></span></b></p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="text-decoration: underline;"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p></o:p></span></span></b></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p>&nbsp;</o:p></span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">basicHttpBinding</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">binding</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">security</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">mode</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">None</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">binding</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">basicHttpBinding</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoListParagraphCxSpLast"><b style="mso-bidi-font-weight: normal;"><span style="text-decoration: underline;"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Primary Service Endpoint</span></span></b></p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="text-decoration: underline;"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p></o:p></span></span></b></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p>&nbsp;</o:p></span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">host</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">baseAddresses</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">add</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">baseAddress</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">https://localhost:8080/PrimaryCalculatorService</span>"<span style="color: blue;">/&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">baseAddresses</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">host</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">endpoint</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">address</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">""<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">binding</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">basicHttpBinding</span>"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">contract</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">ICalculatorContract</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoListParagraphCxSpFirst"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Endpoint of secondary service is identical, only hosted on port 8081. Note the missing</span><span style="line-height: 115%; font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"> </span><span style="line-height: 115%; font-family: Consolas; color: red; font-size: 9.5pt;">bindingConfiguration </span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">property in the endpoint definition. <i style="mso-bidi-font-style: normal;"><span style="color: #0070c0;">This is a new feature of WCF 4.0</span></i>. As long as there is a single binding definition of a given type (in this example basicHttpBinding), there is NO need to link that binding to an endpoint. That binding is considered as the standard binding. Hence no </span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; color: red; font-size: 10pt; mso-bidi-font-family: Consolas;">name </span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">property associated with the binding definition either. If you want to define another binding (say this time with security enabled), you need to give it a name and associate it with a endpoint using bindingConfiguration. There is one another cool feature of WCF 4.0 which I will like to mention here: <i style="mso-bidi-font-style: normal;"><span style="color: #0070c0;">Standard Endpoints</span></i>. More details are available </span><a href="https://msdn.microsoft.com/en-us/library/ee358762.aspx"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">here</span></a><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">. I have used it to define my mex endpoint.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><b style="mso-bidi-font-weight: normal;"><span style="text-decoration: underline;"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"></span></span></b></p>
<p class="MsoListParagraphCxSpLast"><b style="mso-bidi-font-weight: normal;"><span style="text-decoration: underline;"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Standard MEX Endpoint<o:p></o:p></span></span></b></p>
<p class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;"></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">endpoint</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">isSystemEndpoint</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">true</span>"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">kind</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">mexEndpoint</span>"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">address</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">mex</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"></span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Before I get into the SSL Offloader, let&rsquo;s take a look at the client application first. Remember that a client needs to connect over HTTPS and pass some authentication tokens. In this example, we will use UsernameToken. Following is the client binding:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;"></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">customBinding</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">binding</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">security</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">authenticationMode</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">UserNameOverTransport</span>"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">includeTimestamp</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">false</span>"<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">requireDerivedKeys</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">false</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">httpsTransport</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> /&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">binding</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">customBinding</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"></span></p>
<p class="MsoListParagraphCxSpFirst"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Now let&rsquo;s get into SSL Offloader implementation. To reiterate the requirements here:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p></o:p></span></p>
<p class="MsoListParagraphCxSpFirst"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt; mso-bidi-font-family: 'Eras Medium ITC'; mso-fareast-font-family: 'Eras Medium ITC';"><span style="mso-list: Ignore;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;1.<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Communication in between the client and SSL Offloader is over HTTPS.<o:p></o:p></span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt; mso-bidi-font-family: 'Eras Medium ITC'; mso-fareast-font-family: 'Eras Medium ITC';"><span style="mso-list: Ignore;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;2.<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Communication in between the SSL Offloader and calculator service is over HTTP.<o:p></o:p></span></p>
<p class="MsoListParagraphCxSpLast"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt; mso-bidi-font-family: 'Eras Medium ITC'; mso-fareast-font-family: 'Eras Medium ITC';"><span style="mso-list: Ignore;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3.<span style="font: 7pt 'Times New Roman';">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Client authentication is done by the SSL Offloader.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"></span></p>
<p class="MsoListParagraphCxSpLast"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Keeping these in mind, following is the offloader binding:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p>&nbsp;</o:p></span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">wsHttpBinding</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">binding</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">security</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">mode</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Transport</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">transport</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">clientCredentialType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">None</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">security</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">binding</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">wsHttpBinding</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoListParagraphCxSpFirst"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Why is the clientCredentialType set to &lsquo;none&rsquo;? That&rsquo;s where the custom filter comes into picture. It not only routes an incoming request in a round robin fashion, but also authenticates the client. Hence there is no need to implement a custom</span><span style="line-height: 115%; font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"> </span><span style="line-height: 115%; font-family: Consolas; color: #2b91af; font-size: 9.5pt;">UserNamePasswordValidator</span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">. Note the seamless <b style="mso-bidi-font-weight: normal;"><span style="color: #0070c0;">protocol bridging</span></b> which happens here. Routing infrastructure takes care of routing a request from a HTTPS protocol to a HTTP protocol without a single line of application code being written.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p></o:p></span></p>
<p class="MsoListParagraphCxSpLast"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Other implementation details (SSL Offloader and client endpoints) are usual. Let&rsquo;s get to the routing table implementation. This is how the routing table looks like:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">routing</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;"></span></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">filters</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">filter</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">primaryFilter</span>"<span style="color: blue;"> </span><span style="color: red;">filterType</span><span style="color: blue;">=</span>"<span style="color: blue;">Custom</span>"<span style="color: blue;"> </span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;&nbsp;</span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">customType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">SSLOffloaderCustomFilter, SSLOffloaderUsingCustomFilterService</span>"<span style="color: blue;"> </span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;&nbsp;</span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">filterData</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">group1</span>"<span style="color: blue;">/&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">filter</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">secondaryFilter</span>"<span style="color: blue;"> </span><span style="color: red;">filterType</span><span style="color: blue;">=</span>"<span style="color: blue;">Custom</span>"<span style="color: blue;"> </span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">customType</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">SSLOffloaderCustomFilter,SSLOffloaderUsingCustomFilterService</span>"<span style="color: blue;"> </span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">filterData</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">group1</span>"<span style="color: blue;"> /&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">filters</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">filterTables</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">filterTable</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">primaryRoutingTable</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">add</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">filterName</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">primaryFilter</span>"<span style="color: blue;"> </span><span style="color: red;">endpointName</span><span style="color: blue;">=</span>"<span style="color: blue;">primaryCalc</span>"<span style="color: blue;"> <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">backupList</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">primaryBackUp</span>"<span style="color: blue;">/&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">add</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">filterName</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">secondaryFilter</span>"<span style="color: blue;"> </span><span style="color: red;">endpointName</span><span style="color: blue;">=</span>"<span style="color: blue;">secondaryCalc</span>"<span style="color: blue;"> <o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">backupList</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">secondaryBackUp</span>"<span style="color: blue;">/&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">filterTable</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">filterTables</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">backupLists</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">backupList</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">primaryBackUp</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">add</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">endpointName</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">secondaryCalc</span>"<span style="color: blue;">/&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">backupList</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">backupList</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">name</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">secondaryBackUp</span>"<span style="color: blue;">&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">add</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">endpointName</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">primaryCalc</span>"<span style="color: blue;">/&gt;</span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">backupList</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">backupLists</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>&lt;/</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">routing</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&gt;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p></o:p></span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">In addition to the custom filter, note the 2 </span><span style="font-family: 'Eras Medium ITC','sans-serif'; color: #a31515; font-size: 10pt; mso-bidi-font-family: Consolas;">backupList</span><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">. It implements <b style="mso-bidi-font-weight: normal;"><span style="color: #0070c0;">exception handling</span></b> by routing a request to backup endpoint when primary endpoint is unavailable. Simple, isn&rsquo;t it? To know more about error handling by routing service, refer </span><a href="https://msdn.microsoft.com/en-us/library/ee816886.aspx"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">here</span></a><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Now let&rsquo;s move to custom filter implementation details. Since I will not get into the basics of implementing a custom filter, I will recommend everyone to review &lsquo;<b style="mso-bidi-font-weight: normal;"><span style="color: #0070c0;">Advanced Filters</span></b>&rsquo; sample available with WCF 4.0 samples. 2 important works are performed by this custom filter:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p></o:p></span></p>
<p class="MsoListParagraphCxSpLast"><b style="mso-bidi-font-weight: normal;"><span style="text-decoration: underline;"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Client Authentication<o:p></o:p></span></span></b></p>
<p class="MsoNormal"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p></o:p></span></p>
<p class="MsoListParagraphCxSpLast"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">What we do here is read the security header and validate the username and password tokens.</span><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"> <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">private</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">bool</span> ValidateClientCredentials(<span style="color: #2b91af;">Message</span> requestMessage)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: #2b91af; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MemoryStream</span><span style="font-family: Consolas; font-size: 9.5pt;"> stream = <span style="color: blue;">new</span> <span style="color: #2b91af;">MemoryStream</span>();<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: #2b91af; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; MessageBuffer</span><span style="font-family: Consolas; font-size: 9.5pt;"> buffer = requestMessage.CreateBufferedCopy(<span style="color: #2b91af;">Int32</span>.MaxValue);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>buffer.WriteMessage(stream);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>stream.Position = 0;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">byte</span>[] requestByte = stream.ToArray();<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">string</span> requestStr = System.Text.<span style="color: #2b91af;">Encoding</span>.UTF8.GetString(requestByte);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #2b91af;">XmlDocument</span> doc = <span style="color: blue;">new</span> <span style="color: #2b91af;">XmlDocument</span>();<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>doc.LoadXml(requestStr);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #2b91af;">XmlNodeList</span> securityNode = doc.GetElementsByTagName(<span style="color: #a31515;">"o:Security"</span>);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">if</span> (securityNode.Count == 0)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;throw</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">InvalidOperationException</span>(<span style="color: #a31515;">"No security header is available in the incoming request"</span>);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </o:p></span><span style="font-family: Consolas; color: #2b91af; font-size: 9.5pt;">XmlNodeList</span><span style="font-family: Consolas; font-size: 9.5pt;"> usernameNode = doc.GetElementsByTagName(<span style="color: #a31515;">"o:Username"</span>);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: #2b91af;">XmlNodeList</span> passwordNode = doc.GetElementsByTagName(<span style="color: #a31515;">"o:Password"</span>);</span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">if</span> (usernameNode.Count == 0 || passwordNode.Count == 0)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">InvalidOperationException</span>(<span style="color: #a31515;">"No username or password present in the incoming request"</span>);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span>( <span style="color: blue;">string</span>.IsNullOrEmpty(usernameNode[0].InnerText) || <span style="color: blue;">string</span>.IsNullOrEmpty(passwordNode[0].InnerText))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; throw</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">new</span> <span style="color: #2b91af;">ArgumentNullException</span>(<span style="color: #a31515;">"Username / Password cannot be null or empty"</span>);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; else</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span>(usernameNode[0].InnerText.Equals(<span style="color: #a31515;">"Microsoft"</span>) &amp;&amp; passwordNode[0].InnerText.Equals(<span style="color: #a31515;">"Microsoft"</span>))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="mso-tab-count: 1;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">return</span> <span style="color: blue;">true</span>;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-tab-count: 1;"></span><span style="color: blue;">return</span> <span style="color: blue;">false</span>;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">}</span><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">This method is called from all implementations of </span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; color: #2b91af; font-size: 10pt; mso-bidi-font-family: Consolas;">IMessageFilterTable</span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt; mso-bidi-font-family: Consolas;">&lt;FilterData&gt;.GetMatchingXXX </span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">methods. One such implementation is as follows:</span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt; mso-bidi-font-family: Consolas;">&nbsp;</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">bool</span> GetMatchingFilter(System.ServiceModel.Channels.<span style="color: #2b91af;">MessageBuffer</span> messageBuffer, <span style="color: blue;">out</span> <span style="color: #2b91af;">MessageFilter</span> filter)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filter = <span style="color: blue;">null</span>;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">if</span><span style="font-family: Consolas; font-size: 9.5pt;">(ValidateClientCredentials(messageBuffer.CreateMessage()))<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; filter = GetNextAvailableFilter();<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; return</span><span style="font-family: Consolas; font-size: 9.5pt;"> (filter!= <span style="color: blue;">null</span>);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: #2b91af; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Since we are operating on the message body, we need to set the following highlighted property to false inside service behaviors:</span><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&lt;</span><span style="font-family: Consolas; color: #a31515; font-size: 9.5pt;">routing</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;"> </span><span style="font-family: Consolas; color: red; font-size: 9.5pt;">filterTableName</span><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">primaryRoutingTable</span>"<span style="color: blue;"> </span><span style="background: yellow; color: red; mso-highlight: yellow;">routeOnHeadersOnly</span><span style="background: yellow; color: blue; mso-highlight: yellow;">=</span><span style="background: yellow; mso-highlight: yellow;">"<span style="color: blue;">false</span>"</span><span style="color: blue;">/&gt;<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p></o:p></span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">This makes sure that only those variants of GetMatchingXXX are called by runtime whose 1<sup>st</sup> parameter is a </span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; color: #2b91af; font-size: 10pt; mso-bidi-font-family: Consolas;">MessageBuffer</span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"> type. This ensures that we do not directly operate on an incoming </span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; color: #2b91af; font-size: 10pt; mso-bidi-font-family: Consolas;">Message</span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"> object since a </span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; color: #2b91af; font-size: 10pt; mso-bidi-font-family: Consolas;">Message </span><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">object is a read &ndash; once type.</span><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoListParagraphCxSpLast"><b style="mso-bidi-font-weight: normal;"><span style="text-decoration: underline;"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">Round Robin Load Balancing<o:p></o:p></span></span></b></p>
<p class="MsoNormal"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;"><o:p></o:p></span></p>
<p class="MsoListParagraphCxSpLast"><span style="font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">This is implemented inside the following private method inside filter table inner class:</span><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: #2b91af; font-size: 9.5pt;">List</span><span style="font-family: Consolas; font-size: 9.5pt;">&lt;<span style="color: #2b91af;">SSLOffloaderCustomFilter</span>&gt; filters = <span style="color: blue;">new</span> <span style="color: #2b91af;">List</span>&lt;<span style="color: #2b91af;">SSLOffloaderCustomFilter</span>&gt;();<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">int</span><span style="font-family: Consolas; font-size: 9.5pt;"> filterIndex = 0;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">private</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">SSLOffloaderCustomFilter</span> GetNextAvailableFilter()<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: #2b91af; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; SSLOffloaderCustomFilter</span><span style="font-family: Consolas; font-size: 9.5pt;"> returnedFilter = <span style="color: blue;">null</span>;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">int</span> currentIndex = filterIndex;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">for</span> (<span style="color: blue;">int</span> i = currentIndex + 1; i &lt; filters.Count; i++)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-tab-count: 1;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>returnedFilter = filters[i];<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-tab-count: 1;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>filterIndex = i;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; color: blue; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if</span><span style="font-family: Consolas; font-size: 9.5pt;"> (returnedFilter == <span style="color: blue;">null</span>)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-tab-count: 1;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">for</span> (<span style="color: blue;">int</span> i = 0; i &lt; currentIndex + 1; i++)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>{<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-tab-count: 1;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>returnedFilter = filters[i];<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>filterIndex = i;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">break</span>;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">return</span> returnedFilter;<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-family: Consolas; font-size: 9.5pt;">}</span><span style="font-family: 'Verdana','sans-serif'; font-size: 8.5pt;"><o:p>&nbsp;</o:p></span></p>
<p class="MsoListParagraphCxSpMiddle"><span style="line-height: 115%; font-family: 'Eras Medium ITC','sans-serif'; font-size: 10pt;">As the name of the method indicates, all I am doing here is to choose one of the filters in a round robin fashion. With this I have covered the important implementation details which went behind developing this SSL Offloader example. Hope this demonstrates how awesome WCF 4.0 Routing Service is. </span></p>
<p>&nbsp;</p>]]></content:encoded>
    </item>
    <item>
      <title>Manipulate a WCF request / response using a custom encoder</title>
      <link>https://docs.microsoft.com/archive/blogs/dhrubach/manipulate-a-wcf-request-response-using-a-custom-encoder</link>
      <pubDate>Wed, 06 Jan 2010 15:45:00 GMT</pubDate>
      <dc:creator><![CDATA[dhruba]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhrubach/2010/01/06/manipulate-a-wcf-request-response-using-a-custom-encoder/</guid>
      <description><![CDATA[Message Encoders are an interesting component within WCF channel stack. It’s primary job is to...]]></description>
      <content:encoded><![CDATA[<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Message Encoders are an interesting component within WCF channel stack. It’s primary job is to transform Message instances to and from the wire. While it has an independent existence within a WCF binding stack in the form of a Message Encoding binding element, in essence it is closely integrated with the underlying transport layer. This is unlike to any other binding elements, example a security binding element. Check out this MSDN </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><A href="https://msdn.microsoft.com/en-us/library/aa751889.aspx"><SPAN style="COLOR: blue; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri">article</SPAN></A></SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> on message encoders for more details.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Today I will concentrate my discussion on custom encoders. I will present a very simple example to demonstrate the power of a custom encoder to resolve a seemingly complex scenario. For those who are yet to work with custom encoders, you can find more details </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><A href="https://msdn.microsoft.com/en-us/library/ms735115.aspx"><SPAN style="COLOR: blue; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri">here</SPAN></A></SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">. There is also a MSDN </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><A href="https://msdn.microsoft.com/en-us/library/ms751486.aspx"><SPAN style="COLOR: blue; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri">sample</SPAN></A></SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> which demonstrates a custom text encoder.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Consider a scenario where you are trying to consume a non - .NET web service from a WCF client application over MTOM. The client is configured with the following binding:<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">customBinding</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">binding</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">name</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">CustomTransferUsingMTOM</SPAN>"<SPAN style="COLOR: blue">&gt;<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">mtomMessageEncoding</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">maxBufferSize</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">65536</SPAN>"<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">messageVersion</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">Soap12WSAddressing10</SPAN>"<SPAN style="COLOR: blue"> /&gt;<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">httpTransport</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">authenticationScheme</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">Anonymous</SPAN>"<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">maxReceivedMessageSize</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">2147483647</SPAN>"<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">maxBufferSize</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">2147483647</SPAN>"<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">transferMode</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">Buffered</SPAN>"<SPAN style="COLOR: blue"> /&gt;<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">binding</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">customBinding</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;</SPAN><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Ideally things should work if both the participating components have identical implementation of the same standards. More often than not, things don’t follow the ideal path. In this scenario, a MTOM encoded response from the web service fails with the following exception:<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #990000; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">ExceptionType</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-weight: bold; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">System.Xml.XmlException, System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #990000; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">ExceptionType</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #990000; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Message</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: yellow; FONT-SIZE: 9pt; mso-highlight: yellow; mso-bidi-font-weight: bold; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Root MIME part must contain non-zero length value for 'charset' parameter in Content-Type header</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-weight: bold; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">.</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #990000; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Message</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #990000; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">StackTrace</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-weight: bold; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">at System.Xml.XmlMtomReader.ReadRootContentTypeHeader(ContentTypeHeader header, Encoding[] expectedEncodings, String expectedType)</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-weight: bold; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">at System.Xml.XmlMtomReader.Initialize(Stream stream, String contentType, XmlDictionaryReaderQuotas quotas, Int32 maxBufferSize)</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-weight: bold; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">at System.Xml.XmlMtomReader.SetInput(Stream stream, Encoding[] encodings, String contentType, XmlDictionaryReaderQuotas quotas, Int32 maxBufferSize, OnXmlDictionaryReaderClose onClose)</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-weight: bold; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">at System.Xml.XmlDictionaryReader.CreateMtomReader(Stream stream, Encoding[] encodings, String contentType, XmlDictionaryReaderQuotas quotas, Int32 maxBufferSize, OnXmlDictionaryReaderClose onClose)</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-bidi-font-weight: bold; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">at System.ServiceModel.Channels.MtomMessageEncoder.TakeStreamedReader(Stream stream, String contentType)</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #990000; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">StackTrace</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Let’s have a look at the incoming response to get a better understanding of things:<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">HTTP/1.0 200 OK<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: yellow; COLOR: #002060; FONT-SIZE: 8pt; mso-highlight: yellow; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Content-Type</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">: multipart/related;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">boundary="----=_Part_1_31588834.1260459496767";<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">start="&lt;88a8d13e5330b97c125391cf9ba&gt;"; start-info="application/soap+xml";<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">type="application/xop+xml"; <SPAN style="BACKGROUND: yellow; mso-highlight: yellow">charset=UTF-8</SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">MIME-Version: 1.0<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Content-Length: 309045<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN><SPAN style="mso-tab-count: 1"> </SPAN>------=_Part_1_31588834.1260459496767<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1"></SPAN><SPAN style="BACKGROUND: yellow; mso-highlight: yellow">content-type: application/xop+xml; type="application/soap+xml"</SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1"></SPAN>content-transfer-encoding: binary<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1"></SPAN>content-id: &lt;88a8d13e5330b97c125391cf9ba&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1"></SPAN>&lt;?xml version="1.0" encoding="UTF-8"?&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1"></SPAN>&lt;SOAP-ENV:Envelope xmlns:SOAP-ENV="<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>…………………………<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;/SOAP-ENV:Envelope&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1"></SPAN>------=_Part_1_31588834.1260459496767<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1"></SPAN>content-type: application/octet-stream<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1"></SPAN>content-transfer-encoding: binary<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1"></SPAN>content-id: &lt;19e0ed854e021b83125391cf9bb&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #002060; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Base64Encoded data goes here<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">From the highlighted error message above, one can understand that the issue is with missing ‘<I style="mso-bidi-font-style: normal">charset</I>’ parameter in Content-Type header. Check the root MIME header portion (highlighted above). Even though a charset parameter is present as part of HTTP header, <I style="mso-bidi-font-style: normal">it is indeed missing in the root MIME header</I>. WCF does not like that. There are 2 ways to go about here: either we modify the service to generate a working response or we customize the WCF client so that it accepts this response. We will discuss about the later option. That’s where a custom encoder comes into picture.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">With the help of a custom encoder we can modify the response to accommodate a charset parameter in the correct place. This is not possible either with a message inspector or a custom channel as either works on a Message instance. Note the error is thrown before a </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Message </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">instance is created by MTOM encoder. Primary customization will go inside ReadMessage method</SPAN><SPAN style="FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"><FONT face=Calibri>:<o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">public</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> <SPAN style="COLOR: blue">override</SPAN> <SPAN style="COLOR: #2b91af">Message</SPAN> ReadMessage(<SPAN style="COLOR: #2b91af">ArraySegment</SPAN>&lt;<SPAN style="COLOR: blue">byte</SPAN>&gt; buffer, <SPAN style="COLOR: #2b91af">BufferManager</SPAN> bufferManager, <SPAN style="COLOR: blue">string</SPAN> contentType)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Algorithm we need to follow out here:<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto" class=MsoNormalCxSpMiddle><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-bidi-language: BN">-</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 7pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: Calibri; mso-bidi-language: BN">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Convert ArraySegment&lt;byte&gt; buffer into a string<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto" class=MsoNormalCxSpMiddle><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-bidi-language: BN">-</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 7pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: Calibri; mso-bidi-language: BN">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Manipulate generated string to accommodate the charset parameter<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.75in; mso-add-space: auto" class=MsoNormalCxSpMiddle><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: Calibri; mso-bidi-language: BN">-</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 7pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: Calibri; mso-bidi-language: BN">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Recreate ArraySegment&lt;byte&gt; and pass it back to the mtomencoder by calling </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">MtomMessageEncoder.</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">ReadMessage.</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> <o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><I style="mso-bidi-font-style: normal"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Things become interesting if you have a binary data imbedded in the response, for example an image</SPAN></I><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">. In that case the first step becomes critical. Ideally we will use the following code to generate a string:<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">byte</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">[] incomingResponse = buffer.Array;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">string</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> str = System.Text.<SPAN style="COLOR: #2b91af">Encoding</SPAN>.UTF8.GetString(incomingResponse);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">This will work for a text attachment, not for an image. This will not generate any runtime errors though. WCF client will be able to process the response (which means that the issue with ‘<I style="mso-bidi-font-style: normal">charset</I>’ parameter is resolved). However the downloaded binary image, present in the response, will be <B style="mso-bidi-font-weight: normal">corrupt</B>. That is because of the encoding format used in the above line. We cannot convert a base64encoded image into string via UTF-8 encoding. If we want to retain the encoding, we need to use </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Convert</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-no-proof: yes; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">.ToBase64String</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">. In that case, we will not be able to perform any string manipulation operations. <o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">I decided to overcome this catch22 situation by converting the first ‘n’ bytes of an incoming response into string, instead of the entire response. This makes sense in this particular scenario since the size of the response till root MIME header will more or less be constant. Hence I wrote the following code piece which does the job of inserting a ‘<I style="mso-bidi-font-style: normal">charset</I>’ parameter into a ‘Content-Type’ header:<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">//Convert the received buffer into a string<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">byte</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">[] incomingResponse = buffer.Array;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">//read the first 500 bytes of the response<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">string</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> strFirst500 = System.Text.<SPAN style="COLOR: #2b91af">Encoding</SPAN>.UTF8.GetString(incomingResponse, 0, 500);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">/*<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">* Check the last occurance of 'application/xop+xml' in the response. We check for the last <o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">* occurrence since the first one is present in the Content-Type HTTP Header. Once found, <o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">* append charset header to this string<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">*/<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">int</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> appIndex = strFirst500.LastIndexOf(<SPAN style="COLOR: #a31515">"application/xop+xml"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">modifiedResponse = strFirst500.Insert(appIndex + 19, <SPAN style="COLOR: #a31515">"charset=utf-8"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">//convert the modified string back into a byte array<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">byte</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">[] ma = System.Text.<SPAN style="COLOR: #2b91af">Encoding</SPAN>.UTF8.GetBytes(modifiedResponse);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">//integrate the modified byte array back to the original byte array<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">int</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> increasedLength = ma.Length - 500;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">byte</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">[] newArray = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: blue">byte</SPAN>[incomingResponse.Length + increasedLength];<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">for</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> (<SPAN style="COLOR: blue">int</SPAN> count = 0; count &lt; newArray.Length; count++)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">if</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> (count &lt; ma.Length)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>newArray[count] = ma[count];<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">else<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>newArray[count] = incomingResponse[count - increasedLength];<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">/*<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">* In this part generate a new ArraySegment&lt;byte&gt; buffer and pass it to the underlying MTOM <o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">* Encoder.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">*/<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">int</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> size = newArray.Length;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">byte</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">[] msg = manager.TakeBuffer(size);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Array</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">.Copy(newArray, msg, size);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">ArraySegment</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;<SPAN style="COLOR: blue">byte</SPAN>&gt; newResult = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ArraySegment</SPAN>&lt;<SPAN style="COLOR: blue">byte</SPAN>&gt;(msg);</SPAN><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">With that we have resolved an interop issue using a custom encoder.<SPAN style="mso-spacerun: yes">&nbsp; </SPAN>Likewise we can extrapolate the usage of a custom encoder to other scenarios where we need to operate on a request / response prior to it being acted upon by an encoder.</SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>]]></content:encoded>
    </item>
    <item>
      <title>Change the way you define your identity with .NET 3.5 SP1</title>
      <link>https://docs.microsoft.com/archive/blogs/dhrubach/change-the-way-you-define-your-identity-with-net-3-5-sp1</link>
      <pubDate>Thu, 24 Dec 2009 08:16:00 GMT</pubDate>
      <dc:creator><![CDATA[dhruba]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhrubach/2009/12/24/change-the-way-you-define-your-identity-with-net-3-5-sp1/</guid>
      <description><![CDATA[A service’s endpoint identity is an important entity in an authentication process. Any WCF developer...]]></description>
      <content:encoded><![CDATA[<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">A service’s endpoint identity is an important entity in an authentication process. Any WCF developer should have a good understanding of what it is, how it is set at the service and client and what part it plays in the overall authentication process. For those in doubt, MSDN article on ‘<I style="mso-bidi-font-style: normal"><A href="https://msdn.microsoft.com/en-us/library/ms733130.aspx"><SPAN style="COLOR: blue">Service Identity and Authentication</SPAN></A></I>’ will surely make a lot of those things clear.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Today I will concentrate my discussion on how a service’s endpoint identity can be set within a client application. Most common approach will be to configure it within a client configuration file, enclosed within a &lt;identity&gt; element. For the sake of the topic, I will consider the following binding:<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">wsHttpBinding</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">binding</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">name</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">Message_Windows</SPAN>"<SPAN style="COLOR: blue">&gt;<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">security</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">mode</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> =</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">Message</SPAN>"<SPAN style="COLOR: blue">&gt;<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">message</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">clientCredentialType</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">Windows</SPAN>"<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">establishSecurityContext</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">false</SPAN>"<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;</SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">negotiateServiceCredential</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">false</SPAN>"<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">algorithmSuite</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">Basic128</SPAN>"<SPAN style="COLOR: blue">/&gt;<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">security</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">binding</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">wsHttpBinding</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;</SPAN><SPAN style="FONT-SIZE: 8pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"><FONT face=Calibri> <o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Let’s say that my service is hosted on IIS and the application pool is running under a custom service account. I have a HTTP SPN associated with that service account. Check this </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><A href="https://blogs.iis.net/brian-murphy-booth/archive/2007/03/09/the-biggest-mistake-serviceprincipalname-s.aspx"><SPAN style="COLOR: blue; mso-bidi-font-family: Calibri">blog</SPAN></A></SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> for more insights into SPN.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Account name: somedomain\tyler<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>Configured SPN: HTTP/tyler.durden.com<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Going back to how we can provide this information inside a client configuration file:<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">client</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">endpoint</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">address</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">https://somedomain.com/SimpleKerberosTest/Service.svc</SPAN>"<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">binding</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">wsHttpBinding</SPAN>"<SPAN style="COLOR: blue"> </SPAN><SPAN style="COLOR: red">bindingConfiguration</SPAN><SPAN style="COLOR: blue">=</SPAN>"<SPAN style="COLOR: blue">Message_Windows</SPAN>"<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">contract</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">ServiceReference.IService</SPAN>"<SPAN style="COLOR: blue"> </SPAN><SPAN style="COLOR: red">name</SPAN><SPAN style="COLOR: blue">=</SPAN>"<SPAN style="COLOR: blue">WSHttpBinding_IService</SPAN>"<SPAN style="COLOR: blue">&gt;<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">identity</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="BACKGROUND: yellow; mso-highlight: yellow">&lt;</SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: yellow; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-highlight: yellow; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">servicePrincipalName</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-highlight: yellow; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: yellow; COLOR: red; FONT-SIZE: 8pt; mso-no-proof: yes; mso-highlight: yellow; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">value</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-highlight: yellow; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: yellow; FONT-SIZE: 8pt; mso-no-proof: yes; mso-highlight: yellow; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"<SPAN style="COLOR: blue">HTTP/tyler.durden.com</SPAN>"<SPAN style="COLOR: blue"> /&gt;</SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">identity</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">endpoint</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #a31515; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">client</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">All we need now is to instantiate a service proxy within our client application passing to it this endpoint configuration name.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 9pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">ServiceClient</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> proxy = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ServiceClient</SPAN>(<SPAN style="COLOR: #a31515">"WSHttpBinding_IService"</SPAN>);</SPAN><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 9pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Console</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">.WriteLine(proxy.GetData(10));<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Sometimes there is a necessity for us to pass the endpoint address dynamically via the code. That can easily be accomplished by using any of </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-no-proof: yes; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">System.ServiceModel.<SPAN style="COLOR: #2b91af">ClientBase</SPAN>&lt;T&gt; </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">constructors which accept a </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">EndpointAddress </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">object as one of its parameters. <o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 9pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">ServiceClient</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> proxy = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ServiceClient</SPAN>(<SPAN style="COLOR: #a31515">"WSHttpBinding_IService",</SPAN></SPAN><FONT face=Calibri><SPAN style="COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"> </SPAN><SPAN style="COLOR: #c00000; FONT-SIZE: 10pt; mso-no-proof: yes; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri">&lt;EndpointAddress object&gt; or remote endpoint as a string input</SPAN></FONT><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 9pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">);</SPAN><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">This whole scenario works like a charm in .NET 3.5. With the application of SP1, the same scenario fails with the following exception message:<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">ExceptionType</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">System.ServiceModel.Security.MessageSecurityException, System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">ExceptionType</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Message</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">The token provider cannot get tokens for target 'https://somedomain.com/SimpleKerberosTest/Service.svc'.</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Message</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Inner Exception Details:<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">ExceptionString</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">System.ComponentModel.Win32Exception: The specified target is unknown or unreachable</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">ExceptionString</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">NativeErrorCode</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">80090303</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">NativeErrorCode</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">How does the same environment now start complaining about an unreachable or unknown target? Collect WCF trace for the error and have a look at the determined identity (collect verbose tracing and look for ‘<I style="mso-bidi-font-style: normal">Identity was determined for an EndpointReference</I>’):<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Identity </SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: red; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">xmlns</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">="</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: red; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">https://schemas.xmlsoap.org/ws/2006/02/addressingidentity</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 8pt; mso-highlight: yellow; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; BACKGROUND: yellow; COLOR: #990000; FONT-SIZE: 8pt; mso-highlight: yellow; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Dns</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 8pt; mso-highlight: yellow; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> <SPAN style="BACKGROUND: yellow; mso-highlight: yellow">somedomain.com</SPAN></SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 8pt; mso-highlight: yellow; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> &lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; BACKGROUND: yellow; COLOR: #990000; FONT-SIZE: 8pt; mso-highlight: yellow; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Dns</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 8pt; mso-highlight: yellow; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Identity</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">EndpointReference </SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: red; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">xmlns</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">="</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: red; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">https://www.w3.org/2005/08/addressing</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Address</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> https://somedomain.com/SimpleKerberosTest/Service.svc</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Address</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">EndpointReference</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">To our surprise what we see is a DNS generated by the framework. It then appends ‘HOST’ to this value to generate a SPN identity (<SPAN style="BACKGROUND: yellow; mso-highlight: yellow">HOST/somedomain.com</SPAN>). Eventually a HOST SPN is submitted by the client to active directory in request for a service ticket. In my test environment, I do not have any HOST SPNs registered. Hence the error message ‘target is unknown or unreachable’. Usually a HOST SPN will be associated with a computer account. In that scenario, the same request will fail with either of the following error messages:<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><I style="mso-bidi-font-style: normal"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 9pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">The HTTP request is unauthorized with client authentication scheme 'Negotiate'. The authentication header received from the server was 'Negotiate oYG7MIG4oAMKAQGigbAEga1ggaoGCSqGSIb3EgECAgMAfoGaMIGXoAMCAQWhAwIBHqQRGA8yMDA4MDgxNDEwMzk0OVqlBQIDBlSwpgMCASmpJRsjUEFSVFRFU1QuRVhUUkFORVRURVNULk1JQ1JPU09GVC5DT02qRTBDoAMCAQOhPDA6GwRob3N0GzJuZ2ltdHdpcGNybWFwcC5wYXJ0dGVzdC5leHRyYW5ldHRlc3QubWljcm9zb2Z0LmNvbQ<o:p></o:p></SPAN></I></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 9pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 9pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">OR<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 9pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><I style="mso-bidi-font-style: normal"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 9pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">The remote server returned an error: (401) Unauthorized<o:p></o:p></SPAN></I></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">This proves that with the application of SP1, we do not read the identity element from the client configuration file. This is a DESIGN CHANGE implemented with SP1. However one will encounter this issue only when using a ClientBase&lt;T&gt; which accepts a remote address as one of its parameters. <o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Good news is that we have a couple very simple workarounds to resolve this issue:</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-add-space: auto" class=MsoNormalCxSpMiddle><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">1.</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 7pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Use ChannelFactory to create a proxy.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoNormalCxSpMiddle><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none; mso-add-space: auto" class=MsoNormalCxSpMiddle><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">IService</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> proxy = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-add-space: auto" class=MsoNormalCxSpMiddle><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">ChannelFactory</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;<SPAN style="COLOR: #2b91af">IService</SPAN>&gt; factory = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">EndpointIdentity</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> identity = <SPAN style="BACKGROUND: yellow; COLOR: #2b91af; mso-highlight: yellow">EndpointIdentity</SPAN><SPAN style="BACKGROUND: yellow; mso-highlight: yellow">.CreateSpnIdentity(<SPAN style="COLOR: #a31515">"HTTP/tyler.durden.com"</SPAN>);</SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 1.5pt; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">EndpointAddress</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> address = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">EndpointAddress</SPAN>(<SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">Uri</SPAN>(<SPAN style="COLOR: #a31515">"https://somedomain.com/SimpleKerberosTest/Service.svc"</SPAN>), identity);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="BACKGROUND: yellow; mso-highlight: yellow">factory = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ChannelFactory</SPAN>&lt;<SPAN style="COLOR: #2b91af">IService</SPAN>&gt;(<SPAN style="COLOR: #a31515">"WSHttpBinding_IService"</SPAN>, address);</SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">proxy = factory.CreateChannel();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-add-space: auto" class=MsoNormalCxSpMiddle><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Console</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">.WriteLine(proxy.GetData(10));</SPAN><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-SIZE: 9pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"><FONT face=Calibri><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></FONT></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">In the above scenario, the only limitation is hard coding of identity inside the code. That can easily be altered by reading the value from a configuration file.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 0.5in; mso-add-space: auto" class=MsoNormalCxSpMiddle><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">2.</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 7pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Use a dummy proxy to read the identity value from configuration file and use it to create another proxy object.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-add-space: auto" class=MsoNormalCxSpMiddle><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-add-space: auto" class=MsoNormalCxSpMiddle><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">ServiceClient</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> proxy = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ServiceClient</SPAN>(<SPAN style="COLOR: #a31515">"WSHttpBinding_IService"</SPAN>);</SPAN><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 8pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: yellow; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-highlight: yellow; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">EndpointIdentity</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; BACKGROUND: yellow; FONT-SIZE: 8pt; mso-no-proof: yes; mso-highlight: yellow; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> identity = proxy.Endpoint.Address.Identity;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">EndpointAddress</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> address = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">EndpointAddress</SPAN>(<SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">Uri</SPAN>(<SPAN style="COLOR: #a31515">"https://somedomain.com/SimpleKerberosTest/Service.svc "</SPAN>), identity);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">ServiceClient</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> newProxy = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: #2b91af">ServiceClient</SPAN>(<SPAN style="COLOR: #a31515">"WSHttpBinding_IService"</SPAN>, address);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Console</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">.WriteLine(proxy.GetData(10));<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><FONT face=Calibri><SPAN style="FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN; mso-ascii-font-family: Calibri; mso-hansi-font-family: Calibri"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></FONT></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">This way we can read the identity element from configuration file as well as set endpoint address dynamically via code.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Either ways will result in the client using correct SPN to submit to active directory. Now if you look into WCF trace one more time, you will see correct SPN:<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">EndpointReference </SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: red; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">xmlns</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">="</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: red; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">https://www.w3.org/2005/08/addressing</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Address</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> https://somedomain.com/SimpleKerberosTest/Service.svc</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"> &lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Address</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Identity </SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: red; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">xmlns</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">="</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: red; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">https://schemas.xmlsoap.org/ws/2006/02/addressingidentity</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">"&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 8pt; mso-highlight: yellow; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; BACKGROUND: yellow; COLOR: #990000; FONT-SIZE: 8pt; mso-highlight: yellow; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Spn</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 8pt; mso-highlight: yellow; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; BACKGROUND: yellow; FONT-SIZE: 8pt; mso-highlight: yellow; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">HTTP/tyler.durden.com</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 8pt; mso-highlight: yellow; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; BACKGROUND: yellow; COLOR: #990000; FONT-SIZE: 8pt; mso-highlight: yellow; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Spn</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; BACKGROUND: yellow; COLOR: blue; FONT-SIZE: 8pt; mso-highlight: yellow; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">Identity</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">EndpointReference</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN">While it was pretty simple for me to figure out why was the request failing (due to incorrect SPN), but it took me quite a while to figure out that it was a design change implemented by SP1. Hope this will save others a lot of precious time.</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'; mso-bidi-language: BN"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P>]]></content:encoded>
    </item>
    <item>
      <title>Issued Tokens Renewal : Get your token expiration time set correctly by STS</title>
      <link>https://docs.microsoft.com/archive/blogs/dhrubach/issued-tokens-renewal-get-your-token-expiration-time-set-correctly-by-sts</link>
      <pubDate>Mon, 14 Dec 2009 01:23:00 GMT</pubDate>
      <dc:creator><![CDATA[dhruba]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhrubach/2009/12/14/issued-tokens-renewal-get-your-token-expiration-time-set-correctly-by-sts/</guid>
      <description><![CDATA[Working with issued token is always fun. The whole possibility of making 3 components (client, RP...]]></description>
      <content:encoded><![CDATA[<SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">
<P style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial">Working with issued token is always fun. The whole possibility of making 3 components (client, RP and STS) to work seamlessly excites me to no end. Of late I worked on an interesting token renewal issue where the client was not requesting a new SAML token from the STS, even after expiration. An effect of that was client authentication failure at the service end as the presented token had already expired. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial">Exception thrown by the service:<o:p></o:p></SPAN></P></SPAN>
<P style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">ExceptionType</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&gt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; BACKGROUND: yellow; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-bidi-font-weight: bold; mso-highlight: yellow">System.IdentityModel.Tokens.SecurityTokenException</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-bidi-font-weight: bold">, System.IdentityModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">ExceptionType</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">Message</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&gt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-bidi-font-weight: bold">The SamlToken is not time valid. The current time '9/22/2009 6:54:35 PM' is outside the Effective '9/22/2009 6:53:54 PM' and Expiration '9/22/2009 6:54:24 PM' time of the token.</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">Message</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">StackTrace</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-bidi-font-weight: bold">at System.IdentityModel.Selectors.SamlSecurityTokenAuthenticator.ValidateTokenCore(SecurityToken token)</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-bidi-font-weight: bold">at System.IdentityModel.Selectors.SecurityTokenAuthenticator.ValidateToken(SecurityToken token)</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-bidi-font-weight: bold">at System.ServiceModel.Security.ReceiveSecurityHeader.ReadToken(XmlReader reader, SecurityTokenResolver tokenResolver, IList`1 allowedTokenAuthenticators, SecurityTokenAuthenticator&amp;amp; usedTokenAuthenticator)</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-bidi-font-weight: bold">at System.ServiceModel.Security.ReceiveSecurityHeader.ReadToken(XmlDictionaryReader reader, Int32 position, Byte[] decryptedBuffer, SecurityToken encryptionToken, String idInEncryptedForm, TimeSpan timeout)</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-bidi-font-weight: bold">at System.ServiceModel.Security.ReceiveSecurityHeader.ExecuteFullPass(XmlDictionaryReader reader)</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana; mso-bidi-font-weight: bold">at System.ServiceModel.Security.ReceiveSecurityHeader.Process(TimeSpan timeout)</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">StackTrace</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&gt;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-ansi-language: EN-US; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">Initial thought was that a lifetime of a SAML token was governed by the attributes set inside&nbsp;<SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial">&lt;saml:Condition&gt; element :<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt"></SPAN></SPAN><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">saml:Conditions NotBefore</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">="</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">2009-09-22T18:53:54.425Z</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">" </SPAN><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">NotOnOrAfter</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">="</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">2009-09-22T18:54:24.425Z</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">"&gt;&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">saml:Conditions</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&gt; </SPAN><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">
<P style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial">Once de-serialized at the client, the ‘validTo’ and ‘validFrom’ properties of the returned SecurityToken at the client should reflect the same values. However in my case, things were a bit different:<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt"></SPAN><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">SecurityToken.</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">ValidFrom<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: Wingdings; FONT-SIZE: 8pt; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-char-type: symbol; mso-symbol-font-family: Wingdings"><SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings">à</SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'"> <SPAN style="COLOR: #2b91af">DateTime</SPAN>.UtcNow</SPAN><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: #2b91af; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="mso-tab-count: 1"></SPAN>SecurityToken.</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">ValidTo<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: Wingdings; FONT-SIZE: 8pt; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'; mso-ascii-font-family: 'Courier New'; mso-hansi-font-family: 'Courier New'; mso-char-type: symbol; mso-symbol-font-family: Wingdings"><SPAN style="mso-char-type: symbol; mso-symbol-font-family: Wingdings">à</SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 8pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'"> <SPAN style="COLOR: #2b91af">DateTime</SPAN>.MaxValue </SPAN><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt; mso-fareast-font-family: 'Times New Roman'"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p><FONT size=3 face=Calibri>&nbsp;</FONT></o:p></P><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin">
<P style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial">This was really disconcerting. Where the heck were these values coming from ? A max value for ValidTo meant that the issued token would never be renewed !!! Had to dig into the reflected source code and figure out the root cause of the issue. Take a look at the method responsible for de-serializing a RSTR at the client. Just showing the lines of interest from System.ServiceModel.Security.WSTrust+Driver.CreateRequestSecurityTokenResponse:<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt"></SPAN><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><o:p>&nbsp;</o:p></SPAN></P><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><o:p>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; COLOR: #2b91af; FONT-SIZE: 9.5pt">DateTime</SPAN><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"> utcNow = <SPAN style="COLOR: #2b91af">DateTime</SPAN>.UtcNow;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; COLOR: #2b91af; FONT-SIZE: 9.5pt">DateTime</SPAN><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"> maxUtcDateTime = <SPAN style="COLOR: #2b91af">DateTime</SPAN>.MaxValue;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">if</SPAN><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"> ((element2.LocalName == <SPAN style="COLOR: blue">this</SPAN>.DriverDictionary.<SPAN style="BACKGROUND: lime; mso-highlight: lime">Lifetime</SPAN>.Value) &amp;&amp; (element2.NamespaceURI == <SPAN style="COLOR: blue">this</SPAN>.DriverDictionary.Namespace.Value))<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt">{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; COLOR: #2b91af; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>XmlElement</SPAN><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"> element4 = XmlHelper.GetChildElement(element2, <SPAN style="COLOR: #a31515">"<SPAN style="BACKGROUND: lime; mso-highlight: lime">Created</SPAN>"</SPAN>, <SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="COLOR: #a31515">"https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>if</SPAN><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"> (element4 != <SPAN style="COLOR: blue">null</SPAN>)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;</SPAN>utcNow = <SPAN style="COLOR: #2b91af">DateTime</SPAN>.ParseExact(XmlHelper.ReadTextElementAsTrimmedString(element4),WSUtilitySpecificationVersion.AcceptedDateTimeFormats, DateTimeFormatInfo.InvariantInfo,DateTimeStyles.None).ToUniversalTime();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: #2b91af">XmlElement</SPAN> element5 = XmlHelper.GetChildElement(element2, <SPAN style="COLOR: #a31515">"<SPAN style="BACKGROUND: lime; mso-highlight: lime">Expires</SPAN>"</SPAN>, <SPAN style="COLOR: #a31515">"https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (element5 != <SPAN style="COLOR: blue">null</SPAN>)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;</SPAN>maxUtcDateTime = <SPAN style="COLOR: #2b91af">DateTime</SPAN>.ParseExact(XmlHelper.ReadTextElementAsTrimmedString(element5),WSUtilitySpecificationVersion.AcceptedDateTimeFormats,DateTimeFormatInfo.InvariantInfo,DateTimeStyles.None).ToUniversalTime();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt">}</SPAN><o:p></o:p></P></o:p></SPAN><SPAN style="FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"><FONT face=Calibri>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'">Note the highlighted elements above. WCF looks for these elements inside an incoming RSTR to set the lifetime of a security token, NOT inside SAML token. If not present, these individual values, ValidTo and ValidFrom, are set to their corresponding values as highlighted earlier. While the solution to this issue is very simple, I will come to that a bit later. First, we need to understand the significance of such an implementation. A saml:Condition defines <I style="mso-bidi-font-style: normal">the lifetime of a SAML token</I>. A lifetime element defines <I style="mso-bidi-font-style: normal">the lifetime of a RSTR received by the client</I>. This makes perfect sense since an issued token can be something other than a SAML token as well. Taking that into light, a token lifetime at the client and hence any subsequent renewal decision should not be tightly coupled with a SAML token lifetime. <o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt"></FONT></SPAN><SPAN style="FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"><o:p><FONT face=Calibri>&nbsp;</FONT></o:p></SPAN></P><SPAN style="FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'"><FONT face=Calibri>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'">Coming back to the solution, just ensure that you define a lifetime element when generating a RSTR inside your custom STS. A lifetime element inside a RSTR looks as follows:<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal></FONT></SPAN><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt; mso-fareast-font-family: 'Times New Roman'">&nbsp;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">Lifetime</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">Created </SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: red; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">xmlns</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">="</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: red; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">"&gt;</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">2009-09-22T19:03:44.4697845Z</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">Created</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">Expires </SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: red; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">xmlns</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">="</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: red; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">https://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">"&gt;</SPAN><B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">2009-09-22T19:03:54.4697845Z</SPAN></B><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">Expires</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: #990000; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">Lifetime</SPAN><SPAN style="FONT-FAMILY: 'Verdana','sans-serif'; COLOR: blue; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Times New Roman','serif'; FONT-SIZE: 12pt; mso-fareast-font-family: 'Times New Roman'"><o:p>&nbsp;</o:p></SPAN></P><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><FONT face=Calibri>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'">A token with the above lifetime element will be valid for 10 minutes before a renewal request is made by the client to STS. <o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal></FONT></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><o:p><FONT face=Calibri>&nbsp;</FONT></o:p></SPAN></P><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><FONT face=Calibri>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'">Now let’s make things a bit more interesting by considering these 2 elements in union. Consider a generated security token with the following values set:<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal></FONT></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><o:p><FONT face=Calibri>&nbsp;</FONT></o:p></SPAN></P>
<P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; COLOR: #c00000; FONT-SIZE: 10pt"><FONT face=Calibri>saml:Conditions <B style="mso-bidi-font-weight: normal">NotBefore</B> : </FONT></SPAN><B><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">2009-09-22T19:03:44.4697845Z</SPAN></B><SPAN style="LINE-HEIGHT: 115%; COLOR: #c00000; FONT-SIZE: 10pt"><o:p></o:p></SPAN></P>
<P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; COLOR: #c00000; FONT-SIZE: 10pt"><FONT face=Calibri>saml:Conditions <B style="mso-bidi-font-weight: normal">NotOnOrAfter</B> : </FONT></SPAN><B><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">2009-09-22T19:03:49.4697845Z</SPAN></B><SPAN style="LINE-HEIGHT: 115%; COLOR: #c00000; FONT-SIZE: 10pt"><o:p></o:p></SPAN></P>
<P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; COLOR: #c00000; FONT-SIZE: 10pt"><FONT face=Calibri>Lifetime <B style="mso-bidi-font-weight: normal">Created</B> : </FONT></SPAN><B><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">2009-09-22T19:03:44.4697845Z</SPAN></B><SPAN style="LINE-HEIGHT: 115%; COLOR: #c00000; FONT-SIZE: 10pt"><o:p></o:p></SPAN></P>
<P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; COLOR: #c00000; FONT-SIZE: 10pt"><FONT face=Calibri>Lifetime <B style="mso-bidi-font-weight: normal">Expires</B> : </FONT></SPAN><B><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Verdana','sans-serif'; FONT-SIZE: 8pt; mso-bidi-font-family: Verdana">2009-09-22T19:03:54.4697845Z<o:p></o:p></SPAN></B></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><o:p><FONT face=Calibri>&nbsp;</FONT></o:p></SPAN></P><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><FONT face=Calibri>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'">This means that while the lifetime of a SAML token is set to 5 minutes, that of the RSTR is set to 10 minutes. So the client will not renew the token till the 11<SUP>th</SUP> minute, while the SAML token will be invalidated by the service starting from the 6<SUP>th</SUP> minute. Make sure the lifetime of the issued security token by STS &lt;= lifetime of SAML token to prevent such a scenario.<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal></FONT></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><o:p><FONT face=Calibri>&nbsp;</FONT></o:p></SPAN></P><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><FONT face=Calibri>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-fareast-font-family: 'Times New Roman'">There is one very important parameter which I have not spoken of in this article: binding. In this explained scenario, secure sessions were disabled. Things change when we enable that either through binding or use one which implicitly sets up a secure session (netTcpBinding). I will talk about that in my following post. Till then enjoy playing around with issued tokens.</SPAN></P></FONT></SPAN>]]></content:encoded>
    </item>
    <item>
      <title>Mind the case and space when configuring your protocol bindings inside IIS 7.0 to enable net.tcp</title>
      <link>https://docs.microsoft.com/archive/blogs/dhrubach/mind-the-case-and-space-when-configuring-your-protocol-bindings-inside-iis-7-0-to-enable-net-tcp</link>
      <pubDate>Sat, 12 Dec 2009 07:44:00 GMT</pubDate>
      <dc:creator><![CDATA[dhruba]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhrubach/2009/12/12/mind-the-case-and-space-when-configuring-your-protocol-bindings-inside-iis-7-0-to-enable-net-tcp/</guid>
      <description><![CDATA[We all are aware that WCF provides a new TCP-based network protocol (net.tcp://) for high...]]></description>
      <content:encoded><![CDATA[<P><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">We all are aware that WCF provides a new TCP-based network protocol (net.tcp://) for high performance communication. People who are familiar with this particular protocol will know that for a IIS 7.0 hosted WCF service to utilize this protocol, we need to enable appropriate protocol (namely net.tcp) at the web site and virtual directory level for things to work. Highlighted below is the section where the configurations goes in : </SPAN>
<P mce_keep="true">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/dhrubach/WindowsLiveWriter/Mindthecaseandspacewhenconfiguringyo.tcp_D880/image_4.png" original-url="https://blogs.msdn.com/blogfiles/dhrubach/WindowsLiveWriter/Mindthecaseandspacewhenconfiguringyo.tcp_D880/image_4.png" mce_href="https://blogs.msdn.com/blogfiles/dhrubach/WindowsLiveWriter/Mindthecaseandspacewhenconfiguringyo.tcp_D880/image_4.png"><IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/dhrubach/WindowsLiveWriter/Mindthecaseandspacewhenconfiguringyo.tcp_D880/image_thumb_1.png" original-url="https://blogs.msdn.com/blogfiles/dhrubach/WindowsLiveWriter/Mindthecaseandspacewhenconfiguringyo.tcp_D880/image_thumb_1.png" width=244 height=119 mce_src="https://blogs.msdn.com/blogfiles/dhrubach/WindowsLiveWriter/Mindthecaseandspacewhenconfiguringyo.tcp_D880/image_thumb_1.png"></A> </P>
<P><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">Coming back to the issue. I was working on a basic WCF client – service scenario where I had a service hosted on IIS 7.0 over net.tcp protocol. Service binding was as follows </SPAN>
<P mce_keep="true"><SPAN style="FONT-FAMILY: consolas; COLOR: blue; FONT-SIZE: 9.5pt"></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">&lt;</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">netTcpBinding</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">&gt;</SPAN><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">binding</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"> </SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: red; FONT-SIZE: 9.5pt">name</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">=</SPAN><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><FONT color=#000000>"</FONT><SPAN style="COLOR: blue">TransportWithWindows</SPAN><FONT color=#000000>"</FONT><SPAN style="COLOR: blue">&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">security</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"> </SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: red; FONT-SIZE: 9.5pt">mode</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">=</SPAN><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><FONT color=#000000>"</FONT><SPAN style="COLOR: blue">Message</SPAN><FONT color=#000000>"</FONT><SPAN style="COLOR: blue">&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">message</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"> </SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: red; FONT-SIZE: 9.5pt">clientCredentialType</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"> =</SPAN><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><FONT color=#000000>"</FONT><SPAN style="COLOR: blue">Windows</SPAN><FONT color=#000000>"</FONT><SPAN style="COLOR: blue">/&gt;</SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">security</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">&gt;</SPAN><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">binding</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">&gt;</SPAN><SPAN style="FONT-FAMILY: Consolas; FONT-SIZE: 9.5pt"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: #a31515; FONT-SIZE: 9.5pt">netTcpBinding</SPAN><SPAN style="FONT-FAMILY: Consolas; COLOR: blue; FONT-SIZE: 9.5pt">&gt;</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin"><o:p></o:p></SPAN></P>
<P mce_keep="true"></SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">With this simple setting in place, the client was failing with the following exception: </SPAN></P><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">
<P style="MARGIN: 0in 0in 0pt"><I><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; COLOR: #1f497d; FONT-SIZE: 9pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text2">at System.ServiceModel.Channels.ConnectionUpgradeHelper.DecodeFramingFault(ClientFramingDecoder decoder, IConnection connection, Uri via, String contentType, TimeoutHelper&amp; timeoutHelper)</SPAN></I><I style="mso-bidi-font-style: normal"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; COLOR: #1f497d; FONT-SIZE: 9pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text2"><o:p></o:p></SPAN></I></P>
<P style="MARGIN: 0in 0in 0pt"><I><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; COLOR: #1f497d; FONT-SIZE: 9pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text2">at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper&amp; timeoutHelper)</SPAN></I><I style="mso-bidi-font-style: normal"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; COLOR: #1f497d; FONT-SIZE: 9pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text2"> <o:p></o:p></SPAN></I></P>
<P style="MARGIN: 0in 0in 0pt"><I><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; COLOR: #1f497d; FONT-SIZE: 9pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text2">at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper&amp; timeoutHelper)</SPAN></I><I style="mso-bidi-font-style: normal"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; COLOR: #1f497d; FONT-SIZE: 9pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-themecolor: text2"> <SPAN style="mso-bidi-font-style: italic">at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout) at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)</SPAN> <SPAN style="mso-bidi-font-style: italic">at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)</SPAN> <SPAN style="mso-bidi-font-style: italic">at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)</SPAN> <SPAN style="mso-bidi-font-style: italic">at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)</SPAN> <o:p></o:p></SPAN></I></P>
<P mce_keep="true"></SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">That connectivity is the issue out here is evident from the above stack trace. However I had my bindings configured at IIS, Net.Tcp Port Sharing Service was running on my machine, ‘WCF Non-HTTP Activation’ was installed. Where do we look in this case ? Back to the same bindings as highlighted in the image above : </SPAN></P>
<P mce_keep="true">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A href="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/dhrubach/WindowsLiveWriter/Mindthecaseandspacewhenconfiguringyo.tcp_D880/image_6.png" original-url="https://blogs.msdn.com/blogfiles/dhrubach/WindowsLiveWriter/Mindthecaseandspacewhenconfiguringyo.tcp_D880/image_6.png" mce_href="https://blogs.msdn.com/blogfiles/dhrubach/WindowsLiveWriter/Mindthecaseandspacewhenconfiguringyo.tcp_D880/image_6.png"><IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/dhrubach/WindowsLiveWriter/Mindthecaseandspacewhenconfiguringyo.tcp_D880/image_thumb_2.png" original-url="https://blogs.msdn.com/blogfiles/dhrubach/WindowsLiveWriter/Mindthecaseandspacewhenconfiguringyo.tcp_D880/image_thumb_2.png" width=244 height=137 mce_src="https://blogs.msdn.com/blogfiles/dhrubach/WindowsLiveWriter/Mindthecaseandspacewhenconfiguringyo.tcp_D880/image_thumb_2.png"></A> </P>
<P><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">While including the binding information, I had made the mistake of entering it in UPPER CASE instead of lower case (net.tcp). Quite an innocuous error but took quite a while to figure out. </SPAN>
<P mce_keep="true"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">One other point to keep in their mind while configuring a protocol binding. DO NOT LEAVE ANY SPACE in between individual bindings. </SPAN></P>
<P mce_keep="true"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">.NET does not like the following : http, net.tcp. (NOTE A SPACE IN BETWEEN ‘,’ AND ‘n’) </SPAN></P>
<P mce_keep="true"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">Client will once again fail with a EndpointNotFoundException, while service activation will fail with the following exception : </SPAN></P>
<P mce_keep="true"><EM><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; COLOR: #004080; FONT-SIZE: 10pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">InvalidOperationException: Could not find a base address that matches scheme net.tcp for the endpoint with binding NetTcpBinding. Registered base address schemes are [http,https].]</SPAN></EM><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"> </SPAN></P>
<P mce_keep="true"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">Correct : http,net.tcp </SPAN></P>
<P mce_keep="true"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin">Good news is that this little nuance has been resolved with .NET 4.0. Hope these will save some precious time which can be spent elsewhere. </SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: calibri; mso-bidi-theme-font: minor-latin"></SPAN></P>]]></content:encoded>
    </item>
    <item>
      <title>Generate proxy code for a web service dynamically</title>
      <link>https://docs.microsoft.com/archive/blogs/dhrubach/generate-proxy-code-for-a-web-service-dynamically</link>
      <pubDate>Sun, 19 Oct 2008 18:12:00 GMT</pubDate>
      <dc:creator><![CDATA[dhruba]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhrubach/2008/10/19/generate-proxy-code-for-a-web-service-dynamically/</guid>
      <description><![CDATA[The first step to consuming a web service is to generate a proxy class from its wsdl. One will...]]></description>
      <content:encoded><![CDATA[<SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt">
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'">The first step to consuming a web service is to generate a proxy class from its wsdl. One will agree that with visual studio and a magic tool called wsdl.exe, generating the proxy class is the easiest of things. What if we do away with this concept of a proxy file from a client application? Generate one dynamically using the provided URL of the web service, consume the required web methods and forget about the web service. Took me some time to put the pieces together and come up with a solution.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'">“<I>System.Web.Services.Description</I>” namespace has a couple of classes which allows you to implement this quite easily. Two most important of those: <I>ServiceDecription </I>class and <I>ServiceDescriptionImporter </I>class. Use these in conjunction with System.CodeDom and you will get what you want. I wont go into the details of the functionalities exposed by each of these classes (msdn does a very good job of that).&nbsp;The path which I followed to implement the solution is as follows:<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 1.25in; mso-add-space: auto" class=MsoNormalCxSpMiddle><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-fareast-font-family: Arial">1.</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 7pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: Arial">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'">Generate proxy code from the downloaded wsdl file using ServiceDescriptionImporter and System.CodeDom<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 1.25in; mso-add-space: auto" class=MsoNormalCxSpMiddle><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-fareast-font-family: Arial">2.</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 7pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: Arial">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'">Generate a dynamic assembly which contains the compiled proxy code.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 1.25in; mso-add-space: auto" class=MsoNormalCxSpMiddle><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-fareast-font-family: Arial">3.</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 7pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: Arial">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'">Reflect through the assembly to find out the web methods.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: -0.25in; MARGIN: 0in 0in 0pt 1.25in; mso-add-space: auto" class=MsoNormalCxSpMiddle><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-fareast-font-family: Arial">4.</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 7pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: Arial">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-fareast-font-family: 'Times New Roman'">For each web method, find out its input parameter and return type.<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">You can easily develop a UI application to display the required information (regarding web methods and parameters) to the end user and let him choose which web method to invoke. I won’t cover that part in this post. First let’s have a look into the code to generate a dynamic assembly. I have commented every important operation within the code and won't explain it again. Please let me know if I have missed out <SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">on something and i will provide an explanation for that as well.</SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"></SPAN></SPAN></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">public</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">string</SPAN>[] GenerateProxyAssembly()<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes">//create a WebRequest object and fetch the WSDL file for the web service<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: teal; FONT-SIZE: 10pt; mso-no-proof: yes">HttpWebRequest</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> request = (<SPAN style="COLOR: teal">HttpWebRequest</SPAN>)<SPAN style="COLOR: teal">HttpWebRequest</SPAN>.Create(<SPAN style="COLOR: blue">this</SPAN>.uri);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN>request.Credentials = <SPAN style="COLOR: teal">CredentialCache</SPAN>.DefaultCredentials;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp; </SPAN><SPAN style="COLOR: teal">HttpWebResponse</SPAN> response = (<SPAN style="COLOR: teal">HttpWebResponse</SPAN>)request.GetResponse();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">System.IO.<SPAN style="COLOR: teal">Stream</SPAN> stream = response.GetResponseStream();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes">//read the downloaded WSDL file <o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: teal; FONT-SIZE: 10pt; mso-no-proof: yes">ServiceDescription</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> desc = <SPAN style="COLOR: teal">ServiceDescription</SPAN>.Read(stream);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//find out the number of operations exposed by the web service<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//store the name of the operations inside the string array<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//iterating only through the first binding exposed as <o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//the rest of the bindings will have the same number<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">int</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> i = 0;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: teal">Binding</SPAN> binding = desc.Bindings[0];<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: teal; FONT-SIZE: 10pt; mso-no-proof: yes">OperationBindingCollection</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> opColl = binding.Operations;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">foreach</SPAN> (<SPAN style="COLOR: teal">OperationBinding</SPAN> operation <SPAN style="COLOR: blue">in</SPAN> opColl)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>listOfOperations[i++] = operation.Name; <o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes">//initializing a ServiceDescriptionImporter object<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: teal; FONT-SIZE: 10pt; mso-no-proof: yes">ServiceDescriptionImporter</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> importer = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: teal">ServiceDescriptionImporter</SPAN>();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes">//set the protocol to SOAP 1.1<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">importer.ProtocolName = <SPAN style="COLOR: maroon">"Soap12"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//setting the Style to Client in order to generate client proxy code<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>importer.Style = <SPAN style="COLOR: teal">ServiceDescriptionImportStyle</SPAN>.Client;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//adding the ServiceDescription to the Importer object<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>importer.AddServiceDescription(desc, <SPAN style="COLOR: blue">null</SPAN>, <SPAN style="COLOR: blue">null</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 35.25pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">importer.CodeGenerationOptions = <SPAN style="COLOR: teal">CodeGenerationOptions</SPAN>.GenerateNewAsync;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 35.25pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes">//Initialize the CODE DOM tree in which we will import the ServiceDescriptionImporter<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: teal">CodeNamespace</SPAN> nm = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: teal">CodeNamespace</SPAN>();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: teal">CodeCompileUnit</SPAN> unit = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: teal">CodeCompileUnit</SPAN>();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>unit.Namespaces.Add(nm);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//generating the client proxy code<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: teal">ServiceDescriptionImportWarnings</SPAN> warnings = importer.Import(nm, unit);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (warnings == 0)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//set the CodeDOMProvider to C# to generate the code in C#<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>System.IO.<SPAN style="COLOR: teal">StringWriter</SPAN> sw = <SPAN style="COLOR: blue">new</SPAN> System.IO.<SPAN style="COLOR: teal">StringWriter</SPAN>();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: teal">CodeDomProvider</SPAN> provider = <SPAN style="COLOR: teal">CodeDomProvider</SPAN>.CreateProvider(<SPAN style="COLOR: maroon">"C#"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">provider.GenerateCodeFromCompileUnit(unit, sw, <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: teal">CodeGeneratorOptions</SPAN>());<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//creating TempFileCollection</SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="COLOR: green"><o:p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <SPAN style="COLOR: green">//the path of the temp folder is hardcoded</SPAN></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: teal; FONT-SIZE: 10pt; mso-no-proof: yes">TempFileCollection</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> coll = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: teal">TempFileCollection</SPAN>(<SPAN style="COLOR: maroon">@"C:\wmpub\tempFiles"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>coll.KeepFiles = <SPAN style="COLOR: blue">false</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//setting the CompilerParameters for the temporary assembly<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">string</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">[] refAssembly = { <SPAN style="COLOR: maroon">"System.dll"</SPAN>, <SPAN style="COLOR: maroon">"System.Data.dll"</SPAN>, <SPAN style="COLOR: maroon">"System.Web.Services.dll"</SPAN>, <SPAN style="COLOR: maroon">"System.Xml.dll"</SPAN> };<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: teal">CompilerParameters</SPAN> param = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: teal">CompilerParameters</SPAN>(refAssembly);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>param.GenerateInMemory = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>param.TreatWarningsAsErrors = <SPAN style="COLOR: blue">false</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>param.OutputAssembly = <SPAN style="COLOR: maroon">"WebServiceReflector.dll"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>param.TempFiles = coll;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//compile the generated code into an assembly<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 1in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes">//CompilerResults results = provider.CompileAssemblyFromDom(param, unitArr);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 71.25pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: teal; FONT-SIZE: 10pt; mso-no-proof: yes">CompilerResults</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> results = provider.CompileAssemblyFromSource(param, sw.ToString());<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.assem = results.CompiledAssembly;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes">//return the list of operations exposed by the web service<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> listOfOperations;<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}<o:p></o:p></SPAN></P><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt; mso-no-proof: yes">
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">This method returns the list of operations exposed by the web service. I have used </SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; COLOR: teal; FONT-SIZE: 10pt; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">ServiceDescription</SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'"> </SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">to achieve that as I was not able to reflect only the web method names from the generated assmebly. With the operation names available, all that remains is to find out the input and return parameters for each method. </SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"></SPAN></SPAN>&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">public</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: teal">ParameterInfo</SPAN>[] ReturnInputParameters(<SPAN style="COLOR: blue">string</SPAN> methodName)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes">//create an instance of the web service type<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes">//////////////to do/////////////////////////<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes">//get the name of the web service dynamically from the wsdl<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: teal; FONT-SIZE: 10pt; mso-no-proof: yes">Object</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> o = <SPAN style="COLOR: blue">this</SPAN>.assem.CreateInstance(<SPAN style="COLOR: maroon">"Service"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: teal">Type</SPAN> service = o.GetType();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: teal">ParameterInfo</SPAN>[] paramArr = <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes">//get the list of all public methods available in the generated //assembly<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: teal">MethodInfo</SPAN>[] infoArr = service.GetMethods();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">foreach</SPAN> (<SPAN style="COLOR: teal">MethodInfo</SPAN> info <SPAN style="COLOR: blue">in</SPAN> infoArr)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: green">//get the input parameter information for the <o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>//required web method<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1"></SPAN><SPAN style="COLOR: blue">if</SPAN> (methodName.Equals(info.Name))<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>paramArr = info.GetParameters();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> paramArr;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">}<o:p></o:p></SPAN></P></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt; mso-no-proof: yes">
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'"></SPAN>&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">This method returns the input parameters in ParameterInfo[] list. To get the output parameter, just replace the call to GetParamters() on MethodInfo class with ReturnParameter property and put that inside a new method. Put these 3 methods inside a dll and add a reference to it from any client application. That's all. Just provide the URL and consume the web service, any web service. You don't have to go through the procedure of creating a proxy file every time you want to consume a new web service. </SPAN></SPAN></P></o:p></SPAN></SPAN>]]></content:encoded>
    </item>
    <item>
      <title>De-serialize whitespace characters using IXmlSerializable</title>
      <link>https://docs.microsoft.com/archive/blogs/dhrubach/de-serialize-whitespace-characters-using-ixmlserializable</link>
      <pubDate>Fri, 22 Aug 2008 17:42:00 GMT</pubDate>
      <dc:creator><![CDATA[dhruba]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhrubach/2008/08/22/de-serialize-whitespace-characters-using-ixmlserializable/</guid>
      <description><![CDATA[Sometimes back I faced an issue where the customer was trying to de-serialize whitespace characters....]]></description>
      <content:encoded><![CDATA[<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">Sometimes back I faced an issue where the customer was trying to de-serialize whitespace characters. Pretty innocuous from the look of it – why will someone try to de-serialize and preserve white space characters? Naïve – there is a reason for everything. Nonetheless it took me quite a while to figure out the resolution. </SPAN></SPAN></P><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'">Let’s take the following type definition as an example:</SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN>&nbsp;</P></SPAN></SPAN>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">public</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> <SPAN style="COLOR: blue">class</SPAN> <SPAN style="COLOR: teal">FooClass</SPAN> <SPAN style="COLOR: teal"><o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">string</SPAN> _someName;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">private</SPAN> <SPAN style="COLOR: blue">string</SPAN> _someValue;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> FooClass()<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>{ }<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>[System.Xml.Serialization.<SPAN style="COLOR: teal">XmlText</SPAN>()]<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">string</SPAN> SomeName<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">get<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">this</SPAN>._someName;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">set<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>._someName = <SPAN style="COLOR: blue">value</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">string</SPAN> SomeValue<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">get<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">this</SPAN>._someValue;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">set<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>._someValue = <SPAN style="COLOR: blue">value</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN>}</SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt">
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt">Let’s say we are trying to de-serialize the following input xml file:</SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt"><o:p></o:p></SPAN>&nbsp;</P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal></SPAN><SPAN style="FONT-SIZE: 10pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&lt;?</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 10pt; mso-no-proof: yes">xml</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">version</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">"<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;<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 10pt; mso-no-proof: yes">FooClass</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"> </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">xmlns:xsi</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">="https://www.w3.org/2001/XMLSchema-instance" </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: red; FONT-SIZE: 10pt; mso-no-proof: yes">xmlns:xsd</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">=</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">"<SPAN style="COLOR: blue">https://www.w3.org/2001/XMLSchema</SPAN>"<SPAN style="COLOR: blue">&gt;<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 10pt; mso-no-proof: yes">SomeName</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;<SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;/</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 10pt; mso-no-proof: yes">SomeName</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>&lt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 10pt; mso-no-proof: yes">SomeValue</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes">some value<SPAN style="COLOR: blue">&lt;/</SPAN><SPAN style="COLOR: maroon">SomeValue</SPAN><SPAN style="COLOR: blue">&gt;<o:p></o:p></SPAN></SPAN></P>
<P style="TEXT-INDENT: 0.5in; MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&lt;/</SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 10pt; mso-no-proof: yes">FooClass</SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">&gt;</SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">If you try to de-serialize this using <SPAN style="COLOR: teal">XmlSerializer</SPAN>.Deserialize() method, the resultant type will content the following values :</SPAN></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"></SPAN></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><SPAN style="mso-tab-count: 1"><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>this.<SPAN style="COLOR: #00b050">SomeName</SPAN> = “”<SPAN style="mso-spacerun: yes">&nbsp; </SPAN></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: green; FONT-SIZE: 10pt; mso-no-proof: yes">//the whitespace characters are eliminated<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>this.<SPAN style="COLOR: #00b050">SomeValue</SPAN> = “some value”<o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal></SPAN><SPAN style="mso-tab-count: 1"></SPAN></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"></SPAN>&nbsp;</P><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt">
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'">Even using XmlTextReader with WhitespaceHandling property set to </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; COLOR: teal; FONT-SIZE: 10pt; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">WhiteSpaceHandling</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">.All </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">will not help in this case. </SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'">The magic is to implement IXmlSerializable while defining the type:</SPAN><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 12pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><o:p></o:p></SPAN>&nbsp;</P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-SIZE: 10pt"><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN></SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">#region</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> IXmlSerializable Members<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes">public</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"> System.Xml.Schema.<SPAN style="COLOR: teal">XmlSchema</SPAN> GetSchema()<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: blue">null</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">void</SPAN> ReadXml(<SPAN style="COLOR: teal">XmlReader</SPAN> reader)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">string</SPAN> xmlContent = reader.ReadOuterXml();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: teal">XmlDocument</SPAN> doc = <SPAN style="COLOR: blue">new</SPAN> <SPAN style="COLOR: teal">XmlDocument</SPAN>();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>doc.PreserveWhitespace = <SPAN style="COLOR: blue">true</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>doc.LoadXml(xmlContent);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="mso-spacerun: yes">&nbsp;</SPAN><SPAN style="COLOR: teal">XmlNodeList</SPAN> list = doc.DocumentElement.ChildNodes;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">foreach</SPAN> (<SPAN style="COLOR: teal">XmlNode</SPAN> node <SPAN style="COLOR: blue">in</SPAN> list)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">if</SPAN> (node.Name.Equals(<SPAN style="COLOR: maroon">"SomeName"</SPAN>))<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.SomeName = node.InnerXml;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">else</SPAN> <SPAN style="COLOR: blue">if</SPAN> (node.Name.Equals(<SPAN style="COLOR: maroon">"SomeValue"</SPAN>))<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">this</SPAN>.SomeValue = node.InnerXml;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">public</SPAN> <SPAN style="COLOR: blue">void</SPAN> WriteXml(<SPAN style="COLOR: teal">XmlWriter</SPAN> writer)<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>writer.WriteStartElement(<SPAN style="COLOR: maroon">"SomeName"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>writer.WriteString(<SPAN style="COLOR: blue">this</SPAN>.SomeName);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>writer.WriteEndElement();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>writer.WriteStartElement(<SPAN style="COLOR: maroon">"SomeValue"</SPAN>);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>writer.WriteString(<SPAN style="COLOR: blue">this</SPAN>.SomeValue);<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>writer.WriteEndElement();<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>}<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes"><o:p>&nbsp;</o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes"><SPAN style="mso-spacerun: yes">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN>#endregion</SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><o:p></o:p></SPAN></P>
<P style="MARGIN: 0in 0in 10pt" class=MsoNormal><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">One of the most important things that you should take care of is setting the “PreserveWhitespace” property of the XmlDocument object. Or else, the whitespaces will be eliminated while loading into XmlDocument.The rest of the implementation code is pretty straight forward. </SPAN><o:p></o:p></SPAN></P>]]></content:encoded>
    </item>
    <item>
      <title>The specified module could not be found. HRESULT : 0X800700E</title>
      <link>https://docs.microsoft.com/archive/blogs/dhrubach/the-specified-module-could-not-be-found-hresult-0x800700e</link>
      <pubDate>Wed, 09 Jul 2008 17:28:00 GMT</pubDate>
      <dc:creator><![CDATA[dhruba]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhrubach/2008/07/09/the-specified-module-could-not-be-found-hresult-0x800700e/</guid>
      <description><![CDATA[This error message, by the look of it, is very straight forward. It clearly states that the...]]></description>
      <content:encoded><![CDATA[<P><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-ansi-language: EN" lang=EN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-ansi-language: EN; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US; mso-bidi-language: AR-SA" lang=EN>This error message, by the look of it, is very straight forward. It clearly states that the application (irrespective of its type) failed due to a missing module. I had a similar feeling when I received this bright yellow message on my browser window the other day. Next obvious question: which module am I missing? Scan the whole error screen and you won’t find one. Let’s get down to business and find that out. </SPAN></SPAN></P>
<P><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-ansi-language: EN" lang=EN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-ansi-language: EN; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US; mso-bidi-language: AR-SA" lang=EN></SPAN></SPAN><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-ansi-language: EN" lang=EN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-ansi-language: EN; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US; mso-bidi-language: AR-SA" lang=EN>First a bit of background about the application as it holds the clue to the whole thing. I have a .NET 3.5 web application developed in C#. This referenced a managed C++ dll (ManagedWrapper.dll) which was a wrapper over an unmanaged C++ dll (UnmanagedTest.dll). The native dll had a single “Hello” method <SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-ansi-language: EN" lang=EN>which returned “Hello World” string.<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></SPAN></P></SPAN></SPAN><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-ansi-language: EN" lang=EN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-ansi-language: EN; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-fareast-language: EN-US; mso-bidi-language: AR-SA" lang=EN>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-ansi-language: EN" lang=EN>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">#include</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'"> <SPAN style="COLOR: maroon">"StdAfx.h"<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: blue; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">#include</SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'"> <SPAN style="COLOR: maroon">"TestObject.h"<o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; COLOR: maroon; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">TestObject::TestObject() {}<SPAN style="COLOR: maroon"><o:p></o:p></SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; std::string TestObject::Hello()<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt 0.5in; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">{<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt; mso-layout-grid-align: none" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'"><SPAN style="mso-spacerun: yes">&nbsp; </SPAN><SPAN style="mso-tab-count: 2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </SPAN><SPAN style="COLOR: blue">return</SPAN> <SPAN style="COLOR: maroon">"Hello World"</SPAN>;<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; TEXT-INDENT: 0.5in; MARGIN: 0in 0in 0pt 0.5in" class=MsoNormal><SPAN style="FONT-FAMILY: 'Courier New'; FONT-SIZE: 10pt; mso-no-proof: yes; mso-fareast-font-family: 'Times New Roman'">}<o:p></o:p></SPAN></P>
<P></SPAN></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-bidi-language: AR-SA">I included a reference of ManagedWrapper.dll inside my web application. Copied UnmanagedTest.dll inside the bin directory of the web application. My intention was to call the Hello() method present within the native dll from my web application. To test whether the setup will work or not before any development inside the web application, I published the web application on IIS 6.0 and browsed to the default.aspx page from IE7. It failed with the above mentioned error message. Managed Exception :</SPAN></SPAN></P>
<P><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt"><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-ansi-language: EN-US; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"></SPAN></SPAN><SPAN style="LINE-HEIGHT: 115%; COLOR: black; FONT-SIZE: 9.5pt"><SPAN style="LINE-HEIGHT: 115%; COLOR: black; FONT-SIZE: 9pt"><SPAN style="LINE-HEIGHT: 115%; COLOR: maroon; FONT-SIZE: 9pt">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <EM>System.IO.FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)<o:p></o:p></EM></SPAN></P></SPAN></SPAN><SPAN style="LINE-HEIGHT: 115%; COLOR: black; FONT-SIZE: 9.5pt"></SPAN><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt">
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'">Partial Stack Trace of the failing thread: </SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: 'Times New Roman'; mso-fareast-font-family: 'Times New Roman'"><o:p></o:p></SPAN>&nbsp;</P></SPAN><SPAN style="FONT-FAMILY: 'Lucida Console'; COLOR: black; FONT-SIZE: 9pt; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"><o:p><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-ansi-language: EN" lang=EN>
<DIV style="MARGIN: 0pt 75pt; WIDTH: 657pt; HEIGHT: 75pt; OVERFLOW: auto">
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: maroon; FONT-SIZE: 10pt; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><B>[FileNotFoundException: The specified module could not be found. (Exception from HRESULT: 0x8007007E)]</B><o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><SPAN style="COLOR: maroon"><B>System.Reflection.Assembly._nLoad</B></SPAN>(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark&amp; stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><SPAN style="COLOR: maroon"><B>System.Reflection.Assembly.nLoad</B></SPAN>(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark&amp; stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +54<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><SPAN style="COLOR: maroon"><B>System.Reflection.Assembly.InternalLoad</B></SPAN>(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean forIntrospection) +211<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><SPAN style="COLOR: maroon"><B>System.Reflection.Assembly.InternalLoad</B></SPAN>(String assemblyString, Evidence assemblySecurity, StackCrawlMark&amp; stackMark, Boolean forIntrospection) +141<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><SPAN style="COLOR: maroon"><B>System.Reflection.Assembly.Load</B></SPAN>(String assemblyString) +25<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Calibri','sans-serif'; COLOR: black; FONT-SIZE: 9pt; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'; mso-ascii-theme-font: minor-latin; mso-hansi-theme-font: minor-latin"><SPAN style="COLOR: maroon"><B>System.Web.Configuration.CompilationSection.LoadAssemblyHelper</B></SPAN>(String assemblyName, Boolean starDirective) +32<o:p></o:p></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Lucida Console'; COLOR: black; FONT-SIZE: 9pt; mso-bidi-font-family: 'Courier New'; mso-fareast-font-family: 'Times New Roman'"><o:p>&nbsp;</o:p></SPAN></P></DIV></SPAN>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-ansi-language: EN" lang=EN></SPAN>&nbsp;</P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-ansi-language: EN" lang=EN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-ansi-language: EN; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-bidi-language: AR-SA" lang=EN>First I enabled fusion logging for ASP.NET and reproduced the issue. The logs were not able to point me to the failing module. Next I collected process monitor trace and root cause was in front of me:</SPAN></SPAN></P>
<P style="LINE-HEIGHT: normal; MARGIN: 0in 0in 0pt; tab-stops: 45.8pt 91.6pt 137.4pt 183.2pt 229.0pt 274.8pt 320.6pt 366.4pt 412.2pt 458.0pt 503.8pt 549.6pt 595.4pt 641.2pt 687.0pt 732.8pt" class=MsoNormal><SPAN style="FONT-FAMILY: 'Arial','sans-serif'; FONT-SIZE: 10pt; mso-ansi-language: EN" lang=EN><SPAN style="LINE-HEIGHT: 115%; FONT-FAMILY: 'Eras Medium ITC','sans-serif'; COLOR: black; FONT-SIZE: 10pt; mso-bidi-font-family: Arial; mso-ansi-language: EN; mso-fareast-font-family: 'Times New Roman'; mso-fareast-language: EN-US; mso-bidi-language: AR-SA" lang=EN></SPAN></SPAN><SPAN style="COLOR: black; FONT-SIZE: 10pt; mso-fareast-font-family: 'Times New Roman'"><FONT face=Arial></FONT></SPAN>&nbsp;</P>
<DIV style="MARGIN: 0pt 75pt; WIDTH: 649.925pt; HEIGHT: 100pt; OVERFLOW: auto"><SPAN style="COLOR: black; FONT-SIZE: 9pt; mso-fareast-font-family: 'Times New Roman'"><FONT face=Callibri>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal>w3wp.exe<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>2012<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>QueryOpen<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: maroon">C:\WINNT\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\managedwrappersite\5bbb713b\7beac3fa\assembly\dl3\bfbeeb54\95e2dc78_66d5c801\UnmanagedTest.dll</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>NAME NOT FOUND</P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p>&nbsp;</o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal>w3wp.exe<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>2012<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>QueryOpen<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: maroon">C:\WINNT\system32\UnmanagedTest.dll</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>NAME NOT FOUND</P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p>&nbsp;</o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal>w3wp.exe<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>2012<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>QueryOpen<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: maroon">C:\WINNT\system\UnmanagedTest.dll</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</SPAN>NAME NOT FOUND</P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p>&nbsp;</o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal>w3wp.exe<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>2012<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>QueryOpen<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: maroon">C:\WINNT\UnmanagedTest.dll</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>NAME NOT FOUND</P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p>&nbsp;</o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal>w3wp.exe<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>2012<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>QueryOpen<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: maroon">C:\WINNT\system32\inetsrv\UnmanagedTest.dll</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>NAME NOT FOUND</P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p>&nbsp;</o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal>w3wp.exe<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>2012<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>QueryOpen<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: maroon">C:\WINNT\system32\UnmanagedTest.dll</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>NAME NOT FOUND</P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p>&nbsp;</o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal>w3wp.exe<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>2012<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>QueryOpen<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: maroon">C:\WINNT\UnmanagedTest.dll</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>NAME NOT FOUND</P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p>&nbsp;</o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal>w3wp.exe<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>2012<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>QueryOpen<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: maroon">C:\WINNT\system32\wbem\UnmanagedTest.dll</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>NAME NOT FOUND</P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p>&nbsp;</o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal>w3wp.exe<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>2012<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>QueryOpen<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: maroon">C:\Program Files\Windows Imaging\UnmanagedTest.dll</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>NAME NOT FOUND</P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p>&nbsp;</o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal>w3wp.exe<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>2012<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>QueryOpen<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: maroon">C:\Program Files\CA\SharedComponents\ScanEngine\UnmanagedTest.dll</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>NAME NOT FOUND</P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p>&nbsp;</o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal>w3wp.exe<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>2012<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>QueryOpen<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: maroon">C:\Program Files\CA\eTrust Antivirus\UnmanagedTest.dll</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>NAME NOT FOUND</P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p>&nbsp;</o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal>w3wp.exe<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>2012<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>QueryOpen<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: maroon">C:\Program Files\Microsoft Network Monitor 3\UnmanagedTest.dll</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>NAME NOT FOUND</P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal><o:p>&nbsp;</o:p></P>
<P style="MARGIN: 0in 0in 0pt" class=MsoNormal>w3wp.exe<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>2012<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>QueryOpen<SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN><SPAN style="COLOR: maroon">C:\Program Files\Microsoft SQL Server\90\Tools\Binn\UnmanagedTest.dll</SPAN><SPAN style="mso-tab-count: 1">&nbsp;&nbsp;&nbsp;</SPAN>NAME NOT FOUND</P></FONT></SPAN></DIV>
<P></o:p></SPAN></SPAN></SPAN></P><SPAN style="LINE-HEIGHT: 115%; FONT-SIZE: 10pt">
<P style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial">This shows that we are not failing to load ManagedWrapper.dll, but rather UnmanagedTest.dll. Have a close look into the&nbsp;probing paths of the dll :&nbsp;these paths are multiple values of the "PATH" environement variable on the server.&nbsp;Why does&nbsp;w3wp.exe look for a native dll in these paths instead of the application bin directory ? There is a reason for that as well. .NET&nbsp;Framework&nbsp;loads any dll present in the application bin folder as a managed dll.&nbsp;When we place an unmanged native&nbsp;dll in that place, it fails to load the dll and complains, just as it is doing in this scenario. </SPAN></P>
<P style="MARGIN: 0in 0in 0pt"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial"><o:p></o:p></SPAN>&nbsp;</P>
<P style="MARGIN: 0in 0in 0pt" mce_keep="true"><SPAN style="FONT-FAMILY: 'Eras Medium ITC','sans-serif'; FONT-SIZE: 10pt; mso-bidi-font-family: Arial">Resolution in this case will be to place the native dll in any of the probing paths specified in the above trace. We can also place the dll inside a custom folder and set its path to "PATH" environment variable at runtime. Next time you get this error message, make efficient use of the process monitor to catch the culprit.</SPAN></SPAN></P>]]></content:encoded>
    </item>
  </channel>
</rss>