<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/atom.xsl" media="screen"?><feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-US"><title type="html">NathanA&amp;#39;s Mostly Web Services Blog</title><subtitle type="html" /><id>http://blogs.msdn.com/b/nathana/atom.aspx</id><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/" /><link rel="self" type="application/atom+xml" href="http://blogs.msdn.com/b/nathana/atom.aspx" /><generator uri="http://telligent.com" version="5.6.583.17018">Telligent Community 5.6.583.17018 (Build: 5.6.583.17018)</generator><updated>2006-01-24T10:02:00Z</updated><entry><title>WCF Express Interop Binding on App Fabric TV</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2011/07/27/wcf-express-interop-binding-on-app-fabric-tv.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2011/07/27/wcf-express-interop-binding-on-app-fabric-tv.aspx</id><published>2011-07-27T16:34:00Z</published><updated>2011-07-27T16:34:00Z</updated><content type="html">&lt;p&gt;Here&amp;rsquo;s a new video I&amp;rsquo;m in from App Fabric TV doing a demo of the Express Interop Bindings.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;iframe style="width: 512px; height: 288px;" src="http://channel9.msdn.com/Shows/AppFabric-tv/AppFabrictv-WCF-Express-Interop-Bindings/player?w=512&amp;amp;h=288" frameborder="0" scrolling="no"&gt;&lt;/iframe&gt;&lt;/p&gt;
&lt;p&gt;The wizard and bindings are&amp;nbsp;available for download here:&amp;nbsp; &lt;a title="http://wcf.codeplex.com/releases/view/68276" href="http://wcf.codeplex.com/releases/view/68276"&gt;http://wcf.codeplex.com/releases/view/68276&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;And all those great interop resources are here:&amp;nbsp; &lt;a title="http://msdn.microsoft.com/en-us/netframework/webservicesinterop.aspx" href="http://msdn.microsoft.com/en-us/netframework/webservicesinterop.aspx"&gt;http://msdn.microsoft.com/en-us/netframework/webservicesinterop.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10190398" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Windows Azure AppFabric June CTP released</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2011/06/21/windows-azure-appfabric-june-ctp-released.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2011/06/21/windows-azure-appfabric-june-ctp-released.aspx</id><published>2011-06-21T19:56:19Z</published><updated>2011-06-21T19:56:19Z</updated><content type="html">&lt;p&gt;Hurry over to &lt;a href="http://portal.appfabriclabs.com/"&gt;http://portal.appfabriclabs.com/&lt;/a&gt; to sign up, space is limited.&lt;/p&gt;  &lt;p&gt;This release showcases the new container, management and tooling for creating reliable, scalable applications in Windows Azure.&amp;#160; A complete introduction to all of the features and links to more resources is on the &lt;a href="http://blogs.msdn.com/b/appfabric/archive/2011/06/20/introducing-windows-azure-appfabric-applications.aspx"&gt;AppFabric Team Blog&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10177557" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Exciting new bindings for WCF&lt;-&gt;Java Interop</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2011/06/21/exciting-new-bindings-for-wcf-lt-gt-java-interop.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2011/06/21/exciting-new-bindings-for-wcf-lt-gt-java-interop.aspx</id><published>2011-06-21T16:11:03Z</published><updated>2011-06-21T16:11:03Z</updated><content type="html">&lt;p&gt;When configuring web services you have a lot of choices.&amp;#160; You have security algorithms, token types, encodings, reliability and many other settings to worry about.&amp;#160; Now when your clients and services are written using different stacks the challenge becomes finding configurations that both share.&amp;#160; The good news is generally there are configurations that will work between many of the major web services stacks.&amp;#160; The bad news is it is often difficult to figure out what these configurations are and then it’s a challenge to configure both sides correctly.&lt;/p&gt;  &lt;p&gt;I’m a little bit late to this party, but last week we released a set of new bindings along with Visual Studio 2010 integration that makes finding matching configurations and applying that configuration to WCF as simple as navigating a wizard.&amp;#160; All this goodness, the &lt;a href="http://wcf.codeplex.com/wikipage?title=WCF%20Express%20Interop%20Bindings"&gt;WCF Express Interop Bindings&lt;/a&gt;, is available on codeplex right now.&amp;#160; These bindings along with our previously released &lt;a href="http://msdn.microsoft.com/en-us/webservicesinterop"&gt;white papers&lt;/a&gt; provide a road map to achieving interop over some the most difficult WS-* standards (security, secure conversation, reliable messaging, MTOM).&amp;#160; Here’s what others are saying:&lt;/p&gt;  &lt;p&gt;&lt;a title="http://wso2.com/blogs/thesource/2011/06/connecting-microsoft-services-to-wso2-just-got-a-whole-lot-easier/" href="http://wso2.com/blogs/thesource/2011/06/connecting-microsoft-services-to-wso2-just-got-a-whole-lot-easier/"&gt;http://wso2.com/blogs/thesource/2011/06/connecting-microsoft-services-to-wso2-just-got-a-whole-lot-easier/&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://webservices20.blogspot.com/2011/06/test-drive-shiny-new-wcf-interop.html" href="http://webservices20.blogspot.com/2011/06/test-drive-shiny-new-wcf-interop.html"&gt;http://webservices20.blogspot.com/2011/06/test-drive-shiny-new-wcf-interop.html&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://blogs.msdn.com/b/appfabric/archive/2011/06/13/announcing-wcf-express-interop-bindings.aspx" href="http://blogs.msdn.com/b/appfabric/archive/2011/06/13/announcing-wcf-express-interop-bindings.aspx"&gt;http://blogs.msdn.com/b/appfabric/archive/2011/06/13/announcing-wcf-express-interop-bindings.aspx&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&lt;a title="http://weblogs.asp.net/cibrax/archive/2011/06/13/interop-bindings-for-wcf-released-in-codeplex.aspx" href="http://weblogs.asp.net/cibrax/archive/2011/06/13/interop-bindings-for-wcf-released-in-codeplex.aspx"&gt;http://weblogs.asp.net/cibrax/archive/2011/06/13/interop-bindings-for-wcf-released-in-codeplex.aspx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10177478" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Text Encoding and WCF</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2011/04/05/text-encoding-and-wcf.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2011/04/05/text-encoding-and-wcf.aspx</id><published>2011-04-05T18:24:45Z</published><updated>2011-04-05T18:24:45Z</updated><content type="html">&lt;p&gt;For the most part setting the encoding (UTF-8, UTF-16, etc.) on a WCF service is pretty simple:&amp;#160; set textEncoding on &lt;a href="http://msdn.microsoft.com/en-us/library/ms731361.aspx"&gt;basicHttpBinding&lt;/a&gt;/&lt;a href="http://msdn.microsoft.com/en-us/library/ms731299.aspx"&gt;wsHttpBinding&lt;/a&gt; or encoding on a &lt;a href="http://msdn.microsoft.com/en-us/library/ms731787.aspx"&gt;textMessageEncoding&lt;/a&gt; in a &lt;a href="http://msdn.microsoft.com/en-us/library/ms731377.aspx"&gt;customBinding&lt;/a&gt;.&amp;#160; It works in almost all cases, but there’s a surprising number of ways of indicating the encoding of message:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;the content type of the message &lt;/li&gt;    &lt;li&gt;an XML declaration at the start of the message &lt;/li&gt;    &lt;li&gt;a BOM (byte order mark) that is the first 2 or 3 bytes (depending on encoding) of the message &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;Next an encoding of UTF-16 doesn’t specify a single encoding.&amp;#160; It could be either big endian or little endian.&lt;/p&gt;  &lt;p&gt;We can glean a few rules from &lt;a href="http://www.faqs.org/rfcs/rfc3023.html"&gt;RFC 3023 - XML Media Types&lt;/a&gt;:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;The encoding in the content type should take precedence over any other encoding indications.&amp;#160; If the content type is UTF-8 but the XML declaration is UTF-16, the message should actually be UTF-8.&amp;#160; For example, a router could receive a UTF-16 message and reencode it as UTF-8 to save bandwidth.&amp;#160; The router would change the content type but would keep the actual text of the entire message unchanged. &lt;/li&gt;    &lt;li&gt;When the encoding is specified as UTF-16, there must be a BOM. &lt;/li&gt;    &lt;li&gt;When the encoding is specified as UTF-16LE or UTF-16BE, there must not be a BOM. &lt;/li&gt;    &lt;li&gt;An XML declaration is optional in the presence of other indications of encoding. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;The TextMessageEncoder that ships with WCF is a little too strict in a couple of ways:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;When encoding is specified as UTF-16, it requires an XML declaration. &lt;/li&gt;    &lt;li&gt;The content type and the encoding specified in the XML declaration must be consistent. &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;This can lead to problems in interoperability.&amp;#160; Other web service clients can produce messages violating those WCF restrictions and the result is a 400 Bad Request with no additional information.&amp;#160; To work around this we will need a custom message encoder.&lt;/p&gt;  &lt;p&gt;First we can start with the &lt;a href="http://msdn.microsoft.com/en-us/library/ms751486.aspx"&gt;CustomTextMessageEncoder&lt;/a&gt; sample.&amp;#160; This sample allows you to specify any .NET supported encoding for an endpoint instead of just UTF-8 and UTF-16 but doesn’t do anything about the restrictions above.&amp;#160; Additionally it is necessary to specify which encoding you’ll use when deploying your endpoint.&lt;/p&gt;  &lt;p&gt;The new text message encoder I’ll show will accept UTF-8 and UTF-16 encoded messages and workaround those restrictions.&amp;#160; I’ll focus on the message encoder since that is where the action happens, but there is additional boilerplate necessary.&amp;#160; You will also need a &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.messageencoderfactory.aspx"&gt;MessageEncoderFactory&lt;/a&gt; (called by the framework to create instances of the &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.messageencoder.aspx"&gt;MessageEncoder&lt;/a&gt;), &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.messageencodingbindingelement.aspx"&gt;MessageEncodingBindingElement&lt;/a&gt; (used to plug this into the channel stack and allow the framework to create instances of the MessageEncoderFactory) and &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.configuration.bindingelementextensionelement.aspx"&gt;BindingElementExtensionElement&lt;/a&gt; (allows it to be used in config, this is optional).&amp;#160; The CustomTextMessageEncoder sample has excellent examples of each of these.&lt;/p&gt;  &lt;p&gt;Let’s start with &lt;a href="http://msdn.microsoft.com/en-us/library/aa344793.aspx"&gt;ReadMessage&lt;/a&gt;:&lt;/p&gt;  &lt;div id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; Message ReadMessage(ArraySegment&amp;lt;&lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;&amp;gt; buffer, &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;                     BufferManager bufferManager, &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; contentType)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.contentType = contentType;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;     &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[] msgContents = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; &lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[buffer.Count];&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;     Array.Copy(buffer.Array, &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;                 buffer.Offset, msgContents, 0, msgContents.Length);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;     bufferManager.ReturnBuffer(buffer.Array);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// most interoperable to include the xml declaration&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.writerSettings.OmitXmlDeclaration = &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// save the encoding for when we write the response&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.writerSettings.Encoding = GetEncoding(contentType, msgContents);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;     Encoding xmlDeclEncoding = GetXmlDeclEncoding(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;                                 writerSettings.Encoding, msgContents);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// xml declaration encoding doesn't match, need to reencode&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (xmlDeclEncoding != &lt;span style="color: #0000ff"&gt;null&lt;/span&gt; &amp;amp;&amp;amp; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;         xmlDeclEncoding.WebName != &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.writerSettings.Encoding.WebName)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;         msgContents = Encoding.Convert(&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt;                         &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.writerSettings.Encoding, &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt;                         xmlDeclEncoding, msgContents);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum25"&gt;  25:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum26"&gt;  26:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum27"&gt;  27:&lt;/span&gt;     MemoryStream stream = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MemoryStream(msgContents);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum28"&gt;  28:&lt;/span&gt;     XmlReader reader = XmlReader.Create(stream);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum29"&gt;  29:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; Message.CreateMessage(reader, maxSizeOfHeaders, MessageVersion);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum30"&gt;  30:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;This does a couple of things.&amp;#160; It uses some helper functions to help determine the actual encoding of the message and stores that in the &lt;a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlwritersettings.aspx"&gt;XmlWriterSettings&lt;/a&gt; that will be used in the response.&amp;#160; Unfortunately, there isn’t an implementation of &lt;a href="http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx"&gt;XmlReader&lt;/a&gt; that ships with .NET that will ignore the encoding specified in the XML declaration so if the content type and XML declaration disagree the message needs to be reencoded to match the XML declaration.&amp;#160; Finally &lt;a href="http://msdn.microsoft.com/en-us/library/system.xml.xmldictionaryreader.aspx"&gt;XmlDictionaryReader&lt;/a&gt; is the source of the restrictions above so we use &lt;a href="http://msdn.microsoft.com/en-us/library/756wd7zs.aspx"&gt;XmlReader.Create&lt;/a&gt; to avoid that.&lt;/p&gt;

