<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.2.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>kennyw.com &#187; Indigo</title>
	<link>http://kennyw.com</link>
	<description>Kenny Wolf's Thoughts of the Moment</description>
	<pubDate>Tue, 01 Jul 2008 17:44:43 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.2</generator>
	<language>en</language>
			<item>
		<title>WF/WCF July MSDN Webcasts</title>
		<link>http://kennyw.com/indigo/284</link>
		<comments>http://kennyw.com/indigo/284#comments</comments>
		<pubDate>Tue, 01 Jul 2008 17:44:43 +0000</pubDate>
		<dc:creator>Kenny</dc:creator>
		
		<category><![CDATA[Indigo]]></category>

		<guid isPermaLink="false">http://kennyw.com/indigo/284</guid>
		<description><![CDATA[Starting last month, MSDN put together a regular series of webcasts on WCF and WF (focusing on .Net 3.5).&#160; Here are the talks being broadcast in July:
July 7th, 10:00AM (PST)      Transactional Windows Communication Foundation Services with Juval Lowy
July 9th, 10:00AM (PST)      Using Windows Workflow Foundation [...]]]></description>
			<content:encoded><![CDATA[<p>Starting last month, MSDN put together a regular series of webcasts on WCF and WF (focusing on .Net 3.5).&#160; Here are the talks being broadcast in July:</p>
<p><strong>July 7th, 10:00AM (PST)      <br /></strong><a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032381606&amp;Culture=en-US">Transactional Windows Communication Foundation Services with Juval Lowy</a></p>
<p><strong>July 9th, 10:00AM (PST)      <br /></strong><a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032381608&amp;Culture=en-US">Using Windows Workflow Foundation to Build Services with Jon Flanders</a></p>
<p><strong>July 11th, 10:00AM (PST)      <br /></strong><a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032381610&amp;Culture=en-US">WCF Extensibility Deep Dive with Jesus Rodriguez</a></p>
<p><strong>July 18th, 10:00AM (PST)      <br /></strong><a href="http://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032381674&amp;Culture=en-US">SharePoint Server and WCF with Joe Klug</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kennyw.com/indigo/284/feed</wfw:commentRss>
		</item>
		<item>
		<title>WsDualHttp and Faults</title>
		<link>http://kennyw.com/indigo/268</link>
		<comments>http://kennyw.com/indigo/268#comments</comments>
		<pubDate>Tue, 06 May 2008 21:45:19 +0000</pubDate>
		<dc:creator>Kenny</dc:creator>
		
		<category><![CDATA[Indigo]]></category>

		<guid isPermaLink="false">http://kennyw.com/general/268</guid>
		<description><![CDATA[The other day a customer was sending unauthenticated messages to a service and the requests were timing out over WsDualHttp. When using WsHttpBinding or NetTcpBinding, the customer received an authentication MessageFault.&#160; Why was there no Fault returned over WsDualHttpBinding?
The reason has to do with securing composite-duplex channels. WsDualHttp uses two HTTP connections to provide its [...]]]></description>
			<content:encoded><![CDATA[<p>The other day a customer was sending unauthenticated messages to a service and the requests were timing out over WsDualHttp. When using WsHttpBinding or NetTcpBinding, the customer received an authentication MessageFault.&#160; Why was there no Fault returned over WsDualHttpBinding?</p>
<p>The reason has to do with securing composite-duplex channels. WsDualHttp uses two HTTP connections to provide its duplex nature, and messages are correlated between these two connections based on WS-Addressing (ReplyTo/MessageId).&#160; Because of this, the server behavior is entirely dependent on data received from the client. If this client is malicious, then he can cause the server to do a couple of things:</p>
<ul>
<li>Initiate arbitrary outbound connections</li>
<li>Cause a &quot;bouncing DOS&quot; attack. For example, consider a server A that can send messages to server B that&#8217;s behind a firewall. Suppose that client C can send messages to A, but cannot send messages directly to server B (due to the firewall). Now suppose that the client sends a badly secured message to server A, with a ReplyTo equal to server B. If we send back a fault for unsecured messages over WsDualHttp, this would result in C being able to DOS server B due to bounce-assistance from server A.</li>
</ul>
<p>In addition, since these are two one-way channels, the HTTP response (202 Accepted) has already returned prior to the Security channel (or any higher-layer in the channel/dispatcher stack) being called. So we cannot simply piggy-back the fault over the HTTP back channel.</p>
]]></content:encoded>
			<wfw:commentRss>http://kennyw.com/indigo/268/feed</wfw:commentRss>
		</item>
		<item>
		<title>WCF and TIBCO</title>
		<link>http://kennyw.com/indigo/260</link>
		<comments>http://kennyw.com/indigo/260#comments</comments>
		<pubDate>Thu, 01 May 2008 01:04:18 +0000</pubDate>
		<dc:creator>Kenny</dc:creator>
		
		<category><![CDATA[Indigo]]></category>

		<guid isPermaLink="false">http://kennyw.com/indigo/260</guid>
		<description><![CDATA[Integration has arrived!
http://www.tibco.com/company/news/releases/2008/press900.jsp
]]></description>
			<content:encoded><![CDATA[<p>Integration has arrived!</p>
<p><a title="http://www.tibco.com/company/news/releases/2008/press900.jsp" href="http://www.tibco.com/company/news/releases/2008/press900.jsp">http://www.tibco.com/company/news/releases/2008/press900.jsp</a></p>
]]></content:encoded>
			<wfw:commentRss>http://kennyw.com/indigo/260/feed</wfw:commentRss>
		</item>
		<item>
		<title>When to use Async Service Operations</title>
		<link>http://kennyw.com/indigo/258</link>
		<comments>http://kennyw.com/indigo/258#comments</comments>
		<pubDate>Wed, 30 Apr 2008 04:07:19 +0000</pubDate>
		<dc:creator>Kenny</dc:creator>
		
		<category><![CDATA[Indigo]]></category>

		<guid isPermaLink="false">http://kennyw.com/indigo/258</guid>
		<description><![CDATA[I was recently asked about the motivation for choosing asynchronous service operations in WCF (i.e. [OperationContract(AsyncPattern = true)]). 
If you have an operation that is blocking (accessing SQL, Channels, etc) then you should use AsyncPattern=true.&#160; That way you&#8217;ll free up whatever thread we&#8217;re using to call your operation from. The general idea is that if [...]]]></description>
			<content:encoded><![CDATA[<p>I was recently asked about the motivation for choosing asynchronous service operations in WCF (i.e. [OperationContract(<a href="http://msdn.microsoft.com/en-us/library/system.servicemodel.operationcontractattribute.asyncpattern.aspx">AsyncPattern</a> = true)]). </p>
<p>If you have an operation that is blocking (accessing SQL, Channels, etc) then you should use AsyncPattern=true.&#160; That way you&#8217;ll free up whatever thread we&#8217;re using to call your operation from. The general idea is that if you have a blocking call then you should use the async version and it should transparently play well with us. </p>
<p>Put another way: if you are calling a method that returns an AsyncResult (i.e. you&#8217;re accessing SQL, or using sockets, files, or channels), then you can wrap that IAsyncResult and return it from the BeginXXX call (or return the raw asyncresult depending on your scenario). </p>
<p>If you aren&#8217;t doing something that&#8217;s &quot;natively async&quot;, then you shouldn&#8217;t be using AsyncPattern=true. That is, you shouldn&#8217;t just create a thread just for the sake of performing &quot;background work&quot; as part of an asynchronous operation. Note that it is legitimate to spawn a thread because your operation happens to kick off work that is outside of its completion scope (though in that case you should just have a synchronous method, not an async one). </p>
]]></content:encoded>
			<wfw:commentRss>http://kennyw.com/indigo/258/feed</wfw:commentRss>
		</item>
		<item>
		<title>Notes on lifetimes of Channels and their Factories</title>
		<link>http://kennyw.com/indigo/234</link>
		<comments>http://kennyw.com/indigo/234#comments</comments>
		<pubDate>Tue, 18 Mar 2008 17:17:21 +0000</pubDate>
		<dc:creator>Kenny</dc:creator>
		
		<category><![CDATA[Indigo]]></category>

		<guid isPermaLink="false">http://kennyw.com/indigo/234</guid>
		<description><![CDATA[One question I get from custom channel authors has to do with the various lifetimes of the components involved. Especially since, as per best practice, their heavyweight resources are attached to ChannelFactories and ChannelListeners and simply referenced from the Channel. Nicholas covered the basics in this post. Which to summarize is:

ChannelFactory created Channels cannot outlive [...]]]></description>
			<content:encoded><![CDATA[<p>One question I get from custom channel authors has to do with the various lifetimes of the components involved. Especially since, as per best practice, their heavyweight resources are attached to ChannelFactories and ChannelListeners and simply referenced from the Channel. Nicholas covered the basics in <a href="http://blogs.msdn.com/drnick/archive/2006/10/25/asymmetry-between-listeners-and-factories.aspx">this post</a>. Which to summarize is:</p>
<ul>
<li><strong>ChannelFactory</strong> created Channels cannot outlive their creator</li>
</ul>
<ul>
<li>channelFactory.Close/Abort will Close/Abort all Channels created by that factory</li>
</ul>
<li><strong>ChannelListener</strong> created Channels can outlive their creator</li>
<ul>
<li>channelListener.Close/Abort simply disables the ability to accept new channels; existing channels can continue to be serviced</li>
</ul>
<p>Which makes life on the ChannelFactory end pretty straightforward.&#160; On the ChannelListener side, there are a few subtleties.&#160; </p>
<p>First, a Channel is owned by the listener from the time of creation until the successful completion of channel.Open.&#160; So if you are writing a custom listener that has offered up channels, you should clean them up if and only if they haven&#8217;t been opened. </p>
<p>Second, in order to perform eager disposal, you will need to track active ownership of your heavyweight resources. If there are opened channels, then you need to make sure that the shared resources that they leverage have their ownership transferred from the listener to your active channel(s). This can be accomplished through ref-counting, active transfers, or other mechanisms.</p>
]]></content:encoded>
			<wfw:commentRss>http://kennyw.com/indigo/234/feed</wfw:commentRss>
		</item>
		<item>
		<title>Pumping in a Layered IInputChannel</title>
		<link>http://kennyw.com/indigo/235</link>
		<comments>http://kennyw.com/indigo/235#comments</comments>
		<pubDate>Tue, 11 Mar 2008 17:17:51 +0000</pubDate>
		<dc:creator>Kenny</dc:creator>
		
		<category><![CDATA[Indigo]]></category>

		<guid isPermaLink="false">http://kennyw.com/indigo/235</guid>
		<description><![CDATA[When writing a layered channel, sometime you want to decouple processing without changing the channel shape. One example would be for layered demux purposes. When layering your IInputChannel on top of a &#34;lower&#34; IInputChannel, you have a few options for lifetime management and pumping that are worth noting:

When your innerInputChannel.Receive call returns &#34;null&#34;, that means [...]]]></description>
			<content:encoded><![CDATA[<p>When writing a layered channel, sometime you want to decouple processing without changing the channel shape. One example would be for layered demux purposes. When layering your IInputChannel on top of a &quot;lower&quot; IInputChannel, you have a few options for lifetime management and pumping that are worth noting:</p>
<ol>
<li>When your innerInputChannel.Receive call returns &quot;null&quot;, that means that no more messages will arrive on that particular channel. You should Close that channel and then Accept a new one. </li>
<li>If the innerListener.AcceptChannel call returns null then your inner listener is completely done providing messages and you need to follow suit when you are through with any added messages that you may have buffered.</li>
<li>If someone calls Close/Abort on your IInputChannel, you have the option of holding onto the inner channel within your listener (and providing a new facade on top when a new channel is accepted). Alternatively, you can close the inner channel and create a new one with your new channel. That choice is entirely at your discretion (and at the mercy of your perf tuning results :))</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://kennyw.com/indigo/235/feed</wfw:commentRss>
		</item>
		<item>
		<title>TcpTransport&#8217;s Buffer Management in WCF</title>
		<link>http://kennyw.com/indigo/229</link>
		<comments>http://kennyw.com/indigo/229#comments</comments>
		<pubDate>Mon, 18 Feb 2008 17:36:10 +0000</pubDate>
		<dc:creator>Kenny</dc:creator>
		
		<category><![CDATA[Indigo]]></category>

		<guid isPermaLink="false">http://kennyw.com/indigo/229</guid>
		<description><![CDATA[I&#8217;ve gotten some questions recently about how our net.tcp transport functions at the memory allocation level. While at its core this is simply an &#8220;implementation detail&#8221;, this information can be very useful for tuning high performance routers and servers depending on your network topology.&#160; 
When writing a service on top of net.tcp, there are a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve gotten some questions recently about how our net.tcp transport functions at the memory allocation level. While at its core this is simply an &#8220;implementation detail&#8221;, this information can be very useful for tuning high performance routers and servers depending on your network topology.&nbsp; </p>
<p>When writing a service on top of net.tcp, there are a few layers where buffer allocations and copies can occur:</p>
<ul>
<li>Buffers passed into socket.Receive()</li>
<li>Buffers created by the Message class (to support Message copying, etc)</li>
<li>Buffers created by the Serialization stack (to convert from Message to/from parameters)</li>
</ul>
<p>In addition, this behavior differs based on your TransferMode (Buffered or Streamed). In general you&#8217;ll find that Buffered mode will provide you the highest performance for &#8220;small messages&#8221; (i.e. &lt; 4MB or so), while Streamed will provide better performance for larger messages (i.e. &gt; 4MB). Usually this switch is combined with a tweak of your <a href="http://kennyw.com/indigo/51">MaxBufferPoolSize</a> in order to avoid memory thrashing.</p>
<p><strong><u>TransferMode.Buffered</u></strong></p>
<p>In Buffered mode, the transport will reuse a fixed-size buffer on its calls to socket.Receive(). The <a href="http://kennyw.com/indigo/49">ConnectionBufferSize</a> setting on TcpTransportBindingElement controls the size of this buffer. </p>
<p>The data read from the wire is incrementally parsed at the .Net Message Framing level, and is copied into a new buffer (allocated by the <a href="http://kennyw.com/indigo/51">BufferManager</a>) that is sized to the length of the message. This step always involves a buffer copy, but rarely involves a new allocation for small messages (since BufferManager will cache and recycle previously used buffers). </p>
<p>The message-sized buffer is then passed to the <a href="http://kennyw.com/indigo/200">MessageEncoder</a> for Message construction.&nbsp;Again, minimal allocations should occur here since we will&nbsp;pool XmlReader/Writer instances&nbsp;where possible. At this point you have a Message that is backed by a fixed-size buffer and we will share that backing buffer for all copies of the Message created through message.CreateBufferedCopy(). </p>
<p>If your contract is Message/Message, then no more deserialization will occur. If you are using <a href="http://kennyw.com/indigo/91">Stream</a> parameters, then the allocations are determined by your code (since you are creating byte[]s to pass to stream.Read), and given the nature of the Stream APIs you will entail a buffer copy as well (since we have to fill the caller buffer with data stored in the callee). </p>
<p>If your contract uses CLR object parameters, then the Serializer will process the Message and generate CLR objects as per your Data Contracts. This step often entails a number of allocations (as you would expect since you are generating a completely new set of constructs). </p>
<p><strong><u>TransferMode.Streamed</u></strong></p>
<p>There are three main differences that occur when you are using TransferMode.Streamed:</p>
<ol>
<li>The transport will use new variable-sized byte[]s in its calls to socket.Receive. These byte[]s are still allocated from the configured BufferManager. The transport will then offer up a scatter/gather-based stream to the MessageEncoder so there are no extra buffer allocations or copies in this case.</li>
<li>The Message created from the Encoder will be a &#8220;Streamed&#8221; message. This means that if you simply Read() from the Message&#8217;s Body in a single-shot then we don&#8217;t allocate any extra memory. However, if you call message.CreateBufferedCopy() we will entail some large allocations since we need to fully buffer at that point. Note that some binding elements (such as ReliableSession and <a href="http://kennyw.com/indigo/151">certain Security configurations</a>) will call CreateBufferedCopy() under the hood and trigger this situation.</li>
<li>Since the backing data may not all be in memory, invoking the Serializer will incur a larger cost since it will be pulling all the data into memory at once (in order to generate the appropriate CLR objects, even if that is simply a byte[]).</li>
</ol>
<p>&nbsp;</p>
<p>As you can see, there is a tension between performance and usability. Hopefully this data will help you make the appropriate tradeoffs.</p>
]]></content:encoded>
			<wfw:commentRss>http://kennyw.com/indigo/229/feed</wfw:commentRss>
		</item>
		<item>
		<title>Controlling HTTP Cookies on a WCF Client</title>
		<link>http://kennyw.com/indigo/211</link>
		<comments>http://kennyw.com/indigo/211#comments</comments>
		<pubDate>Sat, 01 Dec 2007 00:09:13 +0000</pubDate>
		<dc:creator>Kenny</dc:creator>
		
		<category><![CDATA[Indigo]]></category>

		<guid isPermaLink="false">http://kennyw.com/indigo/211</guid>
		<description><![CDATA[A few customers have tried to control their HTTP Cookie headers from a smart client (using a previously cached cookie for example). The common experience has been &#8220;I enabled AllowCookies=true, and added the cookie using HttpRequestMessageProperty.Headers.Add. But somehow my cookie didn&#8217;t get included in my request.&#8221;
This is because &#8220;allowCookies&#8221; is a somewhat unfortunate name. When [...]]]></description>
			<content:encoded><![CDATA[<p>A few customers have tried to control their HTTP Cookie headers from a smart client (using a previously cached cookie for example). The common experience has been &#8220;I enabled AllowCookies=true, and added the cookie using HttpRequestMessageProperty.Headers.Add. But somehow my cookie didn&#8217;t get included in my request.&#8221;</p>
<p>This is because &#8220;allowCookies&#8221; is a somewhat unfortunate name. When setting &#8220;allowCookies=true&#8221; on your HTTP-based binding (WsHttpBinding, BasicHttpBinding, etc), what you are indicating is that you want WCF to manage the cookie headers for you. That means that WCF will create&nbsp;CookieContainer, associate it with any IChannelFactory that is created from the binding, and then use that CookieContainer for all outgoing HttpWebRequests. The end result of this setup is that the user has zero control over his cookies, since the CookieContainer is taking over all management (including echoing server cookies if and only if a cookie was sent in an earlier response to that factory).</p>
<p>To cut a long explanation short, if you want to manipulate cookies on the client, then you (somewhat unintuitively) need to ensure that <strong>allowCookies=false</strong>.&nbsp; In this manner, you are taking full responsibility for all cookies sent on that channel (in all cases, including capturing response cookies and echoing appropriately).</p>
]]></content:encoded>
			<wfw:commentRss>http://kennyw.com/indigo/211/feed</wfw:commentRss>
		</item>
		<item>
		<title>Performance Characteristics of WCF Encoders</title>
		<link>http://kennyw.com/indigo/200</link>
		<comments>http://kennyw.com/indigo/200#comments</comments>
		<pubDate>Fri, 09 Nov 2007 18:12:38 +0000</pubDate>
		<dc:creator>Kenny</dc:creator>
		
		<category><![CDATA[Indigo]]></category>

		<guid isPermaLink="false">http://kennyw.com/indigo/200</guid>
		<description><![CDATA[As part of the Framework, we ship 3 MessageEncoders (accessible through the relevate subclass of MessageEncodingBindingElement):

Text - The &#8220;classic&#8221; web services encoder. Uses a Text-based (UTF-8 by default) XML encoding. This is the&#160;default encoder used by BasicHttpBinding and WsHttpBinding
MTOM&#160;- An interoperable format (though less&#160;broadly supported then text)&#160;that allows for a more optimized transmission of binary [...]]]></description>
			<content:encoded><![CDATA[<p>As part of the Framework, we ship 3 <em>MessageEncoder</em>s (accessible through the relevate subclass of <a href="http://msdn2.microsoft.com/en-us/library/aa738665.aspx">MessageEncodingBindingElement</a>):</p>
<ol>
<li>Text - The &#8220;classic&#8221; web services encoder. Uses a Text-based (UTF-8 by default) XML encoding. This is the&nbsp;default encoder used by BasicHttpBinding and WsHttpBinding</li>
<li>MTOM&nbsp;- An <a href="http://www.w3.org/TR/soap12-mtom/">interoperable format</a> (though less&nbsp;broadly supported then text)&nbsp;that allows for a more optimized transmission of binary blobs, as they don&#8217;t get base64 encoded.</li>
<li>Binary&nbsp;- &nbsp;A WCF-specific format that avoids base64 encoding your binary blobs, and also uses a dictionary-based algorithm to avoid data duplication. Binary supports &#8220;Session Encoders&#8221; that get smarter about data usage over the course of the session (through pattern recognition). This is the default encoder used by NetTcpBinding and NetNamedPipeBinding</li>
</ol>
<p>I often get asked &#8220;which encoder is the fastest?&#8221; (and then &#8220;by how much?&#8221; :)). As always, the first principle of performance is to measure and tune your exact scenarios to determine if this is a bottleneck for you. That being said, here are some notes on the performance characteristics of our built-in Message Encoders.</p>
<p>Broadly speaking, encoders can impact your performance along two axis: size of encoded messages, and CPU load required to generate/consume those encoded messages. </p>
<p>In general, binary has the fastest encoding/decoding speed since it has less to do (usually because there is less data to read/write). This has to do with the dictionary-based optimization characteristics. The speedup is greater over TCP/NamedPipes since the encoder can recognize patterns (and negotiate optimizations) over the course of the session. If both participants are using WCF, then binary is a natural choice for production. (Note that during development, Text may be useful for debugging purposes).</p>
<p>Both binary and MTOM yield much faster processing of binary data (by avoiding the base64 process as well as the associated size bloat). Binary achieves this with inline binary blobs. The MTOM format achieves this through an inline base64 stub that references the binary blob outside of the Infoset. In both cases, the user model is abstracted from this detail and they will &#8220;appear&#8221; inline through the encoder.</p>
<p>If you do not have any binary data involved, MTOM will actually be slower than text since it had the extra overlead of packaging and processing the Message within a MIME document. However, if there is enough binary data in the document then the savings from avoiding base64 encoding can make up for this added overhead. </p>
<p>We spent a lot of engineering effort tuning the performance of our UTF-8 Text encoder, so you will see better performance over UTF-8 then the Unicode variations. And as to whether you should use Text or MTOM for interoperable endpoints, the guidance above should help with gut feel, but please measure your scenarios!</p>
]]></content:encoded>
			<wfw:commentRss>http://kennyw.com/indigo/200/feed</wfw:commentRss>
		</item>
		<item>
		<title>Efficient usage of WCF clients</title>
		<link>http://kennyw.com/indigo/199</link>
		<comments>http://kennyw.com/indigo/199#comments</comments>
		<pubDate>Sun, 28 Oct 2007 22:41:08 +0000</pubDate>
		<dc:creator>Kenny</dc:creator>
		
		<category><![CDATA[Indigo]]></category>

		<guid isPermaLink="false">http://kennyw.com/general/199</guid>
		<description><![CDATA[Wenlong has an excellent writeup of how write a WCF client with an eye towards performance. 
]]></description>
			<content:encoded><![CDATA[<p><a href="http://blogs.msdn.com/wenlong/">Wenlong</a> has an <a href="http://blogs.msdn.com/wenlong/archive/2007/10/27/performance-improvement-of-wcf-client-proxy-creation-and-best-practices.aspx">excellent writeup</a> of how write a WCF client with an eye towards performance. </p>
]]></content:encoded>
			<wfw:commentRss>http://kennyw.com/indigo/199/feed</wfw:commentRss>
		</item>
	</channel>
</rss>