&lt;p&gt;Now let’s look at the encoding helper functions:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; Encoding GetXmlDeclEncoding(Encoding contentTypeEncoding, &lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[] message)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// get a possible xml declaration from the message&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; contents = contentTypeEncoding.GetString(message, 0, 100);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// capture the encoding from the xml declaraion&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; pattern = &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;         &lt;span style="color: #006080"&gt;&amp;quot;&amp;lt;\\?xml\\sversion=\&amp;quot;1.0\&amp;quot;\\sencoding=\&amp;quot;(?&amp;lt;encoding&amp;gt;[\\w|-]+)\&amp;quot;&amp;quot;&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;     Match m = Regex.Match(contents, pattern, RegexOptions.ExplicitCapture);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (m.Groups[&lt;span style="color: #006080"&gt;&amp;quot;encoding&amp;quot;&lt;/span&gt;].Success)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; Encoding.GetEncoding(m.Groups[&lt;span style="color: #006080"&gt;&amp;quot;encoding&amp;quot;&lt;/span&gt;].Value);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;null&lt;/span&gt;;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;GetXmlDeclEncoding tries to find an encoding pseudoattribute in a possible XML declaration at the beginning of the message.&amp;#160; Since the message must be encoded as specified in the content type we use that encoding to decode the byte array.&amp;#160; XmlReader provides ways to determine values specified in the XML declaration, but as mentioned above it will throw when it discovers the specified encoding doesn’t match the actual encoding.&amp;#160; A regular expression match is used to avoid this.&amp;#160; We only decode the first 100 bytes to minimize overhead.&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; Encoding GetEncoding(&lt;span style="color: #0000ff"&gt;string&lt;/span&gt; contentType, &lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[] message)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;     Encoding encoding;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;string&lt;/span&gt; charSet = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ContentType(contentType).CharSet.ToLower();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (charSet == &lt;span style="color: #006080"&gt;&amp;quot;utf-8&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;         encoding = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; UTF8Encoding();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (charSet == &lt;span style="color: #006080"&gt;&amp;quot;utf-16&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (message[0] == 0xff &amp;amp;&amp;amp; message[1] == 0xfe)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;             encoding = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; UnicodeEncoding(&lt;span style="color: #0000ff"&gt;false&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (message[0] == 0xfe &amp;amp;&amp;amp; message[1] == 0xff)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;             encoding = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; UnicodeEncoding(&lt;span style="color: #0000ff"&gt;true&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;true&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;         {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt;             &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; InvalidOperationException(&lt;span style="color: #006080"&gt;&amp;quot;No byte order mark &amp;quot;&lt;/span&gt; + &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;                 &lt;span style="color: #006080"&gt;&amp;quot;detected.  The byte order mark is required when &amp;quot;&lt;/span&gt; +&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt;                 &lt;span style="color: #006080"&gt;&amp;quot;charset=utf-16.&amp;quot;&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt;         }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum25"&gt;  25:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum26"&gt;  26:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (charSet == &lt;span style="color: #006080"&gt;&amp;quot;utf-16le&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum27"&gt;  27:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum28"&gt;  28:&lt;/span&gt;         encoding = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; UnicodeEncoding(&lt;span style="color: #0000ff"&gt;false&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum29"&gt;  29:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum30"&gt;  30:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;else&lt;/span&gt; &lt;span style="color: #0000ff"&gt;if&lt;/span&gt; (charSet == &lt;span style="color: #006080"&gt;&amp;quot;utf-16be&amp;quot;&lt;/span&gt;)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum31"&gt;  31:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum32"&gt;  32:&lt;/span&gt;         encoding = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; UnicodeEncoding(&lt;span style="color: #0000ff"&gt;true&lt;/span&gt;, &lt;span style="color: #0000ff"&gt;false&lt;/span&gt;);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum33"&gt;  33:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum34"&gt;  34:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;else&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum35"&gt;  35:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum36"&gt;  36:&lt;/span&gt;         &lt;span style="color: #008000"&gt;// this could be replaced by a call to Encoding.GetEncoding&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum37"&gt;  37:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;throw&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; InvalidOperationException(&lt;span style="color: #006080"&gt;&amp;quot;Unrecognized charset: &amp;quot;&lt;/span&gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum38"&gt;  38:&lt;/span&gt;                     + charSet);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum39"&gt;  39:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum40"&gt;  40:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum41"&gt;  41:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; encoding;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum42"&gt;  42:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;GetEncoding is a fairly straightforward implementation of the rules above.&amp;#160; For undifferentiated UTF-16 it checks the BOM and creates the proper encoding that will include a BOM.&amp;#160; For UTF-16LE/BE it creates the proper encoding and suppresses the BOM (it ignores whether a BOM is included making a bit looser on read).&amp;#160; This only recognizes UTF-8 and UTF-16, but it could be modified to call &lt;a href="http://msdn.microsoft.com/en-us/library/t9a3kf7c.aspx"&gt;Encoding.GetEncoding&lt;/a&gt; to get any supported encoding.&lt;/p&gt;

&lt;p&gt;Finally let’s look at writing a message:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; ArraySegment&amp;lt;&lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;&amp;gt; WriteMessage(Message message, &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; maxMessageSize, BufferManager bufferManager, &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;                 &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; messageOffset)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;     MemoryStream stream = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; MemoryStream();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;     XmlWriter writer = XmlWriter.Create(stream, &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.writerSettings);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;     message.WriteMessage(writer);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;     writer.Close();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[] messageBytes = stream.GetBuffer();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; messageLength = (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)stream.Position;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;     stream.Close();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;int&lt;/span&gt; totalLength = messageLength + messageOffset;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;[] totalBytes = bufferManager.TakeBuffer(totalLength);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;     Array.Copy(messageBytes, 0, totalBytes, messageOffset, messageLength);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum18"&gt;  18:&lt;/span&gt;     ArraySegment&amp;lt;&lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;&amp;gt; byteArray = &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum19"&gt;  19:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ArraySegment&amp;lt;&lt;span style="color: #0000ff"&gt;byte&lt;/span&gt;&amp;gt;(totalBytes, messageOffset, messageLength);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum20"&gt;  20:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; byteArray;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum21"&gt;  21:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum22"&gt;  22:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum23"&gt;  23:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;public&lt;/span&gt; &lt;span style="color: #0000ff"&gt;override&lt;/span&gt; &lt;span style="color: #0000ff"&gt;void&lt;/span&gt; WriteMessage(Message message, Stream stream)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum24"&gt;  24:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum25"&gt;  25:&lt;/span&gt;     XmlWriter writer = XmlWriter.Create(stream, &lt;span style="color: #0000ff"&gt;this&lt;/span&gt;.writerSettings);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum26"&gt;  26:&lt;/span&gt;     message.WriteMessage(writer);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum27"&gt;  27:&lt;/span&gt;     writer.Close();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum28"&gt;  28:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;These are actually identical to the WriteMessage implementations in the custom encoder sample.&amp;#160; They simple use the writerSettings populated by ReadMessage to write out the message.&lt;/p&gt;

&lt;p&gt;This will require a &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.channels.custombinding.aspx"&gt;CustomBinding&lt;/a&gt; to use.&amp;#160; It is possible to do it in code: &lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; var messageEncoding = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; ImprovedTextMessageBindingElement&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color: #008000"&gt;// any message version is supported&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     MessageVersion = MessageVersion.Soap12&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt; };&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt; var transport = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; HttpTransportBindingElement();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt; var binding = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; CustomBinding(messageEncoding, transport);&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Or config:&lt;/p&gt;

&lt;div id="codeSnippetWrapper"&gt;
  &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;
    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &amp;lt;customBinding&amp;gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt;     &amp;lt;binding&amp;gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;         &amp;lt;improvedTextMessageEncoding /&amp;gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;         &amp;lt;httpTransport /&amp;gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;     &amp;lt;/binding&amp;gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt; &amp;lt;/customBinding&amp;gt; &lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;&amp;#160; &lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10150146" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Deciphering a SOAP fault with a 400 status code</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2011/03/31/deciphering-a-soap-fault-with-a-400-status-code.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2011/03/31/deciphering-a-soap-fault-with-a-400-status-code.aspx</id><published>2011-03-31T23:55:19Z</published><updated>2011-03-31T23:55:19Z</updated><content type="html">&lt;p&gt;Recently working with a partner I came across a solution for a limitation in WCF error handling.&amp;#160; The root of the issue is a difference between SOAP 1.1 and SOAP 1.2 in the allowed HTTP status codes when a SOAP fault is returned.&amp;#160; For &lt;a href="http://www.w3.org/TR/2000/NOTE-SOAP-20000508/#_Toc478383529"&gt;SOAP 1.1&lt;/a&gt;, the status code must be 500 “Internal Server Error”.&amp;#160; For &lt;a href="http://www.w3.org/TR/2007/REC-soap12-part2-20070427/#http-respbindprocess"&gt;SOAP 1.2&lt;/a&gt;, it varies based on the type of the SOAP fault.&amp;#160; For env:Sender, the status code is 400 “Bad Request”, but for anything else it is 500 like SOAP 1.1.&lt;/p&gt;  &lt;p&gt;When WCF receives an HTTP error code it wraps it in an exception, &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.faultexception.aspx"&gt;FaultException&lt;/a&gt; in the case of 500 and &lt;a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.protocolexception.aspx"&gt;ProtocolException&lt;/a&gt; in the case of 400.&amp;#160; This means when a service returns a SOAP fault with a 400 status code, all the information about it is lost instead of showing up in a nicely populated FaultException.&amp;#160; Actually it isn’t lost, it’s just hidden.&amp;#160; The InnerException of the ProtocolException is a &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.webexception.aspx"&gt;WebException&lt;/a&gt; generated by the HTTP response.&amp;#160; And on the WebException, lo and behold, is the the actual &lt;a href="http://msdn.microsoft.com/en-us/library/system.net.webresponse.aspx"&gt;WebResponse&lt;/a&gt; with that SOAP fault just waiting to be read out of the stream.&amp;#160; So with a little manipulation you can turn these ProtocolExceptions into FaultExceptions:&lt;/p&gt;  &lt;div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper"&gt;   &lt;div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px" id="codeSnippet"&gt;     &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum1"&gt;   1:&lt;/span&gt; &lt;span style="color: #0000ff"&gt;static&lt;/span&gt; FaultException ParseProtocolExecption(ProtocolException ex)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum2"&gt;   2:&lt;/span&gt; {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum3"&gt;   3:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;try&lt;/span&gt;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum4"&gt;   4:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum5"&gt;   5:&lt;/span&gt;         System.IO.Stream stream = (ex.InnerException &lt;span style="color: #0000ff"&gt;as&lt;/span&gt; WebException).Response.GetResponseStream();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum6"&gt;   6:&lt;/span&gt;         System.Xml.XmlReader xmr = System.Xml.XmlReader.Create(stream);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum7"&gt;   7:&lt;/span&gt;         Message message = Message.CreateMessage(xmr, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)stream.Length, MessageVersion.Soap12);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum8"&gt;   8:&lt;/span&gt;         MessageFault mf = MessageFault.CreateFault(message, (&lt;span style="color: #0000ff"&gt;int&lt;/span&gt;)stream.Length);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum9"&gt;   9:&lt;/span&gt;         FaultException fe = &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; FaultException(mf);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum10"&gt;  10:&lt;/span&gt;         message.Close();&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum11"&gt;  11:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; fe;&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum12"&gt;  12:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum13"&gt;  13:&lt;/span&gt;     &lt;span style="color: #0000ff"&gt;catch&lt;/span&gt; (Exception)&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum14"&gt;  14:&lt;/span&gt;     {&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum15"&gt;  15:&lt;/span&gt;         &lt;span style="color: #0000ff"&gt;return&lt;/span&gt; &lt;span style="color: #0000ff"&gt;new&lt;/span&gt; FaultException(ex.Message);&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum16"&gt;  16:&lt;/span&gt;     }&lt;/pre&gt;
&lt;!--CRLF--&gt;

    &lt;pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: white; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px"&gt;&lt;span style="color: #606060" id="lnum17"&gt;  17:&lt;/span&gt; }&lt;/pre&gt;
&lt;!--CRLF--&gt;&lt;/div&gt;
&lt;/div&gt;

&lt;p&gt;Note if there isn’t a SOAP fault in the response, this will throw again, you’ll want to handle that in the best way for your application.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=10148491" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>TestApi v0.3 released</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2009/07/27/testapi-v0-3-released.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2009/07/27/testapi-v0-3-released.aspx</id><published>2009-07-27T19:45:00Z</published><updated>2009-07-27T19:45:00Z</updated><content type="html">&lt;P&gt;TestApi is a collection of test and utility API's written to make testing WPF, WinForms, .NET, and Win32 applications easy.&amp;nbsp; I made some contributions to last week's release (combinatorial variation generation).&amp;nbsp; Also new is a fault injection engine.&amp;nbsp; Previous features have included:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Command line parsing&lt;/LI&gt;
&lt;LI&gt;Visual verification&lt;/LI&gt;
&lt;LI&gt;Application control&lt;/LI&gt;
&lt;LI&gt;Several WPF utilities&lt;/LI&gt;&lt;/UL&gt;
&lt;P&gt;You can check it out here:&amp;nbsp; &lt;A href="http://testapi.codeplex.com/"&gt;http://testapi.codeplex.com/&lt;/A&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9850173" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>XAMLFest</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2009/05/22/xamlfest.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2009/05/22/xamlfest.aspx</id><published>2009-05-22T18:49:00Z</published><updated>2009-05-22T18:49:00Z</updated><content type="html">If you're interested in what XAML can do for you today and what tooling is available, check out &lt;A href="http://xamlfestonline.com/" mce_href="http://xamlfestonline.com"&gt;XAMLFest&lt;/A&gt;.&amp;nbsp; There's a whole series of web seminars on WPF, Silverlight, Blend, and Visual Studio.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9635334" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>New XAML features in .NET 4.0 Beta 1</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2009/05/22/new-xaml-features-in-net-4-0-beta-1.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2009/05/22/new-xaml-features-in-net-4-0-beta-1.aspx</id><published>2009-05-22T17:51:00Z</published><updated>2009-05-22T17:51:00Z</updated><content type="html">&lt;P&gt;There's a whole new XAML stack in the recently released beta 1 (download &lt;A href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx" mce_href="http://www.microsoft.com/visualstudio/en-us/products/2010/default.mspx"&gt;here&lt;/A&gt;) with a bunch of exciting new features making XAML even more expressive.&amp;nbsp; You can check out &lt;A href="http://blogs.windowsclient.net/rob_relyea/archive/2009/05/19/xaml2009-and-system-xaml-dll-preview-in-net-fx-4-beta1.aspx" mce_href="http://blogs.windowsclient.net/rob_relyea/archive/2009/05/19/xaml2009-and-system-xaml-dll-preview-in-net-fx-4-beta1.aspx"&gt;Rob's blog&lt;/A&gt;&amp;nbsp;and &lt;A href="http://channel9.msdn.com/shows/Continuum/XAMLinNET4/" mce_href="http://channel9.msdn.com/shows/Continuum/XAMLinNET4/"&gt;Channel 9&lt;/A&gt;&amp;nbsp;for an overview.&amp;nbsp; I thought I'd discuss some new features for designing new types (Activities, Services, etc) in XAML.&amp;nbsp; Sorry, this isn't supported for WPF as of now.&lt;/P&gt;
&lt;P&gt;When you fire up Visual Studio 2010 and create a new WCF or WF project, you'll see there's now a XAML file that defines your workflow or service.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;For WCF, the service is actually "loose" XAML.&amp;nbsp; It doesn't create a new type and will simply be instantiated by your service host with the equivalent of XamlServices.Load.&lt;/P&gt;
&lt;P&gt;For WF, the workflow is defined as a&amp;nbsp;new type that will be compiled as part of your project, if you look at the XAML in the new project there'll be something like this:&lt;/P&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;p:Activity&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;x:Class&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;WorkflowConsoleApplication1.Sequence1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; ...&lt;/P&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;Nothing new here except x:Class is applied to a WF type instead of WPF.&amp;nbsp; Now lets add some arguments to the Activity:&lt;/P&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;p:Activity&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;x:Class&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;WorkflowConsoleApplication1.Sequence1&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; ...&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;gt;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;x:Members&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&amp;gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;x:Property&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;Name&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;Input&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;Type&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;p:InArgument(x:String)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; /&amp;gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;x:Property&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;Name&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;Output&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;Type&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;p:OutArgument(x:String)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; /&amp;gt;&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&amp;lt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;&lt;FONT color=#a31515 size=2 face=Consolas&gt;x:Property&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;Name&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;Temp&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; &lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;&lt;FONT color=#ff0000 size=2 face=Consolas&gt;Type&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;=&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;x:String&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT size=2 face=Consolas&gt;&lt;FONT size=2 face=Consolas&gt;"&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt; /&amp;gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;&lt;FONT color=#0000ff size=2 face=Consolas&gt;...&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BLOCKQUOTE&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;
&lt;P&gt;Here's where we see some of the new XAML features.&amp;nbsp; x:Members defines a collection of new members to add to this type.&amp;nbsp; x:Property adds a property.&amp;nbsp; Name and type are specified here, visibility (public, protected, etc)&amp;nbsp;can be specified with the Modifer property.&amp;nbsp; We can also see the new generics support as p:InArgument(x:String) refers to the type InArgument&amp;lt;string&amp;gt;.&amp;nbsp; All of the new language features mentioned in Rob's post can be used in this XAML.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9635325" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Lots of new WCF REST resources available</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2008/10/30/lots-of-new-wcf-rest-resources-available.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2008/10/30/lots-of-new-wcf-rest-resources-available.aspx</id><published>2008-10-30T23:58:00Z</published><updated>2008-10-30T23:58:00Z</updated><content type="html">&lt;P&gt;A new developer center just for WCF REST is now live at MSDN:&amp;nbsp; &lt;A href="http://msdn.microsoft.com/wcf/rest"&gt;http://msdn.microsoft.com/wcf/rest&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;Plus the WCF REST Starter kit with oodles of goodies is available at Codeplex: &lt;A href="http://www.codeplex.com/aspnet/Wiki/View.aspx?title=WCF%20REST"&gt;http://www.codeplex.com/aspnet/Wiki/View.aspx?title=WCF%20REST&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;There's also a forum to discuss the starter kit:&amp;nbsp; &lt;A href="http://forums.asp.net/1180.aspx"&gt;http://forums.asp.net/1180.aspx&lt;/A&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9025286" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>PDC is coming</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2008/10/07/pdc-is-coming.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2008/10/07/pdc-is-coming.aspx</id><published>2008-10-07T23:38:00Z</published><updated>2008-10-07T23:38:00Z</updated><content type="html">&lt;P&gt;Uncloaking after a long absence, here's some of what is new and exciting for the next release of WCF and WF:&amp;nbsp; everything can be done in XAML.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.windowsclient.net/rob_relyea/archive/2008/09/30/pdc08-xaml-talk.aspx"&gt;http://blogs.windowsclient.net/rob_relyea/archive/2008/09/30/pdc08-xaml-talk.aspx&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://channel9.msdn.com/pdc2008/TL36/"&gt;http://channel9.msdn.com/pdc2008/TL36/&lt;/A&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8987302" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>WCF Web Programming Help Page</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2007/09/17/wcf-web-programming-help-page.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2007/09/17/wcf-web-programming-help-page.aspx</id><published>2007-09-17T19:51:00Z</published><updated>2007-09-17T19:51:00Z</updated><content type="html">&lt;P&gt;When developing a WCF service using the new web programming features, it's natural to make sure all the basics are taken care of by entering the service address into a browser.&amp;nbsp;&amp;nbsp;When the service is running correctly, this page is returned:&lt;/P&gt;
&lt;P&gt;&lt;IMG src="http://blogs.msdn.com/photos/nathana/images/4958742/original.aspx" border=0 mce_src="http://blogs.msdn.com/photos/nathana/images/4958742/original.aspx"&gt;&lt;/P&gt;
&lt;P&gt;This indicates the service is running but little else.&amp;nbsp; There's lots of other information that would be useful to include, maybe something like this (I'm not an html wizard so this could be greatly improved:)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;IMG src="http://blogs.msdn.com/photos/nathana/images/4959488/original.aspx" border=0&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;This is made possible by including an OperationContract like this in the ServiceContract:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;WebInvoke&lt;/SPAN&gt;(UriTemplate = &lt;SPAN style="COLOR: #a31515"&gt;"*"&lt;/SPAN&gt;, Method = &lt;SPAN style="COLOR: #a31515"&gt;"*"&lt;/SPAN&gt;)]&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;OperationContract&lt;/SPAN&gt;]&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;Message&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt; Help(&lt;SPAN style="COLOR: #2b91af"&gt;Message&lt;/SPAN&gt; m);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;The method can be named anything and UriTemplate and Method can be tweaked to serve custom help for only certain situations.&amp;nbsp; As&amp;nbsp;shown, any message routed to the service that doesn't match another operation contract will call Help.&amp;nbsp; To implement this method I created two classes, WebHttpHelpPageGenerator and WebHttpHelpPageMessage.&amp;nbsp; WebHttpHelpPageGenerator handles collecting the information to display and WebHttpHelpPageMessage derives from Message and handles formatting that information into html.&amp;nbsp; These are used to implement Help like this:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;public&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Message&lt;/SPAN&gt; Help(&lt;SPAN style="COLOR: #2b91af"&gt;Message&lt;/SPAN&gt; m)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;return&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WebHttpHelpPageGenerator&lt;/SPAN&gt;.GenerateHelpPage();&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;WebHttpHelpPageGenerator.GenerateHelpPage is able to accomplish its task by using OperationContext.Current.EndpointDispatch.ContractName and OperationContext.Current.Host.Description.Endpoints to find the current ServiceEndpoint which contains a list of Operations and the CLR type of the contract:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;ServiceEndpointCollection&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; endpoints = &lt;SPAN style="COLOR: #2b91af"&gt;OperationContext&lt;/SPAN&gt;.Current.Host.Description.Endpoints;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;OperationDescriptionCollection&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; operations = &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;Type&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; contract = &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;foreach&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;ServiceEndpoint&lt;/SPAN&gt; endpoint &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; endpoints)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (endpoint.Contract.Name == &lt;SPAN style="COLOR: #2b91af"&gt;OperationContext&lt;/SPAN&gt;.Current.EndpointDispatcher.ContractName)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;contract = endpoint.Contract.ContractType;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;operations = endpoint.Contract.Operations;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;break&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;}&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;}&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;So with that list and a little reflection all the necessary information can be exctracted:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;message.TitleTextString = contract.Name;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;foreach&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; (&lt;SPAN style="COLOR: #2b91af"&gt;OperationDescription&lt;/SPAN&gt; operation &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; operations)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;WebGetAttribute&lt;/SPAN&gt; get = operation.Behaviors.Find&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;WebGetAttribute&lt;/SPAN&gt;&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;WebInvokeAttribute&lt;/SPAN&gt; invoke = operation.Behaviors.Find&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;WebInvokeAttribute&lt;/SPAN&gt;&amp;gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;if&lt;/SPAN&gt; (get == &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt; &amp;amp;&amp;amp; invoke == &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt;) &lt;SPAN style="COLOR: blue"&gt;continue&lt;/SPAN&gt;;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;MethodInfo&lt;/SPAN&gt; method = contract.GetMethod(operation.Name);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;OperationInfo&lt;/SPAN&gt; info = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;OperationInfo&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;OperationName = operation.Name,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Method = get != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt; ? &lt;SPAN style="COLOR: #a31515"&gt;"GET"&lt;/SPAN&gt; : invoke.Method,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;BodyStyle = get != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt; ? get.BodyStyle.ToString() : invoke.BodyStyle.ToString(),&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;UriTemplate = get != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt; ? get.UriTemplate : invoke.UriTemplate,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ReturnType = method.ReturnType.ToString(),&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;Parameters = GetFormattedParameters(method.GetParameters()),&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;RequestFormat = get != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt; ? get.RequestFormat.ToString() : invoke.ResponseFormat.ToString(),&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;ResponseFormat = get != &lt;SPAN style="COLOR: blue"&gt;null&lt;/SPAN&gt; ? get.ResponseFormat.ToString() : invoke.ResponseFormat.ToString()&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;};&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;info.OperationName = operation.Name;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;message.Operations.Add(info);&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;OperationInfo is just a helper class to encapsulate all the data collected.&amp;nbsp; Finally the new WebOperationContext class is used to set the content type to text/html:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;WebOperationContext&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;.Current.OutgoingResponse.ContentType = &lt;SPAN style="COLOR: #a31515"&gt;"text/html"&lt;/SPAN&gt;;&lt;/SPAN&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;This builds a general purpose framework that can be called from any service using the new web programming features, though I'm sure I missed plenty of corner cases (like async programming.)&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4959187" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>WCF Web Programming or: How I Learned to Stop Worrying and Love Uri Templates</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2007/09/13/wcf-web-programming-or-how-i-learned-to-stop-worrying-and-love-uri-templates.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2007/09/13/wcf-web-programming-or-how-i-learned-to-stop-worrying-and-love-uri-templates.aspx</id><published>2007-09-14T00:52:00Z</published><updated>2007-09-14T00:52:00Z</updated><content type="html">&lt;P&gt;Using WCF in web programming scenarios is much simplified in Orcas beta 2 (see &lt;A href="http://hyperthink.net/blog/CategoryView,category,indigo.aspx"&gt;http://hyperthink.net/blog/CategoryView,category,indigo.aspx&lt;/A&gt;&amp;nbsp;and scroll down for more discussions).&amp;nbsp; Maybe you want to write an app that searches Flickr, how can you use WCF?&amp;nbsp; Well, define an interface that exposes the functionality you need:&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;ServiceContract&lt;/SPAN&gt;]&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;interface&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: #2b91af"&gt;IFlickrSearch&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;WebGet&lt;/SPAN&gt;(UriTemplate=&lt;SPAN style="COLOR: #a31515"&gt;"services/rest/?method=flickr.photos.search&amp;amp;api_key={appId}&amp;amp;tags={searchTerms}&amp;amp;extras={extras}&amp;amp;per_page={perPage}"&lt;/SPAN&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;BodyStyle=&lt;SPAN style="COLOR: #2b91af"&gt;WebMessageBodyStyle&lt;/SPAN&gt;.Bare)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;OperationContract&lt;/SPAN&gt;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;XmlSerializerFormat&lt;/SPAN&gt;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;rsp&lt;/SPAN&gt; Search(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; appId, &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; searchTerms, &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; extras, &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; perPage);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/SPAN&gt;The &lt;A class="" href="http://www.flickr.com/services/api/" mce_href="http://www.flickr.com/services/api/"&gt;Flickr API&lt;/A&gt; is very rich, so this is just the tip of the iceberg, but just this little bit of code accomplishes a lot.&amp;nbsp; We have all the WCF v1 attributes (ServiceContract, OperationContract) and some new stuff.&amp;nbsp; WebGet says the request will be a GET and UriTemplate describes how the parameters will be turned into the uri for the request.&amp;nbsp; This provides a great deal of flexibility in defining your interface to the service you're programming against.&amp;nbsp; The Bare BodyStyle specifies to the serializer there won't be wrapper element named SearchResponse on the response.&amp;nbsp; XmlSerializerFormat is another holdover specifying the XmlSerializer, and rsp is a&amp;nbsp;type generated with xsd.exe to deserialize the response.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Now we're ready to call Flickr:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;WebChannelFactory&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;IFlickrSearch&lt;/SPAN&gt;&amp;gt; factory =&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;WebChannelFactory&lt;/SPAN&gt;&amp;lt;&lt;SPAN style="COLOR: #2b91af"&gt;IFlickrSearch&lt;/SPAN&gt;&amp;gt;(&lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;Uri&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #a31515"&gt;"http://api.flickr.com"&lt;/SPAN&gt;));&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 10pt"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;IFlickrSearch&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; LINE-HEIGHT: 115%; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; channel = factory.CreateChannel();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;rsp&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt; flickrRsp = channel.Search(AppId, searchTerms, Extras, perPage);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;And that's it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Maybe you're saying XmlSerializer is way too 20th century and you'd like use something more 21st, like XLinq.&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;ServiceContract&lt;/SPAN&gt;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;interface&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; &lt;SPAN style="COLOR: #2b91af"&gt;IFlickrSearch&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;{&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;WebGet&lt;/SPAN&gt;(UriTemplate = &lt;SPAN style="COLOR: #a31515"&gt;"services/rest/?method=flickr.photos.search&amp;amp;api_key={appId}&amp;amp;tags={searchTerms}&amp;amp;extras={extras}&amp;amp;per_page={perPage}"&lt;/SPAN&gt;,&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;BodyStyle = &lt;SPAN style="COLOR: #2b91af"&gt;WebMessageBodyStyle&lt;/SPAN&gt;.Bare)]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;[&lt;SPAN style="COLOR: #2b91af"&gt;OperationContract&lt;/SPAN&gt;]&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: #2b91af"&gt;XElement&lt;/SPAN&gt; Search(&lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; appId, &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; searchTerms, &lt;SPAN style="COLOR: blue"&gt;string&lt;/SPAN&gt; extras, &lt;SPAN style="COLOR: blue"&gt;int&lt;/SPAN&gt; perPage);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;}&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;/SPAN&gt;We've just taken out the XmlSerializerFormat attribute and replaced the rsp type with XElement.&amp;nbsp; Now we can use Linq and turn the Flickr search into a SyndicationFeed (another new WCF Orcas feature):&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; COLOR: #2b91af; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;SyndicationFeed&lt;/SPAN&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt; feed = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;SyndicationFeed&lt;/SPAN&gt;();&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;feed.Title = &lt;SPAN style="COLOR: blue"&gt;new&lt;/SPAN&gt; &lt;SPAN style="COLOR: #2b91af"&gt;TextSyndicationContent&lt;/SPAN&gt;(&lt;SPAN style="COLOR: #a31515"&gt;"Flickr search"&lt;/SPAN&gt;);&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;o:p&gt;&amp;nbsp;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;feed.Items =&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt; LINE-HEIGHT: normal; mso-layout-grid-align: none"&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;from&lt;/SPAN&gt; photos &lt;SPAN style="COLOR: blue"&gt;in&lt;/SPAN&gt; flickrXml.Elements(&lt;SPAN style="COLOR: #a31515"&gt;"photos"&lt;/SPAN&gt;).Elements(&lt;SPAN style="COLOR: #a31515"&gt;"photo"&lt;/SPAN&gt;)&lt;o:p&gt;&lt;/o:p&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'; mso-no-proof: yes; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-ansi-language: EN-US; mso-fareast-language: EN-US; mso-bidi-language: AR-SA"&gt;&lt;SPAN style="mso-spacerun: yes"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="COLOR: blue"&gt;select&lt;/SPAN&gt; SyndicationItemFromXElement(photos);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Just add this to a service and now you have a Flickr search you can subscribe to in the feed aggregator of your choice.&lt;/FONT&gt;&lt;FONT size=2&gt;&lt;/P&gt;&lt;/FONT&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4902877" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Getting started with LINQ</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2007/09/12/getting-started-with-linq.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2007/09/12/getting-started-with-linq.aspx</id><published>2007-09-12T19:28:00Z</published><updated>2007-09-12T19:28:00Z</updated><content type="html">&lt;P&gt;Here's a great site with a bunch of&amp;nbsp;samples if you've said to yourself "I'm pretty sure&amp;nbsp;I can do this&amp;nbsp;with LINQ, but I'm not quite sure how."&lt;/P&gt;
&lt;P&gt;&lt;A class="" href="http://msdn2.microsoft.com/en-us/vcsharp/aa336746.aspx" mce_href="http://msdn2.microsoft.com/en-us/vcsharp/aa336746.aspx"&gt;101 LINQ Samples&lt;/A&gt;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4881713" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Custom SOAP Headers: WCF and ASMX</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2007/05/29/custom-soap-headers-wcf-and-asmx.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2007/05/29/custom-soap-headers-wcf-and-asmx.aspx</id><published>2007-05-29T23:59:00Z</published><updated>2007-05-29T23:59:00Z</updated><content type="html">&lt;P&gt;First the good news, WCF clients should just work with&amp;nbsp;ASMX services that use custom&amp;nbsp;SOAP headers.&lt;/P&gt;
&lt;P&gt;Now the not so good news, ASMX clients will work with WCF services that use headers, but the object model is pretty funky.&amp;nbsp; Say you want to do something really crazy like have a header of type string.&amp;nbsp; The ASMX client will represent that header with a class that looks like this:&lt;/P&gt;
&lt;P&gt;[System.Xml.Serialization.XmlTypeAttribute(Namespace="&lt;A href="http://www.w3.org/2001/XMLSchema" mce_href="http://www.w3.org/2001/XMLSchema"&gt;http://www.w3.org/2001/XMLSchema&lt;/A&gt;")]&lt;BR&gt;[System.Xml.Serialization.XmlRootAttribute("StringHeader", Namespace="&lt;A href="http://xwsinterop/soapwsdl/headers" mce_href="http://xwsinterop/soapwsdl/headers"&gt;http://xwsinterop/soapwsdl/headers&lt;/A&gt;", IsNullable=true)]&lt;BR&gt;public partial class @string : System.Web.Services.Protocols.SoapHeader {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; private string[] textField;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; /// &amp;lt;remarks/&amp;gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; [System.Xml.Serialization.XmlTextAttribute()]&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public string[] Text {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; get {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return this.textField;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; this.textField = value;&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;BR&gt;}&lt;/P&gt;
&lt;P&gt;To use this class, assign a new string array of length 1 to Text and then assign the value of the header to that element and it will work as expected.&amp;nbsp; These sorts of classes will be generated by ASMX for any simple type, the workaround is to use wrapper classes around the headers on the WCF side.&amp;nbsp; This will result in a somewhat clunky OM, but it will make sense.&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2974915" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Custom SOAP Headers:  WCF and Java</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2007/05/29/custom-soap-headers-wcf-and-java.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2007/05/29/custom-soap-headers-wcf-and-java.aspx</id><published>2007-05-29T23:29:00Z</published><updated>2007-05-29T23:29:00Z</updated><content type="html">&lt;P&gt;First the good news, WCF clients should just work with Java services that use custom&amp;nbsp;SOAP headers.&lt;/P&gt;
&lt;P&gt;Now the not so good news, Java proxies generated from the default WCF WSDL won't include the SOAP headers in the object model.&amp;nbsp; The root problem is most Java platforms represent headers in WSDL differently than WCF.&amp;nbsp; In WCF, the body and the headers are defined in different WSDL message elements:&lt;/P&gt;
&lt;P&gt;&amp;lt;wsdl:message name="OneHeaderIntRequest"&amp;gt;&lt;BR&gt;&amp;lt;wsdl:part name="stringBody" element="tns:stringBody" /&amp;gt; &lt;BR&gt;&amp;lt;/wsdl:message&amp;gt;&lt;BR&gt;&amp;lt;wsdl:message name="OneHeaderIntRequest_Headers"&amp;gt;&lt;BR&gt;&amp;lt;wsdl:part name="IntHeader" element="tns:IntHeader" /&amp;gt; &lt;BR&gt;&amp;lt;/wsdl:message&amp;gt;&lt;/P&gt;
&lt;P&gt;but for most Java platforms, only one message with multiple parts is defined:&lt;/P&gt;
&lt;P&gt;&amp;lt;message name="OneHeaderIntRequest"&amp;gt;&lt;BR&gt;&amp;lt;part element="s0:stringBody" name="parameters" /&amp;gt; &lt;BR&gt;&amp;lt;part element="s0:IntHeader" name="IntHeader" /&amp;gt; &lt;BR&gt;&amp;lt;/message&amp;gt;&lt;/P&gt;
&lt;P&gt;The workaround is to modify the WCF WSDL to mirror the Java-style WSDL (eliminate the OneHeaderIntRequest_Headers message and move the IntHeader part into the OneHeaderIntRequest message in this case).&amp;nbsp; Unfortunately this is a manual process.&amp;nbsp; Now to serve this wsdl requires setting the ExternalMetadataLocation property on the ServiceMetadataBehavior either &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/system.servicemodel.description.servicemetadatabehavior.externalmetadatalocation.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/system.servicemodel.description.servicemetadatabehavior.externalmetadatalocation.aspx"&gt;in a service host&lt;/A&gt; or &lt;A class="" href="http://msdn2.microsoft.com/en-us/library/ms731317.aspx" mce_href="http://msdn2.microsoft.com/en-us/library/ms731317.aspx"&gt;in config&lt;/A&gt;.&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2974760" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>How do I get a DateTime from a UNIX timestamp?</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2007/05/13/how-do-i-get-a-datetime-from-a-unix-timestamp.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2007/05/13/how-do-i-get-a-datetime-from-a-unix-timestamp.aspx</id><published>2007-05-14T01:49:00Z</published><updated>2007-05-14T01:49:00Z</updated><content type="html">&lt;P&gt;Often when consuming data from a web site, it will represent time with a UNIX timestamp.&amp;nbsp; This is the number of seconds since January 1, 1970.&amp;nbsp; It would be nice to turn this into a System.DateTime, but how?&lt;FONT color=#008080 size=2&gt;&lt;/P&gt;
&lt;P&gt;DateTime&lt;/FONT&gt;&lt;FONT size=2&gt; FromUnixTime(&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;Int64&lt;/FONT&gt;&lt;FONT size=2&gt; unixTime)&lt;/P&gt;
&lt;P&gt;{&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DateTime&lt;/FONT&gt;&lt;FONT size=2&gt; time = &lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;new&lt;/FONT&gt;&lt;FONT size=2&gt; &lt;/FONT&gt;&lt;FONT color=#008080 size=2&gt;DateTime&lt;/FONT&gt;&lt;FONT size=2&gt;(unixTime * 10000000);&lt;/P&gt;
&lt;P&gt;time = time.AddYears(1969);&lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;return&lt;/FONT&gt;&lt;FONT size=2&gt; time;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;The DateTime constructor takes the number of 100 nanosecond ticks since January 1, 0001, so multiplying by 10000000 translates seconds into 100 nanosecond intervals.&amp;nbsp; But the Unix era begins in 1970 and DateTime in 1, so to translate that we add 1969 years.&lt;/P&gt;&lt;/FONT&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2610297" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Coming soon...</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2007/05/13/coming-soon.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2007/05/13/coming-soon.aspx</id><published>2007-05-14T01:14:00Z</published><updated>2007-05-14T01:14:00Z</updated><content type="html">I have done much posting in more or less forever, but I have some new stuff on deck.&amp;nbsp; In the meantime, check out the recent posts at&amp;nbsp;&lt;A class="" href="http://hyperthink.net/blog/" mce_href="http://hyperthink.net/blog/"&gt;Steve Maine's&lt;/A&gt; blog for some of the stuff I've been working on.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2609864" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>WCF Interop Community</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2007/02/19/wcf-interop-community.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2007/02/19/wcf-interop-community.aspx</id><published>2007-02-19T23:45:00Z</published><updated>2007-02-19T23:45:00Z</updated><content type="html">&lt;P&gt;There's no original content in this post, but here's what people are saying about WCF and ASMX interoperability in the Microsoft forums and other blogs over the last month or so:&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;ASMX&lt;?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /&gt;&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1131814&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;WCF method returning a strongly typed collection to a .NET 2.0 client&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1125700&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;Trouble getting a WCF return a collection to a .NET 2.0 client&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1121986&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;Issues with generating .net 2.0 client for consuming a WCF service&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1131814&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;WCF method returning a strongly typed collection to a .NET 2.0 client&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1162031&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;Making an asynchronous call from a .Net 2.0 client(asmx) to a WCF method&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Java&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1087496&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;netTcpBinding and Java Web Services&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1142719&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;WCF and Java WS client&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1154389&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;WCF bug in message deserialization?&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1189342&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;Interop problem: WCF service &amp;amp; Java client &lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1122326&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;.NET/Java double-dimensional (jagged) array interop&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1180486&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;Custom Binding requires a Timestamp &lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1136446&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;Accessing : &amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Other&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://blogs.msdn.com/netcfteam/archive/2007/02/01/why-your-netcf-apps-fail-to-call-some-web-services.aspx"&gt;&lt;FONT face=Calibri size=3&gt;Why your NetCF apps fail to call some web services&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Security&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1179866&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;How to Create a SAML token parsing the SOAP / RSTR Response&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1171462&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;WS Security interoperability between Java and .NET web services(Urgent)&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Sun&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://blogs.tedneward.com/2007/01/18/Interop+Briefs+Begin+At+The+Beginning.aspx"&gt;&lt;FONT face=Calibri size=3&gt;Interop Briefs: Begin at the Beginning... &lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://blogs.sun.com/arungupta/entry/new_wsit_plug_in_coming"&gt;&lt;FONT face=Calibri size=3&gt;New WSIT Plug-in coming&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://blogs.sun.com/arungupta/entry/sun_understands_ws_very_well"&gt;&lt;FONT face=Calibri size=3&gt;Sun understands WS-* very well!!!&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://www.tbray.org/ongoing/When/200x/2007/02/04/WS-Microsoft"&gt;&lt;FONT face=Calibri size=3&gt;SOA and WCF&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://blogs.sun.com/racingsnake/entry/can_sun_do_ws"&gt;&lt;FONT face=Calibri size=3&gt;Can Sun do WS-*?&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;o:p&gt;&lt;FONT face=Calibri size=3&gt;&amp;nbsp;&lt;/FONT&gt;&lt;/o:p&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;B&gt;&lt;FONT size=3&gt;&lt;FONT face=Calibri&gt;Web Clients&lt;o:p&gt;&lt;/o:p&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/B&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1091108&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;Connecting to WCF from Javascript\XMLHTTP&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1129123&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;calling a webservice from classic asp - what are the limitations?&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P class=MsoNormal style="MARGIN: 0in 0in 0pt"&gt;&lt;A href="http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=1098525&amp;amp;SiteID=1"&gt;&lt;FONT face=Calibri size=3&gt;SOAP Services and XML&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1718551" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>.Net Framework 3.0 is live</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2006/11/07/net-framework-3-0-is-live.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2006/11/07/net-framework-3-0-is-live.aspx</id><published>2006-11-08T01:56:00Z</published><updated>2006-11-08T01:56:00Z</updated><content type="html">&lt;P&gt;WCF and the other goodies are available for download here:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=10CC340B-F857-4A14-83F5-25634C3BF043&amp;amp;displaylang=en"&gt;http://www.microsoft.com/downloads/details.aspx?FamilyId=10CC340B-F857-4A14-83F5-25634C3BF043&amp;amp;displaylang=en&lt;/A&gt;&lt;/P&gt;
&lt;P mce_keep="true"&gt;&amp;nbsp;&lt;/P&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=1024719" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>WCF and eBay</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2006/10/12/wcf-and-ebay.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2006/10/12/wcf-and-ebay.aspx</id><published>2006-10-12T19:20:00Z</published><updated>2006-10-12T19:20:00Z</updated><content type="html">&lt;P&gt;eBay provides a very rich, though very complicated, &lt;A class="" href="http://developer.ebay.com/developercenter/soap" mce_href="http://developer.ebay.com/developercenter/soap"&gt;SOAP API&lt;/A&gt;.&amp;nbsp; It is possible to use WCF with eBay, but it takes a few tricks.&amp;nbsp; First read &lt;A class="" href="http://pluralsight.com/blogs/aaron/archive/2006/04/18/21943.aspx" mce_href="http://pluralsight.com/blogs/aaron/archive/2006/04/18/21943.aspx"&gt;this&lt;/A&gt; article.&amp;nbsp; I'll wait.&amp;nbsp; Ok, since that didn't scare you away I'll continue.&amp;nbsp; Everything there is still necessary except the custom message encoder for removing the quotes around the content type.&amp;nbsp; In fact the basicHttpBinding produced by svcutil.exe is just fine, though bumping up some of the quotas (&lt;FONT size=2&gt;maxNameTableCharCount, &lt;FONT size=2&gt;maxBufferSize, &lt;FONT size=2&gt;maxReceivedMessageSize)&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&amp;nbsp;might not hurt.&amp;nbsp; Now calling GeteBayOfficialTime just works, but graduating to say GetItem, there's another problem.&amp;nbsp; GetItem returns a GetItemResponseType which derives from AbstractResponseType.&amp;nbsp; After successfully calling GetItemResponseType, all the fields it inherits are correctly populated but the fields it defines haven't been.&amp;nbsp; Looking at the response on the wire, those fields are there, for some reason they weren't deserialized.&amp;nbsp; The problem is eBay defined the schema for AbstractResponseType with an xs:any, so the code generated for this type includes an array of XmlElements with the XmlAny attribute:&lt;/P&gt;&lt;FONT size=2&gt;
&lt;P&gt;[System.Xml.Serialization.XmlAnyAttribute(Order=12)] &lt;/P&gt;
&lt;P&gt;&lt;/FONT&gt;&lt;FONT color=#0000ff size=2&gt;public&lt;/FONT&gt;&lt;FONT size=2&gt; System.Xml.XmlElement[] Any&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT size=2&gt;When the response from eBay arrives the XmlSerializer happily begins populating all the fields in AbstractResponseType and anything it doesn't recognize gets put into Any.&amp;nbsp; Now when it's time to populate the fields defined in GetItemResponseType there's no xml left.&amp;nbsp; Given this knowledge it's an easy fix, but unfortunately it involves manually editing the generated proxy.&amp;nbsp; All that's necessary is to change the XmlAnyAttribute to an XmlIgnoreAttribute.&amp;nbsp; Now upon receiving the response, the XmlSerializer "saves" any elements that don't map to AbstractResponseType and uses them to populate GetItemResponseType.&lt;/P&gt;&lt;/FONT&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=820210" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Useful "knobs" for WCF &lt;-&gt; WSE interop</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2006/05/19/602127.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2006/05/19/602127.aspx</id><published>2006-05-19T21:45:00Z</published><updated>2006-05-19T21:45:00Z</updated><content type="html">&lt;DIV&gt;Let's take&amp;nbsp;the scenario of a WCF client and a WSE service using MTOM&amp;nbsp;either with or without&amp;nbsp;security, here's some of the settings that help make this possible.&amp;nbsp; I'm going&amp;nbsp;to focus mostly&amp;nbsp;on code, but almost all or all of these are available via config.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;First off, the proxy created for WCF will be missing pretty much all of the necessary configuration that would be present if this was a WCF service.&amp;nbsp; This is because WSE doesn't support WS-Policy so the wsdl it generates doesn't say it uses MTOM and a specific security policy like a WCF wsdl.&amp;nbsp; WCF will generate 2 bindings for a WSE service, a BasicHttpBinding for SOAP 1.1 and a custom binding for SOAP 1.2.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Without security, it's easiest to just modify the generated bindings.&amp;nbsp; For SOAP 1.1 just changed messageEncoding from "Text" to "Mtom".&amp;nbsp; For SOAP 1.2 replace the textMessageEncoding element with an mtomMessageEncoding element.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;In code, SOAP 1.1 is just as easy:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#a52a2a&gt;binding.MessageEncoding = WSMessageEncoding.Mtom;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;For SOAP 1.2, it's still conceptually simple but more code is required.&amp;nbsp; The easiest approach is to search through the Elements collection on the binding for an element of type TextMessageEncodingBindingElement, and then replace it in the collection with an MtomMessageEncodingBindingElement.&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Turning security on adds a couple more twists.&amp;nbsp; The first one is WSE only supports WS-Addressing headers in the 8/2004 namespace but the default for WCF is 8/2005.&amp;nbsp; Next to do signing only, for example, the setting for this isn't on the binding it's on the contract description of the proxy's endpoint, so the code would look like this:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#a52a2a&gt;proxy.Endpoint.Contract.ProtectionLevel = System.Net.Security.ProtectionLevel.Sign;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;For the security case it's probably best to just start from scratch.&amp;nbsp; Here's some code:&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#a52a2a&gt;Binding GetNewBindingForSecurity(MessageVersion messageVersion)&lt;BR&gt;{&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#a52a2a&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp; // Create and configure&amp;nbsp;security for binding&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#a52a2a&gt;&lt;FONT color=#008000&gt;&lt;FONT color=#a52a2a&gt;&amp;nbsp;&amp;nbsp; MessageSecurityVersion securityVersion =&lt;/FONT&gt; &lt;/FONT&gt;&lt;FONT color=#a52a2a&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#a52a2a&gt;&lt;FONT color=#a52a2a&gt;MessageSecurityVersion.WSSecurity10WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp; SecurityBindingElement securityBE&amp;nbsp;=&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#a52a2a&gt;&amp;nbsp;&amp;nbsp;SecurityBindingElement.CreateMutualCertificateBindingElement(securityVersion, true);&lt;BR&gt;&amp;nbsp;&amp;nbsp; securityBE.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Default;&lt;BR&gt;&amp;nbsp;&amp;nbsp; securityBE.IncludeTimestamp = true;&lt;BR&gt;&amp;nbsp;&amp;nbsp; securityBE.MessageSecurityVersion = securityVersion;&lt;BR&gt;&amp;nbsp;&amp;nbsp; securityBE.SetKeyDerivation(false);&lt;BR&gt;&amp;nbsp;&amp;nbsp; securityBE.SecurityHeaderLayout = SecurityHeaderLayout.Lax;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#a52a2a&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#a52a2a&gt;&amp;nbsp;&amp;nbsp; AsymmetricSecurityBindingElement asymmetricSecurityBE = &lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#a52a2a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;securityBE as AsymmetricSecurityBindingElement;&lt;BR&gt;&amp;nbsp;&amp;nbsp; if (asymmetricSecurityBE != null)&lt;BR&gt;&amp;nbsp;&amp;nbsp; {&lt;BR&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; asymmetricSecurityBE.MessageProtectionOrder = &lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#a52a2a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;MessageProtectionOrder.SignBeforeEncrypt;&lt;BR&gt;&amp;nbsp;&amp;nbsp; }&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#a52a2a&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp; // Create and configure encoding element&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#a52a2a&gt;&amp;nbsp;&amp;nbsp; MtomMessageEncodingBindingElement encodingBE = new MtomMessageEncodingBindingElement();&lt;BR&gt;&amp;nbsp;&amp;nbsp; &lt;FONT color=#008000&gt;//messageVersion is either MessageVersion.Soap11WSAddressingAugust2004 or MessageVersion.Soap12WSAddressingAugust2004 to interop with WSE&lt;/FONT&gt;&lt;BR&gt;&amp;nbsp;&amp;nbsp; encodingBE.MessageVersion = messageVersion;&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#a52a2a&gt;&lt;/FONT&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#008000&gt;&amp;nbsp;&amp;nbsp; // Create and configure transport element&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;FONT color=#a52a2a&gt;&amp;nbsp;&amp;nbsp; HttpTransportBindingElement transportBE = new HttpTransportBindingElement();&lt;BR&gt;&amp;nbsp;&amp;nbsp; transportBE.MaxReceivedMessageSize = Int32.MaxValue;&lt;BR&gt;&amp;nbsp;&amp;nbsp; return new CustomBinding(securityBE, textBE, transportBE);&lt;BR&gt;}&lt;/FONT&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Three things are happening here.&amp;nbsp; Security is configured (MutualCertificate in this case but it could be any of the &lt;A href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wse3.0/html/0246eb35-4599-4fec-beea-af0419fe8926.asp"&gt;WSE turnkey security assertions&lt;/A&gt;) with the proper settings.&amp;nbsp; Mtom is configured with the proper message version, note the two values that will interop correctly.&amp;nbsp; Finally a transport is selected.&amp;nbsp; This could also be https, but then why are you using message level security, or possibly &lt;A href="http://windowscommunication.net/ControlGallery/ControlDetail.aspx?Control=2247&amp;amp;tabindex=2"&gt;TCP&lt;/A&gt;.&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=602127" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>WSE Quick Links</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2006/02/22/537295.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2006/02/22/537295.aspx</id><published>2006-02-23T00:06:00Z</published><updated>2006-02-23T00:06:00Z</updated><content type="html">&lt;UL&gt;
&lt;LI&gt;If you haven't seen it,&amp;nbsp;&lt;A href="http://weblogs.asp.net/cibrax/"&gt;Pablo Cibraro&lt;/A&gt;&amp;nbsp;has a lot of&amp;nbsp;informative posts about WSE (and WCF).&amp;nbsp; These include implementations of &lt;A href="http://weblogs.asp.net/cibrax/archive/2006/02/02/437180.aspx"&gt;WS-Federation&lt;/A&gt;&amp;nbsp;and &lt;A href="http://weblogs.asp.net/cibrax/archive/2006/01/24/436334.aspx"&gt;WS-Polling&lt;/A&gt;&amp;nbsp;among a great number of others, just keep scrolling.&lt;/LI&gt;
&lt;LI&gt;Julie Lerman points out the &lt;A href="http://www.thedatafarm.com/blog/PermaLink.aspx?guid=3768a11b-4369-45de-8f6a-19f161de66b5"&gt;number #1 cause&lt;/A&gt;&amp;nbsp;of performance degradation with WSE:&amp;nbsp; tracing has been on for a while and the trace files have gotten huge.&amp;nbsp; This is always the first thing to check when WSE's performance has become sluggish.&amp;nbsp; Be careful with Tip #2 though, particularly on the server side.&amp;nbsp; ASP.NET explicitly forbids serving the default extensions for trace (.webinfo) and policy (.config) files, changing the extensions to .xml could lead to accidental information disclosure.&amp;nbsp; &lt;/LI&gt;&lt;/UL&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=537295" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>WinFX February CTP available</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2006/02/22/537062.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2006/02/22/537062.aspx</id><published>2006-02-22T20:43:00Z</published><updated>2006-02-22T20:43:00Z</updated><content type="html">The &lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=F51C4D96-9AEA-474F-86D3-172BFA3B828B&amp;amp;displaylang=en"&gt;February CTP&lt;/A&gt; for WinFX is now available for download.&amp;nbsp; Breaking changes are &lt;A HREF="/edpinto/archive/2006/02/22/537027.aspx"&gt;here&lt;/A&gt;.&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=537062" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>Quick Links</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2006/02/01/522584.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2006/02/01/522584.aspx</id><published>2006-02-02T01:51:00Z</published><updated>2006-02-02T01:51:00Z</updated><content type="html">&lt;ul&gt;
&lt;li&gt;Aaron Skonnard has a new &lt;a href="http://msdn.microsoft.com/msdnmag/issues/06/01/ServiceStation/default.aspx"&gt;Service Station&lt;/a&gt;&amp;nbsp;column all about the new web services features in .NET 2.0 (ASMX 2.0 and WSE 3.0) and how they fit with the impending release of WCF. 
&lt;/li&gt;&lt;li&gt;Kirk Evans has a great &lt;a href="/kaevans/archive/2006/01/29/518999.aspx"&gt;post&lt;/a&gt; about using WSE 3.0's policy framework to get WSE 1.0 to talk to WSE 3.0.
&lt;/li&gt;&lt;li&gt;Another &lt;a href="http://groups.yahoo.com/group/WS-Builders/message/56"&gt;WCF Interop Plugfest&lt;/a&gt; is coming up March 7-9.&lt;/li&gt;&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=522584" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry><entry><title>So you want to move a lot of data</title><link rel="alternate" type="text/html" href="http://blogs.msdn.com/b/nathana/archive/2006/01/24/516925.aspx" /><id>http://blogs.msdn.com/b/nathana/archive/2006/01/24/516925.aspx</id><published>2006-01-24T21:02:00Z</published><updated>2006-01-24T21:02:00Z</updated><content type="html">&lt;DIV&gt;Yasser Shohoud has a &lt;a href="http://blogs.msdn.com/yassers/archive/2006/01/21/515887.aspx"&gt;great post &lt;/A&gt;up about moving large amounts of data with WCF.&amp;nbsp;&amp;nbsp;The solutions are&amp;nbsp;WCF-specific but the discussion&amp;nbsp;of the problems (bandwidth utilization, memory utilization, and error recovery) is general to any system using web services to transfer big chunks of data.&lt;/DIV&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=516925" width="1" height="1"&gt;</content><author><name>nathana_work@hotmail.com</name><uri>http://blogs.msdn.com/nathana_5F00_work_4000_hotmail.com/ProfileUrlRedirect.ashx</uri></author></entry></feed>