<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://blogs.msdn.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Matt W's Windows Workflow Place : WCF</title><link>http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx</link><description>Tags: WCF</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>WF4, WCF and AppFabric Sessions @ PDC09</title><link>http://blogs.msdn.com/mwinkle/archive/2009/11/23/wf4-wcf-and-appfabric-pdc09.aspx</link><pubDate>Mon, 23 Nov 2009 23:16:44 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:9927614</guid><dc:creator>mwinkle</dc:creator><slash:comments>0</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/9927614.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=9927614</wfw:commentRss><description>&lt;p&gt;I’m taking this week off to catch up on everything I haven’t done the last two months and to celebrate the &lt;a href="http://en.wikipedia.org/wiki/Thanksgiving"&gt;Thanksgiving holiday&lt;/a&gt; here in the US. &lt;/p&gt;  &lt;p&gt;PDC was a blast!&amp;#160; It was incredibly awesome to meet so many folks interested in WF and talking with others about how they are using (or plan to use) WF4.&amp;#160; I’ll be following up with a more detailed post on my talk, including demos and code, but I wanted to give a summary of the talks that came from my team at this PDC.&amp;#160; Below is the diagram that breaks down some of the “capabilities” of AppFabric and I have color coded them for the various talks that we gave.&amp;#160; All of the PDC Sessions are available online &lt;a href="http://microsoftpdc.com/Videos"&gt;here&lt;/a&gt;.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4WCFandAppFabricPDC09_D6DC/image_2.png"&gt;&lt;img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WF4WCFandAppFabricPDC09_D6DC/image_thumb.png" width="592" height="309" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;h2&gt;WF Talks&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/FT17"&gt;Spice Up Your Applications with Windows Workflow Foundation 4&lt;/a&gt; – Matt Winkler&lt;/li&gt;    &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/P09-22"&gt;Windows Workflow Foundation 4 from the Inside Out&lt;/a&gt; – Bob Schmidt&lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;WCF Talks&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/FT13"&gt;What’s New for Windows Communication Foundation 4&lt;/a&gt; – Ed Pinto&lt;/li&gt;    &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/FT55"&gt;Developing REST Applications with the .NET Framework&lt;/a&gt; – Henrik Nielsen &lt;/li&gt; &lt;/ul&gt;  &lt;h2&gt;AppFabric Talks&lt;/h2&gt;  &lt;ul&gt;   &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/FT25"&gt;Microsoft Application Server Technologies: Present and Future&lt;/a&gt; – Anil Nori &lt;/li&gt;    &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/SVR15"&gt;Microsoft BizTalk Server Futures and Roadmap&lt;/a&gt; –&amp;#160; Balasubramanian Sriram &lt;/li&gt;    &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/FT14"&gt;Workflow Services and Windows Server AppFabric&lt;/a&gt; – Mark Fussell&lt;/li&gt;    &lt;li&gt;&lt;a href="http://microsoftpdc.com/Sessions/FT27"&gt;Application Server Extensibility with Microsoft .NET 4 and Windows Server AppFabric&lt;/a&gt; – Nicholas Allen&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;There’s a ton of great content up at the PDC site, plenty to sit back and enjoy!&amp;#160; &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=9927614" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf4/default.aspx">wf4</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/pdc09/default.aspx">pdc09</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/AppFabric/default.aspx">AppFabric</category></item><item><title>Which WF/WCF Talks Should You Attend at PDC?</title><link>http://blogs.msdn.com/mwinkle/archive/2008/10/03/which-wf-wcf-talks-should-you-attend-at-pdc.aspx</link><pubDate>Fri, 03 Oct 2008 02:19:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8974616</guid><dc:creator>mwinkle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/8974616.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=8974616</wfw:commentRss><description>&lt;p&gt;Just got the email the other day that PDC is less than 4 weeks away, and it got me thinking a bit about how I would think about these sessions as an attendee.&amp;#160; Searching on the &lt;a href="https://sessions.microsoftpdc.com/public/sessions.aspx"&gt;PDC site&lt;/a&gt; will yield 8 talks tagged with WF.&amp;#160;&amp;#160; Here's how I break some of these these down, the first few are about using WF, and the last 3 are about WF itself:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;a href="http://channel9.msdn.com/pdc2008/BB18/"&gt;Hosting Workflows and Services&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;Dan Eshner&lt;/p&gt;    &lt;p&gt;Hear about extensions being made to Windows Server to provide a feature-rich middle-tier execution and deployment environment for Windows Workflow Foundation (WF) and Windows Communication Foundation (WCF) applications. Learn about the architecture of this new extension, how it works, how to take advantage of it, and the features it provides that simplify deployment, management, and troubleshooting of workflows and services.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;This talk is all about the host we're building for WF and WCF, which I mentioned earlier, we're calling &amp;quot;Dublin&amp;quot;.&amp;#160; If you're familiar with either technology, and have built a host of your own, this will be interesting both from the perspective of what is coming, as well as how we are thinking about solving some of the hosting problems.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;strong&gt;&lt;em&gt;&lt;a href="http://channel9.msdn.com/pdc2008/TL23/"&gt;A Lap around &amp;quot;Oslo&amp;quot;&lt;/a&gt;&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;    &lt;p&gt;Presenters: &lt;a href="http://www.douglasp.com"&gt;Douglas Purdy&lt;/a&gt;, Vijaye Raji&lt;/p&gt;    &lt;p&gt;&amp;quot;Oslo&amp;quot; is the family of new technologies that enable data-driven development and execution of services and applications. Come and learn how to capture all aspects of an application schematized in the &amp;quot;Oslo&amp;quot; repository and use &amp;quot;Oslo&amp;quot; directly to drive the execution of deployed applications.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Building declarative or data driven apps is a &amp;quot;thing&amp;quot; in the Oslo world.&amp;#160; This talk will give the big picture of all of the various pieces of Oslo, and how existing declarative technologies, like WF and WCF fit into it.&amp;#160; Note, this talk is not primarily about WF or WCF, rather it is about Oslo, which you can read about in more detail here and here.&lt;/p&gt;  &lt;p&gt;What about all of the things we are doing to WCF and WF in .NET 4?&amp;#160; That's the remaining three talks:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;&lt;a href="http://channel9.msdn.com/pdc2008/TL17/"&gt;&lt;strong&gt;Windows Workflow Foundation 4.0: A First Look&lt;/strong&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;Presenter: &lt;a href="http://www.kennyw.com"&gt;Kenny Wolf&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;Programs coordinate work. The code for coordination and state management often obscures a program's purpose. Learn how programming with Windows Workflow Foundation (WF) 4.0 provides clarity of intent while preserving the functional richness of the .NET framework. See how easy it is to build workflows with the new Visual Studio workflow designer. Learn about text-based authoring options for WF. Hear how WF integrates well with other Microsoft technologies (WCF, WPF, ASP.NET). If you've looked at WF before, come and see the changes to data flow, composition, and new control flow styles. Significant improvements to usability, composability, and performance make Workflow a great fit for a broad range of solutions on both the client and the server.&lt;/p&gt;    &lt;p&gt;&lt;em&gt;&lt;a href="http://channel9.msdn.com/pdc2008/TL21/"&gt;&lt;strong&gt;Windows Workflow Foundation 4.0: Extending with Custom Activities&lt;/strong&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;Presenter: &lt;a href="http://blogs.msdn.com/mwinkle"&gt;Matt Winkler&lt;/a&gt;&lt;/p&gt;    &lt;p&gt;Windows Workflow Foundation (WF) coordinates and manages individual units of work, encapsulated into activities. WF comes with a rich library of activities. Learn how to extend this library by encapsulating your own APIs with custom activities. See how to compose those basic activities into higher level units using rules, flowchart, and state machine control flow styles. Learn how to build your own WF control styles. Learn how to customize and re-host the workflow authoring experience using the new WF designer framework.&lt;/p&gt;    &lt;p&gt;&lt;em&gt;&lt;a href="http://channel9.msdn.com/pdc2008/TL06/"&gt;&lt;strong&gt;Windows Communication Foundation 4.0: Building WCF Services with Windows Workflow Foundation in Microsoft .NET 4.0&lt;/strong&gt;&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;Presenter: Ed Pinto&lt;/p&gt;    &lt;p&gt;Eliminate the tradeoff between ease of service authoring and performant, scalable services. Hear about significant enhancements in WCF and WF to deal with the ever increasing complexity of communication. Learn how to use WCF to correlate messages to service instances using transport, context, and application payloads. See how the new WF messaging activities enable the modeling of rich protocols. Learn how WCF provides a default host for workflows exposing features such as distributed compensation and discovery. See how service definition in XAML completes the union of WF and WCF with a unified authoring experience that simplifies configuration and is fully integrated with IIS activation and deployment.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Kenny's talk will be an introduction to all of the new features in WF.&amp;#160; If you haven't used WF, or if you looked at WF before and decided it wasn't right for your solution, come to this talk to see how WF makes writing programs easier.&amp;#160; If you are using WF today, and want to see what has changed, this will be a good talk for you.&lt;/p&gt;  &lt;p&gt;My talk will be a very hands on, write some code, style talk focused on building activities and all of the aspects of WF that impact activity development.&amp;#160; If you are using WF today, and want to see what the changes mean for the code you'll write, this is the talk for you.&amp;#160; Also, if you attend Kenny's talk and think, &amp;quot;hey, I want to learn more&amp;quot; this will also be the talk for you.&amp;#160; My talk won't focus on the &amp;quot;why&amp;quot; or the &amp;quot;where&amp;quot; of workflow, but more the &amp;quot;how to build&amp;quot; parts.&lt;/p&gt;  &lt;p&gt;Finally, Ed's talk is &lt;strong&gt;&lt;em&gt;the&lt;/em&gt;&lt;/strong&gt; talk to go to if you are a WCF&amp;#160; developer. If you are building programs that consume services, where service is very loosely defined integrating external information into your app, you should also make sure to go to this talk.&amp;#160; This talk will highlight a number of the enhancements that have been made both to WCF and to the integration between WF and WCF.&amp;#160; We believe very strongly that WF and WCF are tremendously complementary technologies. &lt;/p&gt;  &lt;p&gt;To help, I've put together the following decision table to help you decide.&amp;#160; There are three possible actions, &amp;quot;Must Attend&amp;quot; &amp;quot;Should attend&amp;quot; and &amp;quot;Would Enjoy&amp;quot;.&amp;#160; I think they are fairly explanatory actions, but if you have questions, let me know.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;table style="width: 400pt; border-collapse: collapse" cellspacing="0" cellpadding="0" width="863" border="0"&gt;&lt;colgroup&gt;&lt;col style="width: 233pt; mso-width-source: userset; mso-width-alt: 11373" width="311" /&gt;&lt;col style="width: 130pt; mso-width-source: userset; mso-width-alt: 6326" width="173" /&gt;&lt;col style="width: 159pt; mso-width-source: userset; mso-width-alt: 7753" width="212" /&gt;&lt;col style="width: 204pt; mso-width-source: userset; mso-width-alt: 9947" width="272" /&gt;&lt;/colgroup&gt;&lt;tbody&gt;     &lt;tr style="height: 15pt" height="20"&gt;       &lt;td style="border-right: #fac090 0.5pt solid; border-top: #fac090 0.5pt solid; font-weight: 700; font-size: 11pt; background: #fde9d9; border-left: #fac090 0.5pt solid; width: 233pt; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; height: 15pt; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="310" height="20"&gt;&amp;#160;&lt;/td&gt;        &lt;td class="xl66" style="border-right: #fac090 0.5pt solid; border-top: #fac090 0.5pt solid; font-weight: 700; font-size: 11pt; background: #fde9d9; border-left: medium none; width: 130pt; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="173"&gt;Kenny's talk: A First look&lt;/td&gt;        &lt;td class="xl66" style="border-right: #fac090 0.5pt solid; border-top: #fac090 0.5pt solid; font-weight: 700; font-size: 11pt; background: #fde9d9; border-left: medium none; width: 159pt; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="212"&gt;Matt's Talk : Building Activities&lt;/td&gt;        &lt;td class="xl66" style="border-right: #fac090 0.5pt solid; border-top: #fac090 0.5pt solid; font-weight: 700; font-size: 11pt; background: #fde9d9; border-left: medium none; width: 204pt; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="166"&gt;Ed's talk: Building WCF Services with WF&lt;/td&gt;     &lt;/tr&gt;      &lt;tr style="height: 15pt" height="20"&gt;       &lt;td class="xl66" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 700; font-size: 11pt; background: #fcd5b4; border-left: #fac090 0.5pt solid; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; height: 15pt; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="310" height="20"&gt;Building WF today&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fcd5b4; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="173"&gt;Must attend&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fcd5b4; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="212"&gt;Must attend&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fcd5b4; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="166"&gt;Must attend&lt;/td&gt;     &lt;/tr&gt;      &lt;tr style="height: 15pt" height="20"&gt;       &lt;td class="xl66" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 700; font-size: 11pt; background: #fde9d9; border-left: #fac090 0.5pt solid; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; height: 15pt; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="310" height="20"&gt;Building WCF today&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fde9d9; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="173"&gt;Should attend&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fde9d9; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="212"&gt;Should attend&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fde9d9; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="166"&gt;Must attend&lt;/td&gt;     &lt;/tr&gt;      &lt;tr style="height: 15pt" height="20"&gt;       &lt;td class="xl66" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 700; font-size: 11pt; background: #fcd5b4; border-left: #fac090 0.5pt solid; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; height: 15pt; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="310" height="20"&gt;Looked at WF, but didn't use it&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fcd5b4; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="173"&gt;Must attend&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fcd5b4; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="212"&gt;Must attend&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fcd5b4; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="166"&gt;Should attend&lt;/td&gt;     &lt;/tr&gt;      &lt;tr style="height: 15pt" height="20"&gt;       &lt;td class="xl66" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 700; font-size: 11pt; background: #fde9d9; border-left: #fac090 0.5pt solid; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; height: 15pt; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="310" height="20"&gt;Looked at WCF, but didn't use it&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fde9d9; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="173"&gt;Should attend&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fde9d9; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="212"&gt;Would enjoy&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fde9d9; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="166"&gt;Must attend&lt;/td&gt;     &lt;/tr&gt;      &lt;tr style="height: 15pt" height="20"&gt;       &lt;td class="xl66" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 700; font-size: 11pt; background: #fcd5b4; border-left: #fac090 0.5pt solid; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; height: 15pt; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="310" height="20"&gt;Interested in Oslo&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fcd5b4; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="173"&gt;Must attend&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fcd5b4; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="212"&gt;Should attend&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fcd5b4; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="166"&gt;Should attend&lt;/td&gt;     &lt;/tr&gt;      &lt;tr style="height: 15pt" height="20"&gt;       &lt;td class="xl66" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 700; font-size: 11pt; background: #fde9d9; border-left: #fac090 0.5pt solid; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; height: 15pt; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="310" height="20"&gt;Interested in the problem of coordination&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fde9d9; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="173"&gt;Should attend&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fde9d9; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="212"&gt;Should attend&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fde9d9; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fde9d9 none" width="166"&gt;Should attend&lt;/td&gt;     &lt;/tr&gt;      &lt;tr style="height: 15pt" height="20"&gt;       &lt;td class="xl66" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 700; font-size: 11pt; background: #fcd5b4; border-left: #fac090 0.5pt solid; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; height: 15pt; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="310" height="20"&gt;Building services, or apps that consume services&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fcd5b4; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="173"&gt;Would enjoy&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fcd5b4; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="212"&gt;Would enjoy&lt;/td&gt;        &lt;td class="xl65" style="border-right: #fac090 0.5pt solid; border-top: medium none; font-weight: 400; font-size: 11pt; background: #fcd5b4; border-left: medium none; color: black; border-bottom: #fac090 0.5pt solid; font-family: calibri; text-decoration: none; text-underline-style: none; text-line-through: none; mso-pattern: #fcd5b4 none" width="166"&gt;Must attend&lt;/td&gt;     &lt;/tr&gt;   &lt;/tbody&gt;&lt;/table&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Can't wait to see you in LA!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8974616" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx">wf</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/Oslo/default.aspx">Oslo</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/PDC2008/default.aspx">PDC2008</category></item><item><title>WCF Perf Talk @ PDC (or, the Doctor Teaches Fishing)</title><link>http://blogs.msdn.com/mwinkle/archive/2008/10/02/wcf-perf-talk-pdc-or-the-doctor-teaches-fishing.aspx</link><pubDate>Thu, 02 Oct 2008 20:06:54 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8973955</guid><dc:creator>mwinkle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/8973955.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=8973955</wfw:commentRss><description>&lt;p&gt;I'm probably not going to have too much time to attend talks at PDC, but one talk that would be high on my list is the one that Dr. Allen blogs about &lt;a href="http://blogs.msdn.com/drnick/archive/2008/10/02/zen-of-wcf-performance-and-scale.aspx"&gt;here&lt;/a&gt;, where he talks about the Zen of WCF Performance and Scale.&amp;#160; &lt;/p&gt;  &lt;p&gt;I like &amp;quot;Zen&amp;quot; style talks, especially for topics like performance and scale.&amp;#160; Sure, I could go and listen for 75 minutes for tips and tricks that may be applicable to my scenario, but this is giving you a fish.&amp;#160; Having a 75 minute conversation about how to think about perf and scale, how to think about achieving that in a distributed messaging system teaches you how to fish.&amp;#160; This is going to equip you with a lot more knowledge about &lt;em&gt;how&lt;/em&gt; to plan for and solve performance and scale issues down the road.&lt;/p&gt;  &lt;p&gt;This is one lunch session, I wouldn't want to miss.&amp;#160; As a plus, he's taking questions and suggestions on his blog, so fire away!&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8973955" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/PDC2008/default.aspx">PDC2008</category></item><item><title>More Details On WF/WCF in .NET 4.0</title><link>http://blogs.msdn.com/mwinkle/archive/2008/10/01/more-details-on-wf-wcf-in-net-4-0.aspx</link><pubDate>Wed, 01 Oct 2008 23:15:27 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8972142</guid><dc:creator>mwinkle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/8972142.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=8972142</wfw:commentRss><description>&lt;p&gt;&lt;a href="http://blogs.msdn.com/stevemar"&gt;Steve Martin&lt;/a&gt;, a director of product management for CSD, has a &lt;a href="http://blogs.msdn.com/stevemar/archive/2008/10/01/the-road-to-pdc-net-framework-4-0-and-dublin.aspx"&gt;blog post&lt;/a&gt; containing more information on the work that we are doing for the next versions of WF and WCF that we will release as a CTP at PDC.&amp;#160; He also introduces &amp;quot;Dublin,&amp;quot; the name for our efforts around creating a manageable and scalable host for WF and WCF applications, something that I know a few customers would be interested in.&amp;#160; &lt;/p&gt;  &lt;p&gt;For you WF and WCF fans, there some more information about some of the features that you'll hear more about at PDC.&amp;#160; I think for customers who are using either today, you'll see something on the list below that gets you interested.&amp;#160; And, if you're not using WF or WCF today, I think there are a few things that might make you interested. We think that the features we're introducing (especially in WF, which is close to my heart) will make it easier to use WF, in more places, and by more people.&amp;#160; Let us know what you think.&amp;#160; What's exciting in the list below, what do you want to hear more about, is there something else you'd like to see on the list? &lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;WF Features&lt;/h2&gt;  &lt;p&gt;&lt;b&gt;Significant improvements in performance and scalability&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&amp;#183; Ten-fold improvement in performance&lt;/p&gt;  &lt;p&gt;&lt;b&gt;New workflow flow-control models and pre-built activities&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&amp;#183; Flowcharts, rules&lt;/p&gt;  &lt;p&gt;&amp;#183; Expanded built-in activities &amp;#8211; PowerShell, database, messaging, etc.&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Enhancements in workflow modeling&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&amp;#183; Persistence control, transaction flow, compensation support, data binding and scoping&lt;b&gt;&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&amp;#183; Rules composable and seamlessly integrated with workflow engine&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Updated visual designer&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&amp;#183; Easier to use by end-users &lt;/p&gt;  &lt;p&gt;&amp;#183; Easier to rehost by ISVs&lt;/p&gt;  &lt;p&gt;Ability to debug XAML&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h2&gt;WCF Features&lt;/h2&gt;  &lt;p&gt;&lt;b&gt;RESTful enhancements&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&amp;#183; Simplifying the building of REST Singleton &amp;amp; Collection Services, ATOM Feed and Publishing Protocol Services, and HTTP Plain XML Services using WCF&lt;/p&gt;  &lt;p&gt;&amp;#183; WCF REST Starter Kit to be released on Codeplex to get early feedback&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Messaging enhancements&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&amp;#183; Transports - UDP, MQ, Local in-process &lt;/p&gt;  &lt;p&gt;&amp;#183; Protocols - SOAP over UDP, WS-Discovery, WS-BusinessActivity, WS-I BP 1.2&lt;/p&gt;  &lt;p&gt;&amp;#183; Duplex durable messaging&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Correlation enhancements&lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&amp;#183; Content and context driven, One-way support&lt;/p&gt;  &lt;p&gt;&lt;b&gt;Declarative Workflow Services &lt;/b&gt;&lt;/p&gt;  &lt;p&gt;&amp;#183; Seamless integration between WF and WCF and unified XAML model&lt;/p&gt;  &lt;p&gt;&amp;#183; Build entire application in XAML, from presentation to data to services to workflow&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8972142" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx">wf</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/Oslo/default.aspx">Oslo</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/PDC2008/default.aspx">PDC2008</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/Dublin/default.aspx">Dublin</category></item><item><title>Advanced Workflow Service Talk (Demo 4 of 4)</title><link>http://blogs.msdn.com/mwinkle/archive/2008/08/11/advanced-workflow-service-talk-demo-4-of-4.aspx</link><pubDate>Mon, 11 Aug 2008 18:52:10 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8848313</guid><dc:creator>mwinkle</dc:creator><slash:comments>3</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/8848313.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=8848313</wfw:commentRss><description>&lt;p&gt;When we start doing this two way style of messaging, we now open up to start modeling some interesting business problems.&amp;#160; In the previous post, you'll note that I did not include the code, because I mentioned we needed to be more clever in scenarios where we listen in parallel.&amp;#160; &lt;/p&gt;  &lt;p&gt;First, a brief diversion into how the Receive activity works.&amp;#160; Everybody remembers the workflow queues, the technology that underlies all communication between a host and a workflow instance.&amp;#160; The Receive activity works by creating a queue that the WorkflowServiceHost (specifically the WorkflowOperationInvoker) will use to send the message received off the wire into the workflow.&amp;#160; Now, the Receive activity normally just creates a queue that is named the same as the operation the Receive activity is bound to.&amp;#160; However, if we have two Receive activities listening for the same operation at the same time, no longer is a single queue useful to route responses back as we want to route to the correct Receive activity instance.&amp;#160; &lt;/p&gt;  &lt;p&gt;There is property on the Receive activity called ContextToken.&amp;#160; Normally this is null in the simple case.&amp;#160; However, when we want our Receive activity to operate in parallel, we need to indicate that it needs to be smarter when it creates a queue.&amp;#160; &lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServiceTalkDemo4of4_9005/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="227" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServiceTalkDemo4of4_9005/image_thumb.png" width="409" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;By setting this property (you can just type in a name, and then select the common owner all of the parallel receive's share.&amp;#160; This will cause the Receive activity to create a queue named [OperationName] +[ConversationId], the conversation ID takes the form of a GUID, and is the second element inside a context token.&amp;#160; &lt;/p&gt;  &lt;p&gt;The sample that I show for this talk is simply the &lt;a href="http://msdn.microsoft.com/en-us/library/bb410775.aspx"&gt;conversations sample inside the SDK&lt;/a&gt;.&amp;#160; This is the sample to check out to understand all sorts of interesting ways to use the context tokens to model your processes.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb410775.aspx"&gt;&lt;img alt="Conversations Sample Architecture" src="http://i.msdn.microsoft.com/Bb410775.7f198cc1-b77a-4460-a007-4ac0ac91a109(en-us,VS.90).gif" /&gt;&lt;/a&gt;&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;Now, there are two conversation patterns here.&amp;#160; One is the one shown above, which I refer to as an &lt;em&gt;n&lt;/em&gt;-party conversation where &lt;em&gt;n&lt;/em&gt; is fixed at design time.&amp;#160; We can accomplish this with the parallel activity.&amp;#160; The other is where &lt;em&gt;n&lt;/em&gt; is arbitrary (imagine you send out to business partners stored in the database).&amp;#160; The way to do this is to use the &lt;a href="http://msdn.microsoft.com/en-us/library/system.workflow.activities.replicatoractivity.aspx"&gt;Replicator&lt;/a&gt; activity.&amp;#160; The Replicator is a little known gem shipped in 3.0 that essentially gives you &amp;quot;ForEach&amp;quot; semantics.&amp;#160; But, by flipping the &lt;a href="http://msdn.microsoft.com/en-us/library/system.workflow.activities.replicatoractivity.executiontype.aspx"&gt;ExecutionType&lt;/a&gt; switch to parallel, I now get the behavior of a parallel, but operating with an arbitrary &lt;em&gt;n&lt;/em&gt; branches. &lt;/p&gt;  &lt;p&gt;So, in order to enable conversations, we need to tell our receive activity to be a little smarter about how it generates its queue name, and then we simply follow the duplex pattern we discussed in the last &lt;a href="http://blogs.msdn.com/mwinkle/archive/2008/08/06/advanced-workflow-services-talk-demo-2-of-4.aspx#comments"&gt;two&lt;/a&gt; &lt;a href="http://blogs.msdn.com/mwinkle/archive/2008/08/07/advanced-workflow-services-talk-demo-3-of-4.aspx"&gt;posts&lt;/a&gt;.&amp;#160; Once we do that, we're in good shape to start modeling some more interesting communication patterns between multiple parties.&amp;#160; &lt;/p&gt;  &lt;h3&gt;Where can we go from here? &lt;/h3&gt;  &lt;p&gt;   &lt;br /&gt;We can just make the patterns more interesting.&amp;#160; One interesting one would be the combination of the long running work with cancellation and a &lt;a href="http://blogs.msdn.com/mwinkle/archive/2007/06/27/implementing-the-n-of-m-pattern-in-wf.aspx"&gt;Voting activity&lt;/a&gt; in order to coordinate the responses and allow for progress to be made when some of the branches complete (if I have 3 yes votes, I can proceed).&amp;#160; The power of building composite activities is that it gives me a uniform programming model (and a single threaded one to boot) in order to handle the coordination of different units of work.&amp;#160; Get out there and write some workflows :-) &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8848313" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx">wf</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/patterns/default.aspx">patterns</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/presentations/default.aspx">presentations</category></item><item><title>Advanced Workflow Services Talk (Demo 3 of 4)</title><link>http://blogs.msdn.com/mwinkle/archive/2008/08/07/advanced-workflow-services-talk-demo-3-of-4.aspx</link><pubDate>Fri, 08 Aug 2008 00:17:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8841711</guid><dc:creator>mwinkle</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/8841711.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=8841711</wfw:commentRss><description>&lt;p&gt;So, we've seen in part 1 how to manage context, we saw in part 2 how we can take that basic knowledge to do duplex messaging.&amp;#160; Once we start doing duplex work, there are some interesting patterns, and the first one is one that we like to call &amp;quot;long running work&amp;quot;.&amp;#160; Why are we interested in this?&amp;#160; Well, as you probably know, the execution of a workflow is single threaded (this is a feature, not a bug).&amp;#160; We also don't have a mechanism to force the workflow to be &amp;quot;pinned&amp;quot; in memory.&amp;#160; What this means is that things like the asynchronous programming model&amp;#160; (APM), can't be used, since there isn't a guarantee that there will be something to call back when we are done.&amp;#160; What this means is that the send activity can not take advantage of the APM to be more thread friendly.&lt;/p&gt;  &lt;p&gt;We may want to do things in parallel, like this&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServicesTalkDemo3of4_D4A0/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="309" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServicesTalkDemo3of4_D4A0/image_thumb.png" width="616" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;If each of these branches takes 3 seconds, the whole of this workflow will complete in about 9 seconds.&amp;#160; The general expectation is that in parallel, this would happen at the length of the longest branch + some minor delta for overhead.&amp;#160; The trouble is, APM programming is tricky, especially relative to the layout above.&lt;/p&gt;  &lt;p&gt;In order to model APM style service calls, but allowing for the service operations to be extremely long running, where extremely is defined as &amp;quot;long enough to where I would want to be able to persist.&amp;quot;&amp;#160; The approach then is to model this as disjoint send and receive activities.&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServicesTalkDemo3of4_D4A0/image_4.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="386" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServicesTalkDemo3of4_D4A0/image_thumb_1.png" width="632" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;  &lt;p&gt;One intermediate step is to simply use one way messaging, but the problem there is that in a lot of cases, I'm looking for some information being sent back to me.&amp;#160; &lt;/p&gt;  &lt;p&gt;I'll hold off on the code for the above, the fact we are listening in parallel for the same operation requires us to be a little more clever. &lt;/p&gt;  &lt;p&gt;Let's look first at our contract, and then our service implementation:&lt;/p&gt;  &lt;div class="csharpcode"&gt;   &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; Long_Running_Work&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    [ServiceContract]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; ILongRunningWork&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        [OperationContract]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        &lt;span class="kwrd"&gt;string&lt;/span&gt; TakeAWhile(&lt;span class="kwrd"&gt;int&lt;/span&gt; i);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        [OperationContract(IsOneWay = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;        &lt;span class="kwrd"&gt;void&lt;/span&gt; OneWayTakeAWhile( &lt;span class="kwrd"&gt;int&lt;/span&gt; i);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;        &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;        [OperationContract(IsOneWay = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        &lt;span class="kwrd"&gt;void&lt;/span&gt; TakeAWhileAndTellMeLater(IDictionary&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;,&lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; contextToken, &lt;span class="kwrd"&gt;int&lt;/span&gt; i);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    [ServiceContract]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; IReverseContract&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;        [OperationContract(IsOneWay = &lt;span class="kwrd"&gt;true&lt;/span&gt;)]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;        &lt;span class="kwrd"&gt;void&lt;/span&gt; TakeAWhileAndTellMeLaterDone(&lt;span class="kwrd"&gt;string&lt;/span&gt; s);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;   &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;And now for the implementation of these;&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;namespace&lt;/span&gt; Long_Running_Work&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;   &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; Service1 : ILongRunningWork&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; Service1()&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;           &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;        &lt;span class="preproc"&gt;#region&lt;/span&gt; ILongRunningWork Members&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; TakeAWhile(&lt;span class="kwrd"&gt;int&lt;/span&gt; i)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Starting TakeAWhile&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;            System.Threading.Thread.Sleep(&lt;span class="kwrd"&gt;new&lt;/span&gt; TimeSpan(0, 0, 3));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;            &lt;span class="kwrd"&gt;return&lt;/span&gt; i.ToString();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; OneWayTakeAWhile( &lt;span class="kwrd"&gt;int&lt;/span&gt; i)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Starting One Way TakeAWhile&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;            System.Threading.Thread.Sleep(&lt;span class="kwrd"&gt;new&lt;/span&gt; TimeSpan(0, 0, 3));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Ending One Way TakeAWhile&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  27:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  28:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  29:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  30:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  31:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  32:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; TakeAWhileAndTellMeLater(IDictionary&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; context, &lt;span class="kwrd"&gt;int&lt;/span&gt; i)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  33:  &lt;/span&gt;        {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  34:  &lt;/span&gt;            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Received the context Token&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  35:  &lt;/span&gt;            System.Threading.Thread.Sleep(&lt;span class="kwrd"&gt;new&lt;/span&gt; TimeSpan(0, 0, 3));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  36:  &lt;/span&gt;            Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Need to Message Back Now {0}&amp;quot;&lt;/span&gt;, i.ToString());&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  37:  &lt;/span&gt;            &lt;span class="rem"&gt;// could investigate a more useful pooling of these if we &lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  38:  &lt;/span&gt;            &lt;span class="rem"&gt;// really wanted to worry about perf&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  39:  &lt;/span&gt;            IReverseContractClient ircc = &lt;span class="kwrd"&gt;new&lt;/span&gt; IReverseContractClient(&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  40:  &lt;/span&gt;                &lt;span class="kwrd"&gt;new&lt;/span&gt; NetTcpContextBinding(),&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  41:  &lt;/span&gt;                &lt;span class="kwrd"&gt;new&lt;/span&gt; EndpointAddress(&lt;span class="str"&gt;&amp;quot;net.tcp://localhost:10003/ReverseContract&amp;quot;&lt;/span&gt;)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  42:  &lt;/span&gt;                );&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  43:  &lt;/span&gt;            IContextManager icm = ircc.InnerChannel.GetProperty&amp;lt;IContextManager&amp;gt;();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  44:  &lt;/span&gt;            icm.SetContext(context);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  45:  &lt;/span&gt;            ircc.TakeAWhileAndTellMeLaterDone(i.ToString());&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  46:  &lt;/span&gt;        }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  47:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  48:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  49:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  50:  &lt;/span&gt;        &lt;span class="preproc"&gt;#endregion&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  51:  &lt;/span&gt;    } &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  52:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  53:  &lt;/span&gt;   &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;class&lt;/span&gt; IReverseContractClient : ClientBase&amp;lt;IReverseContract&amp;gt;, IReverseContract&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  54:  &lt;/span&gt;   {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  55:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; IReverseContractClient() : &lt;span class="kwrd"&gt;base&lt;/span&gt;(){}&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  56:  &lt;/span&gt;        &lt;span class="kwrd"&gt;public&lt;/span&gt; IReverseContractClient(System.ServiceModel.Channels.Binding binding, EndpointAddress address) : &lt;span class="kwrd"&gt;base&lt;/span&gt;(binding, address) { }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  57:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  58:  &lt;/span&gt;&lt;span class="preproc"&gt;#region&lt;/span&gt; IReverseContract Members&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  59:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  60:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  61:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  62:  &lt;/span&gt;       &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; TakeAWhileAndTellMeLaterDone(&lt;span class="kwrd"&gt;string&lt;/span&gt; s)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  63:  &lt;/span&gt;       {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  64:  &lt;/span&gt;           &lt;span class="kwrd"&gt;base&lt;/span&gt;.Channel.TakeAWhileAndTellMeLaterDone(s);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  65:  &lt;/span&gt;       }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  66:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  67:  &lt;/span&gt;       &lt;span class="preproc"&gt;#endregion&lt;/span&gt;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  68:  &lt;/span&gt;   }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  69:  &lt;/span&gt; &lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  70:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Basically, we sit around and wait.&amp;#160; You'll also note in the TakeAWhileAndTellMeLater, we take in a context token (similar to our previous approach), and we will use that to new up a client at the end and call back in after setting the context.&amp;#160; Look at lines 39-44 above.&amp;#160; The nice thing about this is that my above workflow client can actually go idle, persist, and react to a message being delivered later on.&lt;/p&gt;

&lt;p&gt;One thing to note is that one should not place a delay between any of the Send and Receives.&amp;#160; This could cause the workflow to go idle, which may allow you to miss messages.&amp;#160; This is generally considered, a bad thing.&amp;#160; The reason this occurs is that the WorkflowOperationInvoker will use EnqueueOnIdle which means that when teh workflow goes idle, the message will be enqueued.&amp;#160; If the queue hasn't been created by the Receive activity, the message will not get delivered.&lt;/p&gt;

&lt;p&gt;For the final workflow above (the TakeAWhileAndTellMeLater workflow), I will need to spin this up in a WorkflowServiceHost (a la the Duplex Sample in part 2).&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; (WorkflowServiceHost wsh = &lt;span class="kwrd"&gt;new&lt;/span&gt; WorkflowServiceHost(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(CallLongRunningComponents.WorkflowWithmessaging)))
{
    wsh.AddServiceEndpoint(
            &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Long_Running_Work.IReverseContract),
            &lt;span class="kwrd"&gt;new&lt;/span&gt; NetTcpContextBinding(),
           &lt;span class="str"&gt;&amp;quot;net.tcp://localhost:10003/ReverseContract&amp;quot;&lt;/span&gt;
            );
    &lt;span class="rem"&gt;// don't forget to open up the wsh&lt;/span&gt;
    WorkflowRuntime wr = wsh.Description.Behaviors.Find&amp;lt;WorkflowRuntimeBehavior&amp;gt;().WorkflowRuntime;

    wsh.Open();


    WorkflowInstance wi = wr.CreateWorkflow(
        &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(CallLongRunningComponents.WorkflowWithmessaging));
    wr.WorkflowCompleted += ((o, e) =&amp;gt; waitHandle.Set());
    wr.WorkflowIdled += ((o, e) =&amp;gt; Console.WriteLine(&lt;span class="str"&gt;&amp;quot;We're idled&amp;quot;&lt;/span&gt;));
        

    wi.Start();




    waitHandle.WaitOne();

}&lt;/pre&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Why do I think this is cool? &lt;/p&gt;

&lt;p&gt;Two reasons:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;If I assume that I can modify the called service to callback to me (or put such a wrapper at a runtime service level), this is easier to model than the APM (that code included at the end of this post) &lt;/li&gt;

  &lt;li&gt;This gives me a natural way to start exposing more advanced control over a service call.&amp;#160; Rather than just a send and receive, I can use a send and a listen, and in the listen have a receive, a cancel message receive, and a delay in order to expose more fine grained control points for my workflow, and model the way the process should work very explicitly and declaratively. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServicesTalkDemo3of4_D4A0/image_6.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="503" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServicesTalkDemo3of4_D4A0/image_thumb_2.png" width="449" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h4&gt;Code for APM approach:&lt;/h4&gt;

&lt;p&gt;call some services and wait:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Press &amp;lt;enter&amp;gt; to execute APM approach&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;Console.ReadLine();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;waitHandle = &lt;span class="kwrd"&gt;new&lt;/span&gt; AutoResetEvent(&lt;span class="kwrd"&gt;false&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;Stopwatch sw = &lt;span class="kwrd"&gt;new&lt;/span&gt; Stopwatch();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;sw.Start();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;lrwc = &lt;span class="kwrd"&gt;new&lt;/span&gt; WorkflowHost.ServiceReference1.LongRunningWorkClient();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;lrwc.BeginTakeAWhile(1, HandleClientReturn, &lt;span class="str"&gt;&amp;quot;one&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;lrwc.BeginTakeAWhile(2, HandleClientReturn, &lt;span class="str"&gt;&amp;quot;two&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;lrwc.BeginTakeAWhile(3, HandleClientReturn, &lt;span class="str"&gt;&amp;quot;three&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;lrwc.BeginTakeAWhile(4, HandleClientReturn, &lt;span class="str"&gt;&amp;quot;four&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;&lt;span class="kwrd"&gt;while&lt;/span&gt; (!areDone)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    System.Threading.Thread.Sleep(25);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;}&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;APM approach compelted in {0} milliseconds&amp;quot;&lt;/span&gt;, sw.ElapsedMilliseconds);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;Console.WriteLine(&lt;span class="str"&gt;&amp;quot;All Done, press &amp;lt;enter&amp;gt; to exit&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;Console.ReadLine();&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;Ignore the busy wait on line 11, I should use a waithandle here but was having trouble getting it to work correctly (this is hard code).&lt;/p&gt;

&lt;p&gt;The callback and respective state:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;static&lt;/span&gt; ServiceReference1.LongRunningWorkClient lrwc;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;static&lt;/span&gt; Int32 countOfFinished = 0;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; HandleClientReturn(IAsyncResult result)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    &lt;span class="kwrd"&gt;string&lt;/span&gt; s = (&lt;span class="kwrd"&gt;string&lt;/span&gt;)result.AsyncState;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;    &lt;span class="kwrd"&gt;string&lt;/span&gt; resultString = lrwc.EndTakeAWhile(result);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;received {0}&amp;quot;&lt;/span&gt;, resultString);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (Interlocked.Increment(&lt;span class="kwrd"&gt;ref&lt;/span&gt; countOfFinished) == 4)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;        areDone = &lt;span class="kwrd"&gt;true&lt;/span&gt;;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;

&lt;p&gt;&lt;style type="text/css"&gt;


.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/p&gt;

&lt;p&gt;I have had some people say that line 9 should use &lt;a href="http://msdn.microsoft.com/en-us/library/system.threading.interlocked.compareexchange.aspx"&gt;Interlocked.CompareExchange&lt;/a&gt; in order to do this correctly, but the point is that this is tricky code, that modeling in WF is pretty nice.&amp;#160; [ignoring for the moment the work required to realize the assumption that we can make the service message back.]&amp;#160; &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8841711" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx">wf</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/presentations/default.aspx">presentations</category></item><item><title>Q &amp; A on Advanced Workflow Services talk</title><link>http://blogs.msdn.com/mwinkle/archive/2008/08/07/q-a-on-advanced-workflow-services-talk.aspx</link><pubDate>Thu, 07 Aug 2008 22:13:30 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8841511</guid><dc:creator>mwinkle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/8841511.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=8841511</wfw:commentRss><description>&lt;p&gt;Martin posted an interesting question &lt;a href="http://blogs.msdn.com/mwinkle/archive/2008/08/06/advanced-workflow-services-talk-demo-2-of-4.aspx#8840881"&gt;here&lt;/a&gt; on my last post:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;&amp;lt;quote&amp;gt;&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;The first thing that we need to do in order to enable this duplex messaging to occur is that the &amp;quot;client&amp;quot; workflow has to explicitly provide its context token to the service so that the service can address the appropriate instance of the client workflow.&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;Note, in the real world, you'll probably need to supply more than just the context token, you will need some address and binding information.&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;&amp;lt;/quote&amp;gt;&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;Shouldn't we have this built into a custom binding? (or an extra binding element) So with every call from the client the (WF)context information is included. And the developer is not required to follow a (artificial) state machine.&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;Note, at the time, when the service calls back, the endpoint (and the binding) of the client may have changed... So we may need dynamic name-endpoint resolution (sounds like DNS?)&lt;/em&gt;&lt;/p&gt;    &lt;p&gt;&lt;em&gt;Martin&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;The question here is generally also asked as &amp;quot;wait, why do I need to explicitly provide a context token and change the contract to have this context thing?&amp;quot;&amp;#160; This is a common question, as changing the contract to reflect implementation details is generally a no-no.&amp;#160; There's one part I left out as well, so let me add that here:&lt;/p&gt;  &lt;p&gt;In the real world, one may also wish to not change the contract (or may not have the ability to).&amp;#160; In that case, we still need to explicitly provide the context token and endpoint information in order to allow me to call back.&amp;#160; There are a few ways to do this, of varying complexity and implication:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Put this into the message header and have the other side extract this information and use it the same way.&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;There are two downsides to this approach:&lt;/li&gt;      &lt;ul&gt;       &lt;li&gt;It still requires management of the other side to agree upon where the context token is being place.&lt;/li&gt;        &lt;li&gt;The WF Messaging activities don't give me an easy way to reach in and get to header information, but one could certainly look at some infrastructure level extensions to manage this.&amp;#160; This idea of making duplex easier is one thing that Ed will be talking about in his &lt;a href="http://channel9.msdn.com/pdc2008/TL06/"&gt;Oslo workflow services talk at PDC&lt;/a&gt;&lt;/li&gt;     &lt;/ul&gt;   &lt;/ul&gt;    &lt;li&gt;Create a custom binding element.&lt;/li&gt;    &lt;ul&gt;     &lt;li&gt;There is one downside with this approach:&lt;/li&gt;      &lt;ul&gt;       &lt;li&gt;You're creating a custom channel, custom binding element, and all the other stuff that goes along with creating a channel.&amp;#160; This is very hard work.&amp;#160; If the answer is &amp;quot;you've got to write a channel to do it,&amp;quot; we need to do a better job making it easier (see earlier point about Ed's talk).&lt;/li&gt;     &lt;/ul&gt;      &lt;li&gt;If that's the behavior that you want, you are certainly welcome do go down that path, it would be great to hear about your experiences doing it!&lt;/li&gt;      &lt;li&gt;The upside to this approach:&lt;/li&gt;      &lt;ul&gt;       &lt;li&gt;You're creating a layer of near infinite extensibility, allowing you to handle simple things to the complex dynamic endpoint resolution behavior, once you invest the cost once to create the channel that would sit there and do that.&lt;/li&gt;     &lt;/ul&gt;   &lt;/ul&gt; &lt;/ul&gt;  &lt;p&gt;This is also the same approach one could take with using an implicit, or content based correlation scheme.&amp;#160; In that case, you create an intermediary that is responsible for translating message contents into the &amp;quot;addressing&amp;quot; information for the instance.&amp;#160; That intermediary can be a service, it could be a channel, and once you put that intermediary in place, you are free to do as sophisticated or as simple work as possible.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8841511" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx">wf</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category></item><item><title>Advanced Workflow Services Talk (Demo 2 of 4)</title><link>http://blogs.msdn.com/mwinkle/archive/2008/08/06/advanced-workflow-services-talk-demo-2-of-4.aspx</link><pubDate>Wed, 06 Aug 2008 21:30:04 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8838441</guid><dc:creator>mwinkle</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/8838441.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=8838441</wfw:commentRss><description>&lt;p&gt;A continuation of my series of demos from my advanced workflow services talk.&amp;#160; Here we focus on duplex message exchange patterns.&lt;/p&gt;  &lt;p&gt;Duplex messaging is something that we model at the application level (as opposed to the infrastructure level) because we want to model that message exchange at the level of the application.&amp;#160; Here's some scenarios where I could use duplex messaging:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;[concrete] I submit an order, and you tell me when it ships &lt;/li&gt;    &lt;li&gt;[abstract] I ask you do to do some long running work, let me know when it is done &lt;/li&gt;    &lt;li&gt;[abstract] I ask you to start doing something, you update me on the status &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;One may ask the question, &amp;quot;But, what about the wsHttpDualBinding, or WCF duplex bindings.&amp;quot;&amp;#160; That's a valid question, but it's important to point out that those bindings are really used to describe the behavior of a given proxy instance (and associated service artifacts).&amp;#160; When my proxy dies, or the underlying connection goes away, I lose the ability for the service to call back to me.&amp;#160; Additionally, this binds me to listen in the same way that I sent out the initial message.&amp;#160; &lt;/p&gt;  &lt;p&gt;By modeling this at the application layer, we do lose some of the &amp;quot;automagicity&amp;quot; of the WCF duplex behavior, but I get more flexibility, and I get the ability to sustain potentially repeated recycling of the services and clients.&amp;#160; Also, you could imagine a service that I call that turns around and calls a third party service.&amp;#160; That third party service could call back directly to the client that made the initial call.&amp;#160; Note, once we start doing duplex communication (and we'll encounter this in part 4, conversations), is that the definition of &amp;quot;client&amp;quot; and &amp;quot;service&amp;quot; become a bit muddier.&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;So, to the code:&lt;/p&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Ingredients:&lt;/h4&gt;  &lt;ul&gt;   &lt;li&gt;My service workflow, I listen for three different messages (start, add item, complete ), and then I will send the message back to the client: &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServicesTalkDemo2of4_C68C/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="855" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServicesTalkDemo2of4_C68C/image_thumb.png" width="450" border="0" /&gt;&lt;/a&gt;       &lt;ul&gt;       &lt;li&gt;You'll note that there is a loop so that we can keep adding items until we eventually get the complete order message and we then exit the loop. &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt;    &lt;li&gt;A &amp;quot;client&amp;quot; workflow, which will call this service: &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServicesTalkDemo2of4_C68C/image_4.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="667" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServicesTalkDemo2of4_C68C/image_thumb_1.png" width="234" border="0" /&gt;&lt;/a&gt;       &lt;ul&gt;       &lt;li&gt;You'll note, some of &lt;strong&gt;&lt;em&gt;the magic happens here&lt;/em&gt;&lt;/strong&gt;.&amp;#160; After I start, add and complete the order, you'll see that instead of sending messages, I'll now flip around and wait on the receive in order to receive the shipping cost from the service. &lt;/li&gt;     &lt;/ul&gt;   &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;h4&gt;Details&lt;/h4&gt;  &lt;p&gt;The first thing that we need to do in order to enable this duplex messaging to occur is that the &amp;quot;client&amp;quot; workflow has to explicitly provide its context token to the service so that the service can address the appropriate instance of the client workflow.&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;Note, in the real world, you'll probably need to supply more than just the context token, you will need some address and binding information.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Let's look at the contract of the service:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;[ServiceContract(Namespace =&lt;span class="str"&gt;&amp;quot;http://microsoft.com/dpe/samples/duplex&amp;quot;&lt;/span&gt;)]
&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt;  IOrderProcessing
{
    [OperationContract()]
    &lt;span class="kwrd"&gt;void&lt;/span&gt; SubmitOrder(&lt;span class="kwrd"&gt;string&lt;/span&gt; customerName, &lt;font color="#ff0000"&gt;IDictionary&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; context&lt;/font&gt;);

    [OperationContract(IsOneWay = &lt;span class="kwrd"&gt;true&lt;/span&gt; )]
    &lt;span class="kwrd"&gt;void&lt;/span&gt; AddItem(OrderItem orderItem);

    [OperationContract(IsOneWay = &lt;span class="kwrd"&gt;true&lt;/span&gt; )]
    &lt;span class="kwrd"&gt;void&lt;/span&gt; CompleteOrder();
}&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;You'll note that on the SubmitOrder method, I pass in a context token.&amp;#160; This is my callback correlation identifier, this is how I will figure out what instance on the client side I want to talk to.&amp;#160; Now, I need to do some work to get the context token in order to send, so let's look at how we do this:&lt;/p&gt;

&lt;p&gt;On the client side, on the first Send activity, let's hook the BeforeSend event.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServicesTalkDemo2of4_C68C/image_6.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="292" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServicesTalkDemo2of4_C68C/image_thumb_2.png" width="278" border="0" /&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;Let's look at the implementation of GrabToken:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; GrabToken(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, SendActivityEventArgs e)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    ContextToSend = receiveActivity1.Context;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Received token to send along&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;}&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; DependencyProperty ContextToSendProperty = DependencyProperty.Register(&lt;span class="str"&gt;&amp;quot;ContextToSend&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(System.Collections.Generic.IDictionary&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, System.String&amp;gt;), &lt;span class="kwrd"&gt;typeof&lt;/span&gt;(OrderSubmitter.Workflow1));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;[DesignerSerializationVisibilityAttribute(DesignerSerializationVisibility.Visible)]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;[BrowsableAttribute(&lt;span class="kwrd"&gt;true&lt;/span&gt;)]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;[CategoryAttribute(&lt;span class="str"&gt;&amp;quot;Parameters&amp;quot;&lt;/span&gt;)]&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; System.Collections.Generic.IDictionary&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, String&amp;gt; ContextToSend&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    get&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;        &lt;span class="kwrd"&gt;return&lt;/span&gt; ((System.Collections.Generic.IDictionary&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt;)(&lt;span class="kwrd"&gt;base&lt;/span&gt;.GetValue(OrderSubmitter.Workflow1.ContextToSendProperty)));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;    set&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;        &lt;span class="kwrd"&gt;base&lt;/span&gt;.SetValue(OrderSubmitter.Workflow1.ContextToSendProperty, &lt;span class="kwrd"&gt;value&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;First, note that on lines 7-22 we declare a dependency property call ContextToSend.&amp;#160; Think of this simply as a bindable storage space.&amp;#160; On line 3, we go and assign to that the value of receiveActivity1.Context.&amp;#160; &amp;quot;But Matt, couldn't I just build a context token off the workflow ID?&amp;quot;&amp;#160; You could, but you're only going to be correct in the &amp;quot;simple scenario.&amp;quot;&amp;#160;&amp;#160; You can see we then take that ContextToSend, and pass that into the context parameter for the service operation. &lt;strong&gt;Always walk up and ask a Receive activity for its context token, don't try to build one on your own.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, on the service side, we need to extract that, and we need to apply the value to the send activity in the service workflow that needs to call back.&amp;#160; We basically can do the reverse:&lt;/p&gt;

&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; codeActivity1_ExecuteCode(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
{
    &lt;span class="rem"&gt;//set callback context&lt;/span&gt;
    sendActivity1.Context = callbackContext;
}&lt;/pre&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;This is inside a code activity in the first receive activity.&amp;#160; callbackContext is a dependency property that is bound to the inbound context on the Receive activity.&amp;#160; &lt;/p&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;p&gt;The final trick is that both workflows have to be hosted inside a WorkflowServiceHost.&amp;#160; This makes sense for the &amp;quot;service&amp;quot; workflow, since it will be message activated.&amp;#160; On the client side, we have to do a little bit of work in order to get to the workflow runtime to spin up a workflow instance.&amp;#160; In the early betas, we had an easy way to get to the runtime, WorkflowServiceHost.WorkflowRuntime.&amp;#160; In order to conform more with the extensibility of WCF, this has been moved to the extensions of the service host.&amp;#160; We get there by:&lt;/p&gt;

&lt;div class="csharpcode"&gt;
  &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Main(&lt;span class="kwrd"&gt;string&lt;/span&gt;[] args)&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    &lt;span class="kwrd"&gt;using&lt;/span&gt; (WorkflowServiceHost wsh = &lt;span class="kwrd"&gt;new&lt;/span&gt; WorkflowServiceHost(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Workflow1)))&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    {&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;        Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Press &amp;lt;ENTER&amp;gt; to start the workflow&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;        Console.ReadLine();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        wsh.Open();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;        WorkflowRuntime wr = wsh.Description.Behaviors.Find&amp;lt;WorkflowRuntimeBehavior&amp;gt;().WorkflowRuntime;&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;        WorkflowInstance wi = wr.CreateWorkflow(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Workflow1));&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;        AutoResetEvent waitHandle = &lt;span class="kwrd"&gt;new&lt;/span&gt; AutoResetEvent(&lt;span class="kwrd"&gt;false&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;        wr.WorkflowCompleted += &lt;span class="kwrd"&gt;delegate&lt;/span&gt; { waitHandle.Set(); };&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;        wr.WorkflowTerminated += &lt;span class="kwrd"&gt;delegate&lt;/span&gt;(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, WorkflowTerminatedEventArgs e) { Console.WriteLine(&lt;span class="str"&gt;&amp;quot;error {0}&amp;quot;&lt;/span&gt;, e); waitHandle.Set(); };&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;        wi.Start();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;        waitHandle.WaitOne();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;        Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Workflow Completed&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;        Console.ReadLine();&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    }&lt;/pre&gt;

  &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;}&lt;/pre&gt;
&lt;/div&gt;
&lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

&lt;p&gt;On line 3, you'll see we new up a WorkflowServiceHost based on the service type (it will do this to find and open the respective endpoints).&amp;#160; On line 8, we reach in and grab the WorkflowRuntimeBehavior and get the WorkflowRuntime, and we use that to create an instance of the workflow.&amp;#160; &lt;/p&gt;

&lt;p&gt;So, here's what we have done:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Figure out how to grab the context token from a Receive activity &lt;/li&gt;

  &lt;li&gt;Modify the contract to explicitly send the &amp;quot;callback info&amp;quot; to the service &lt;/li&gt;

  &lt;li&gt;On the service side, figure out how to grab that and apply it to a Send activity &lt;/li&gt;

  &lt;li&gt;Finally, on the client side, how to manually kick off workflows, rather than waiting for them to be message activated (the usual path we have is the infrastructure creating the workflow instance).&amp;#160; &lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8838441" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx">wf</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/presentations/default.aspx">presentations</category></item><item><title>Advanced Workflow Services Talk (Demo 1 of 4)</title><link>http://blogs.msdn.com/mwinkle/archive/2008/08/05/advanced-workflow-services-talk-demo-1-of-4.aspx</link><pubDate>Tue, 05 Aug 2008 20:44:58 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:8834527</guid><dc:creator>mwinkle</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/8834527.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=8834527</wfw:commentRss><description>&lt;p&gt;So, last week I wrapped up a conversation at TechReady, our internal conference, where I was talking about the integration between WF and WCF in .NET 3.5.&amp;#160; This talk was somewhat bittersweet, it's the last conference where I'm scheduled to talk about WF 3.0/3.5, I'll start talking about WF 4.0 at PDC this fall.&amp;#160; &lt;/p&gt;  &lt;p&gt;There are a series of 4 demos that we'll talk about in this series:&lt;/p&gt;  &lt;ol&gt;   &lt;li&gt;Basic Context Management &lt;/li&gt;    &lt;li&gt;Simple Duplex &lt;/li&gt;    &lt;li&gt;Long Running Work Pattern &lt;/li&gt;    &lt;li&gt;Conversations Pattern &lt;/li&gt; &lt;/ol&gt;  &lt;p&gt;I've gotten a lot of requests to post the code samples, so I want to do that here:&lt;/p&gt;  &lt;h1&gt;Sample 1, Basic Management of Context&lt;/h1&gt;  &lt;p&gt;The goal of this sample is to show the way that the context channel works, and how to interact with it from imperative code.&lt;/p&gt;  &lt;h3&gt;Ingredients: &lt;/h3&gt;  &lt;ul&gt;   &lt;li&gt;One basic workflow service that simply has two Receive activities bound to the same operation inside of a sequence. &lt;/li&gt;    &lt;li&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServicesTalkDemo1ofn_AAA5/image_2.png"&gt;&lt;img style="border-top-width: 0px; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="380" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/AdvancedWorkflowServicesTalkDemo1ofn_AAA5/image_thumb.png" width="279" border="0" /&gt;&lt;/a&gt; &lt;/li&gt;    &lt;li&gt;Inside each Receive, I have placed a Code Activity that simply outputs a little bit of info (the vars declared on lines 1 and 2 are used by the Receive activities: &lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;&amp;#160;&lt;/p&gt;  &lt;ul&gt;   &lt;div class="csharpcode"&gt;     &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; String returnValue = &lt;span class="kwrd"&gt;default&lt;/span&gt;(System.String);&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;public&lt;/span&gt; String inputMessage = &lt;span class="kwrd"&gt;default&lt;/span&gt;(System.String);&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; codeActivity1_ExecuteCode(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;{&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    returnValue = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;first activity {0}&amp;quot;&lt;/span&gt;, inputMessage);&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;    Output(inputMessage + &lt;span class="str"&gt;&amp;quot; Activity 1&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;}&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; Output(&lt;span class="kwrd"&gt;string&lt;/span&gt; message)&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;{&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Workflow {0} : Message {1}&amp;quot;&lt;/span&gt;, &lt;span class="kwrd"&gt;this&lt;/span&gt;.WorkflowInstanceId, message);&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;}&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; codeActivity2_ExecuteCode(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;{&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    returnValue = &lt;span class="kwrd"&gt;string&lt;/span&gt;.Format(&lt;span class="str"&gt;&amp;quot;second activity {0}&amp;quot;&lt;/span&gt;, inputMessage);&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;    Output(inputMessage + &lt;span class="str"&gt;&amp;quot; Activity 2&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

    &lt;pre&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;}&lt;/pre&gt;
  &lt;/div&gt;
  &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/ul&gt;

&lt;p&gt;&amp;#160;&lt;/p&gt;

&lt;h3&gt;Instructions: &lt;/h3&gt;

&lt;ul&gt;
  &lt;li&gt;Create a client type that will call the service for us 
    &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;class&lt;/span&gt; IWorkflowClient : ClientBase&amp;lt;Intro1.IWorkflow1&amp;gt;, Intro1.IWorkflow1
{
    &lt;span class="kwrd"&gt;public&lt;/span&gt; IWorkflowClient() : &lt;span class="kwrd"&gt;base&lt;/span&gt;() { }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; IWorkflowClient(Binding binding, EndpointAddress address) : &lt;span class="kwrd"&gt;base&lt;/span&gt;(binding, address) { }
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;string&lt;/span&gt; Hello(&lt;span class="kwrd"&gt;string&lt;/span&gt; message)
    {
        &lt;span class="kwrd"&gt;return&lt;/span&gt; &lt;span class="kwrd"&gt;base&lt;/span&gt;.Channel.Hello(message);
    }
}&lt;/pre&gt;
    &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;&lt;/li&gt;

  &lt;li&gt;Create a utility function CheckAndPrintContext() 
    &lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; CheckAndPrintContext(IContextManager icm)
{
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;null&lt;/span&gt; != icm) Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Context contains {0} elements&amp;quot;&lt;/span&gt;, icm.GetContext().Count);
    &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;null&lt;/span&gt; != icm)
    {
        &lt;span class="kwrd"&gt;if&lt;/span&gt; (icm.GetContext().Count &amp;gt; 0)
        {
            &lt;span class="kwrd"&gt;foreach&lt;/span&gt; (&lt;span class="kwrd"&gt;string&lt;/span&gt; xmlName &lt;span class="kwrd"&gt;in&lt;/span&gt; icm.GetContext().Keys)
            {
                Console.WriteLine(&lt;span class="str"&gt;&amp;quot;key : {0}&amp;quot;&lt;/span&gt;, xmlName);
                Console.WriteLine(&lt;span class="str"&gt;&amp;quot;value : {0}&amp;quot;&lt;/span&gt;, icm.GetContext()[xmlName]);
            }
        }
    }
}&lt;/pre&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;ul&gt;
  &lt;ul&gt;
    &lt;li&gt;The thing to note here is that we need to traverse the dictionary, since there could be more than one key in here, although there won't be in this sample. &lt;/li&gt;
  &lt;/ul&gt;

  &lt;li&gt;Now, let's run the three different bits of code, we want to first show the happy path, show how to break it, and then show how to explicitly manage the context token &lt;/li&gt;

  &lt;li&gt;
    &lt;h4&gt;Scenario 1: The Happy Path&lt;/h4&gt;

    &lt;div class="csharpcode"&gt;
      &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DemoOne()&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;{&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Press Enter to Send a Message and reuse proxy&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    &lt;span class="rem"&gt;// Console.ReadLine();&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    Debugger.Break();&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    IWorkflowClient iwc = &lt;span class="kwrd"&gt;new&lt;/span&gt; IWorkflowClient(&lt;span class="kwrd"&gt;new&lt;/span&gt; NetTcpContextBinding(),&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;        &lt;span class="kwrd"&gt;new&lt;/span&gt; EndpointAddress(&lt;span class="str"&gt;&amp;quot;net.tcp://localhost:10001/Intro1&amp;quot;&lt;/span&gt;));&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;    IContextManager icm = iwc.InnerChannel.GetProperty&amp;lt;IContextManager&amp;gt;();&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;null&lt;/span&gt; != icm) Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Context contains {0} elements&amp;quot;&lt;/span&gt;, icm.GetContext().Count);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    &lt;span class="kwrd"&gt;string&lt;/span&gt; s = iwc.Hello(&lt;span class="str"&gt;&amp;quot;message1&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;the service returned the message '{0}'&amp;quot;&lt;/span&gt;, s);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    CheckAndPrintContext(icm);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    s = iwc.Hello(&lt;span class="str"&gt;&amp;quot;message2&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    icm = iwc.InnerChannel.GetProperty&amp;lt;IContextManager&amp;gt;();&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;    CheckAndPrintContext(icm);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;the service returned the message '{0}'&amp;quot;&lt;/span&gt;, s);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Press Enter to Continue&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;}&lt;/pre&gt;
    &lt;/div&gt;
    &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

    &lt;ul&gt;
      &lt;li&gt;What's going on here? 
        &lt;ul&gt;
          &lt;li&gt;Line 5, a more convenient way in demos to hit a breakpoint &lt;/li&gt;

          &lt;li&gt;Line 10: Call the service &lt;/li&gt;

          &lt;li&gt;Line 12: CheckAndPrint the Context Token.&amp;#160; In this case, this will print the Guid of the initiated workflow that is contained in the token &lt;/li&gt;

          &lt;li&gt;Line 13: Call the service a second time 
            &lt;ul&gt;
              &lt;li&gt;Look at the service window, you'll see that this message has been routed to the same instance of the workflow. &lt;/li&gt;

              &lt;li&gt;You can also see in Line 16 that the second activities return message is included. &lt;/li&gt;
            &lt;/ul&gt;
          &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;h4&gt;Scenario 2: The Path Grows Darker&lt;/h4&gt;

    &lt;div class="csharpcode"&gt;
      &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="rem"&gt;// show this not working using a second client&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DemoTwo()&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;{&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Press Enter to Send a Message (it will break this time)&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    &lt;span class="rem"&gt;//Console.ReadLine();&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    Debugger.Break();&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;    IWorkflowClient iwc = &lt;span class="kwrd"&gt;new&lt;/span&gt; IWorkflowClient(&lt;span class="kwrd"&gt;new&lt;/span&gt; NetTcpContextBinding(),&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;        &lt;span class="kwrd"&gt;new&lt;/span&gt; EndpointAddress(&lt;span class="str"&gt;&amp;quot;net.tcp://localhost:10001/Intro1&amp;quot;&lt;/span&gt;));&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    IContextManager icm = iwc.InnerChannel.GetProperty&amp;lt;IContextManager&amp;gt;();&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;null&lt;/span&gt; != icm) Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Context contains {0} elements&amp;quot;&lt;/span&gt;, icm.GetContext().Count);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    &lt;span class="kwrd"&gt;string&lt;/span&gt; s = iwc.Hello(&lt;span class="str"&gt;&amp;quot;message1&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;the service returned the message '{0}'&amp;quot;&lt;/span&gt;, s);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    CheckAndPrintContext(icm);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    iwc = &lt;span class="kwrd"&gt;new&lt;/span&gt; IWorkflowClient(&lt;span class="kwrd"&gt;new&lt;/span&gt; NetTcpContextBinding(),&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;       &lt;span class="kwrd"&gt;new&lt;/span&gt; EndpointAddress(&lt;span class="str"&gt;&amp;quot;net.tcp://localhost:10001/Intro1&amp;quot;&lt;/span&gt;));&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;    s = iwc.Hello(&lt;span class="str"&gt;&amp;quot;message2&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;the service returned the message '{0}'&amp;quot;&lt;/span&gt;, s);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;    icm = iwc.InnerChannel.GetProperty&amp;lt;IContextManager&amp;gt;();&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;    CheckAndPrintContext(icm);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Press Enter to Continue&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;}&lt;/pre&gt;
    &lt;/div&gt;
    &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

    &lt;ul&gt;
      &lt;li&gt;What's going on here? (Same until line 14) 
        &lt;ul&gt;
          &lt;li&gt;Line 14: Let's create a new proxy.&amp;#160; &lt;/li&gt;

          &lt;li&gt;Line 15: Call the service using the new proxy.&amp;#160; You'll note on the server side that a second workflow instance has been created.&amp;#160; This is where we break. &lt;/li&gt;

          &lt;li&gt;Line 19: On the client side, you'll see that the second GUID being returned &lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;

  &lt;li&gt;
    &lt;h4&gt;Scenario 3: Finding the Light&lt;/h4&gt;

    &lt;div class="csharpcode"&gt;
      &lt;pre&gt;&lt;span class="lnum"&gt;   1:  &lt;/span&gt;&lt;span class="rem"&gt;// show this working with a second client by caching the context&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   2:  &lt;/span&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;static&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; DemoThree()&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   3:  &lt;/span&gt;{&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   4:  &lt;/span&gt;    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Press Enter to Send a Message (we'll cache the context and apply it to the new proxy)&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   5:  &lt;/span&gt;    &lt;span class="rem"&gt;// Console.ReadLine();&lt;/span&gt;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   6:  &lt;/span&gt;    Debugger.Break();&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   7:  &lt;/span&gt;    IWorkflowClient iwc = &lt;span class="kwrd"&gt;new&lt;/span&gt; IWorkflowClient(&lt;span class="kwrd"&gt;new&lt;/span&gt; NetTcpContextBinding(),&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   8:  &lt;/span&gt;        &lt;span class="kwrd"&gt;new&lt;/span&gt; EndpointAddress(&lt;span class="str"&gt;&amp;quot;net.tcp://localhost:10001/Intro1&amp;quot;&lt;/span&gt;));&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;   9:  &lt;/span&gt;    IContextManager icm = iwc.InnerChannel.GetProperty&amp;lt;IContextManager&amp;gt;();&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  10:  &lt;/span&gt;    &lt;span class="kwrd"&gt;if&lt;/span&gt; (&lt;span class="kwrd"&gt;null&lt;/span&gt; != icm) Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Context contains {0} elements&amp;quot;&lt;/span&gt;, icm.GetContext().Count);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  11:  &lt;/span&gt;    &lt;span class="kwrd"&gt;string&lt;/span&gt; s = iwc.Hello(&lt;span class="str"&gt;&amp;quot;message1&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  12:  &lt;/span&gt;    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;the service returned the message '{0}'&amp;quot;&lt;/span&gt;, s);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  13:  &lt;/span&gt;    CheckAndPrintContext(icm);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  14:  &lt;/span&gt;    IDictionary&amp;lt;&lt;span class="kwrd"&gt;string&lt;/span&gt;, &lt;span class="kwrd"&gt;string&lt;/span&gt;&amp;gt; context = icm.GetContext();&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  15:  &lt;/span&gt;    icm = &lt;span class="kwrd"&gt;null&lt;/span&gt;;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  16:  &lt;/span&gt;    iwc = &lt;span class="kwrd"&gt;new&lt;/span&gt; IWorkflowClient(&lt;span class="kwrd"&gt;new&lt;/span&gt; NetTcpContextBinding(),&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  17:  &lt;/span&gt;       &lt;span class="kwrd"&gt;new&lt;/span&gt; EndpointAddress(&lt;span class="str"&gt;&amp;quot;net.tcp://localhost:10001/Intro1&amp;quot;&lt;/span&gt;));&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  18:  &lt;/span&gt;    icm = iwc.InnerChannel.GetProperty&amp;lt;IContextManager&amp;gt;();&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  19:  &lt;/span&gt;    icm.SetContext(context);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  20:  &lt;/span&gt;    s = iwc.Hello(&lt;span class="str"&gt;&amp;quot;message2&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  21:  &lt;/span&gt;    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;the service returned the message '{0}'&amp;quot;&lt;/span&gt;, s);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  22:  &lt;/span&gt;    icm = iwc.InnerChannel.GetProperty&amp;lt;IContextManager&amp;gt;();&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  23:  &lt;/span&gt;    CheckAndPrintContext(icm);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  24:  &lt;/span&gt;    Console.WriteLine(&lt;span class="str"&gt;&amp;quot;Press Enter to Exit&amp;quot;&lt;/span&gt;);&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  25:  &lt;/span&gt;&amp;#160;&lt;/pre&gt;

      &lt;pre&gt;&lt;span class="lnum"&gt;  26:  &lt;/span&gt;}&lt;/pre&gt;
    &lt;/div&gt;
    &lt;style type="text/css"&gt;

.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;

    &lt;ul&gt;
      &lt;li&gt;Line 14 is where the magic happens, here' we grab the context token from the IContextManager.&amp;#160; &lt;/li&gt;

      &lt;li&gt;Line 19 is where the magic completes, we apply this token to the new proxy.&amp;#160; Note, this proxy could be running on different machine somewhere, but one I get the context token, I can use it to communicate with the same workflow instance that the first call did. &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So, what have we shown:&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;Manipulating context in workflow and imperative code 
    &lt;ul&gt;
      &lt;li&gt;How to extract the context token &lt;/li&gt;

      &lt;li&gt;How to explicitly set the context token &lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;

  &lt;li&gt;The caching behavior of the context channel (as seen in Scenario 1) &lt;/li&gt;

  &lt;li&gt;The behavior of the context channel to return the context token only on the activating message &lt;/li&gt;
&lt;/ul&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=8834527" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx">wf</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/presentations/default.aspx">presentations</category></item><item><title>Workflows that don't start with a Receive</title><link>http://blogs.msdn.com/mwinkle/archive/2008/01/17/workflows-that-don-t-start-with-a-receive.aspx</link><pubDate>Thu, 17 Jan 2008 22:13:56 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:7143004</guid><dc:creator>mwinkle</dc:creator><slash:comments>5</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/7143004.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=7143004</wfw:commentRss><description>&lt;p&gt;A question recently came up on an internal list about how to start a workflow to do some work and then have it accept a message via a Receive activity.&amp;#160; This led to an interesting discussion that provides some insight into how the WorkflowServiceHost instantiates workflows in conjunction with the ContextChannel.&lt;/p&gt;  &lt;h2&gt;Creating a Message Activated Workflow&lt;/h2&gt;  &lt;p&gt;By default, the WorkflowServiceHost will create a workflow when the following two conditions are true:&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;The message received is headed for an operation that is associated with a RecieveActivity that has the CanCreateInstance property set to true&lt;/li&gt;    &lt;li&gt;The message contains no context information&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;It is interesting to note that you don't even need to use a binding element collection that contains a ContextBindingElement.&amp;#160; The ContextBindingElement is responsible for creating the ContextChannel.&amp;#160; The job of the ContextChannel is to do two things on the Receive side&lt;/p&gt;  &lt;ul&gt;   &lt;li&gt;Extract the context information and pass that along up the stack (hand it off into the service model)&lt;/li&gt;    &lt;li&gt;On the creation, &lt;strong&gt;and only on the creation,&lt;/strong&gt; of a new instance, return the context information to the caller in the header of the response.&lt;/li&gt; &lt;/ul&gt;  &lt;p&gt;So, if we want to create workflows based on messages dropped into an MSMQ queue, we can do that by not trying to add the ContextBindingElement into a custom binding on top of the netMsmqBinding, and associating the operation with a Receive activity with the CanCreateInstance equaling true. Note, that any subsequent communication with the workflow will have to occur with a communication channel over which we can pass context.&lt;/p&gt;  &lt;h2&gt;Creating a Non-Message Activated Workflow&lt;/h2&gt;  &lt;p&gt;In the case that this post is about, we do not want to activate off an inbound message.&amp;#160; The way to do this doesn't require much additional work.&amp;#160; We first need to make sure we don't have any of our Receive activities marked with CanCreateInstance to true.&amp;#160; This means that no message coming in can activate the workflow.&amp;#160; Our workflow will then do some work prior to executing the Receive activity and waiting for the next message.&amp;#160; Our workflow will look like this (pretty simple)&lt;/p&gt;  &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WorkflowsthatdontstartwithaReceive_9DEA/image_2.png"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="328" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/WorkflowsthatdontstartwithaReceive_9DEA/image_thumb.png" width="224" border="0" /&gt;&lt;/a&gt;&amp;#160;&lt;/p&gt;  &lt;p&gt;When we want to start a workflow, we need to reach into the workflow service host and extract the workflow runtime and initiate the workflow:&lt;/p&gt;  &lt;pre class="csharpcode"&gt;WorkflowServiceHost myWorkflowServiceHost = &lt;span class="kwrd"&gt;new&lt;/span&gt; WorkflowServiceHost(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Workflow1), &lt;span class="kwrd"&gt;null&lt;/span&gt;);
&lt;span class="rem"&gt;// do some work to set up workflow service host&lt;/span&gt;
myWorkflowServiceHost.Open();
&lt;span class="rem"&gt;// on some reason to start the workflow&lt;/span&gt;
WorkflowRuntime wr = myWorkflowServiceHost.Description.Behaviors.Find&amp;lt;WorkflowRuntimeBehavior&amp;gt;().WorkflowRuntime;
WorkflowInstance wi = wr.CreateWorkflow(&lt;span class="kwrd"&gt;typeof&lt;/span&gt;(Workflow1));
wi.Start();
// need to send wi.InstanceId somewhere &lt;span class="kwrd"&gt;for&lt;/span&gt; others to communicate with it&lt;/pre&gt;
&lt;style type="text/css"&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }&lt;/style&gt;The last note is important.&amp;#160; In order for a client to eventually be able to communicate to the workflow, the workflow instance Id will need to be relayed to that client.&amp;#160; &lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=7143004" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx">wf</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category></item><item><title>Regarding Re-use of Context-aware Proxies</title><link>http://blogs.msdn.com/mwinkle/archive/2007/11/08/regarding-re-use-of-context-aware-proxies.aspx</link><pubDate>Thu, 08 Nov 2007 10:56:57 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:5980530</guid><dc:creator>mwinkle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/5980530.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=5980530</wfw:commentRss><description>&lt;p&gt;Yesterday, following my &amp;quot;What's the context for this conversation&amp;quot; presentation, I was approached with the following question:&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;I am sharing a singleton client that I want to use to interact with multiple workflow instances, how do I change the context for each of them.&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Completely unbeknownst to me, Wenlong, one of the product team's more prolific bloggers, addressed this very topic in his post &lt;a href="http://blogs.msdn.com/wenlong/archive/2007/11/08/how-to-use-a-singleton-wcf-proxy-to-call-different-workflow-service-instances-in-net-3-5.aspx"&gt;here&lt;/a&gt;, conveniently posted yesterday :-) &lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=5980530" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx">wf</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category></item><item><title>Recent WF Content Summary</title><link>http://blogs.msdn.com/mwinkle/archive/2007/09/11/recent-wf-content-summary.aspx</link><pubDate>Tue, 11 Sep 2007 03:11:06 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4857923</guid><dc:creator>mwinkle</dc:creator><slash:comments>6</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/4857923.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=4857923</wfw:commentRss><description>&lt;p&gt;I've been having some fun playing around with Visual Studio 2008 and the .NET Framework 3.5, and wanted to summarize some of the content I've put up on channel9 and other places.&lt;/p&gt; &lt;h2&gt;Samples&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;The &lt;a href="http://www.netfx3.com/files/folders/sampleservices/entry12188.aspx"&gt;Conversation Sample remixed&lt;/a&gt; -- if there is one sample in the SDK to help you understand what is going on with context passing and duplex messaging, this is &lt;a href="http://msdn2.microsoft.com/en-us/library/bb410775(VS.90).aspx"&gt;the sample&lt;/a&gt; that helped me learn it.&amp;nbsp; I had this sample reworked a little bit so that you don't have 5 console windows open.&lt;/li&gt; &lt;li&gt;&lt;a href="http://www.cloudsamples.net/HelpDesk/Default.aspx"&gt;Pageflow sample 1&lt;/a&gt;, live hosted -- watch this as pageflow is hosted "live" in the cloud.&amp;nbsp; This lets you interact with a pageflow as well as dive into the code using some tools my team has built.&lt;/li&gt; &lt;li&gt;&lt;a href="http://www.cloudsamples.net/RealState/Default.aspx"&gt;Pageflow sample 2&lt;/a&gt;, live hosted as above -- this is the sample that shows how we can leverage the &lt;a href="http://www.cloudsamples.net/ContextBar/SrcViewer/?name=RealState&amp;amp;f=Microsoft.Samples.Workflow.UI\Navigator.cs"&gt;navigator workflow&lt;/a&gt; type to be in multiple paths at the same time (a parallel state machine almost).&lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;Screencasts&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://channel9.msdn.com/Showpost.aspx?postid=338720"&gt;Intro demo&lt;/a&gt; -- a 10 minute walk through of building Workflow Services&lt;/li&gt; &lt;li&gt;&lt;a href="http://channel9.msdn.com/Showpost.aspx?postid=330489"&gt;0 to Workflow Service in 60 seconds&lt;/a&gt;&amp;nbsp; -- a very quick tools walkthrough&lt;/li&gt; &lt;li&gt;&lt;a href="http://channel9.msdn.com/Showpost.aspx?postid=331668 "&gt;Dynamically creating service contracts using Workflow Services in Net 3.5&lt;/a&gt;&amp;nbsp;-- the way to dynamically create a contract using a workflow first approach to building it.&lt;/li&gt; &lt;li&gt;&lt;a href="http://channel9.msdn.com/Showpost.aspx?postid=320225"&gt;BizTalk Server 2006 Extensions for WF&lt;/a&gt; -- A screencast from Jon Flanders walking through the &lt;a href="http://blogs.msdn.com/pandrew/archive/2007/06/27/no-biztalk-experience-required.aspx"&gt;work that has been done&lt;/a&gt; to host WF inside BizTalk.&lt;/li&gt; &lt;li&gt;&lt;a href="http://channel9.msdn.com/Showpost.aspx?postid=319489"&gt;Building WCF Services with WF&lt;/a&gt;&amp;nbsp; -- A screen recording with the PM responsible for the WF-WCF integration&lt;/li&gt; &lt;li&gt;&lt;a href="http://channel9.msdn.com/Showpost.aspx?postid=315811"&gt;Introduction to the Windows Workflow Foundation Pageflow Sample&lt;/a&gt; -- A screen recording with the dev responsible for building &lt;a href="http://blogs.msdn.com/mwinkle/archive/2007/06/07/introducing-the-pageflow-sample.aspx"&gt;pageflow&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt; &lt;h2&gt;&lt;a href="http://channel9.msdn.com/"&gt;Channel9&lt;/a&gt; Videos&lt;/h2&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://channel9.msdn.com/Showpost.aspx?postid=331668"&gt;Programming JSON with WCF in .NET Framework 3.5&lt;/a&gt; -- an interview with a Dev and PM from the WCF team talking about how and why talking JSON over WCF is interesting.&lt;/li&gt; &lt;li&gt;&lt;a href="http://channel9.msdn.com/Showpost.aspx?postid=335756"&gt;WF and WCF Integration In .NET Framework 3.5&lt;/a&gt; -- meet the team that brought us the Workflow Service features in .NET 3.5&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;In the upcoming months, we've got more samples and content coming out about these features.&amp;nbsp; If you've got questions, keep 'em coming.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4857923" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx">wf</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/Channel9/default.aspx">Channel9</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/screencasts/default.aspx">screencasts</category></item><item><title>Picture Services</title><link>http://blogs.msdn.com/mwinkle/archive/2007/08/30/picture-services.aspx</link><pubDate>Thu, 30 Aug 2007 02:27:17 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4635961</guid><dc:creator>mwinkle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/4635961.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=4635961</wfw:commentRss><description>&lt;p&gt;As Justin announces &lt;a href="http://blogs.msdn.com/justinjsmith/archive/2007/08/20/check-out-picture-services.aspx"&gt;here&lt;/a&gt;, my team recently released the picture services sample.&amp;nbsp; This is a cool way to expose the pictures on a machine that are found via Windows Desktop Search out in a simple, easy to consume REST endpoint.&lt;/p&gt; &lt;p&gt;There are a few things here that I think are pretty cool&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Pretty easily return POX and Syndication formatted data, and creating a URI hierarchy&amp;nbsp;(&lt;a href="http://www.cloudsamples.net/ContextBar/SrcViewer/?name=PictureServices&amp;amp;f=PictureSyndication\IPictureService.cs"&gt;here&lt;/a&gt;)&lt;/li&gt; &lt;li&gt;Querying Windows Desktop Search (&lt;a href="http://www.cloudsamples.net/ContextBar/SrcViewer/?name=PictureServices&amp;amp;f=PictureProvider\Providers\WdsPictureProvider.cs"&gt;here&lt;/a&gt;)&lt;/li&gt; &lt;li&gt;Adding Simple List Extensions (&lt;a href="http://www.cloudsamples.net/ContextBar/SrcViewer/?name=PictureServices&amp;amp;f=SyndicationExtensions\SimpleListExtensionHelper.cs"&gt;here&lt;/a&gt;)&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;Justin has a screencast &lt;a href="http://channel9.msdn.com/Showpost.aspx?postid=334896"&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4635961" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category></item><item><title>VS 2008 Beta 2 Shipped : 0 to Workflow Service in 60 seconds</title><link>http://blogs.msdn.com/mwinkle/archive/2007/07/30/vs-2008-beta-2-shipped-0-to-workflow-service-in-60-seconds.aspx</link><pubDate>Mon, 30 Jul 2007 23:03:19 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:4135568</guid><dc:creator>mwinkle</dc:creator><slash:comments>2</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/4135568.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=4135568</wfw:commentRss><description>&lt;p&gt;So, per &lt;a href="http://blogs.msdn.com/somasegar/archive/2007/07/26/announcing-the-release-of-visual-studio-2008-beta-2-net-fx-3-5-beta-2-and-silverlight-1-0-rc.aspx"&gt;Soma's blog&lt;/a&gt;, this &lt;a href="http://channel9.msdn.com/Showpost.aspx?postid=329443"&gt;great Channel9 video&lt;/a&gt;, and a bunch of other places, VS 2008 Beta 2 is available for download (&lt;a href="http://msdn2.microsoft.com/en-us/vstudio/aa700831.aspx"&gt;go here&lt;/a&gt;).&lt;/p&gt; &lt;p&gt;Others are covering their favorite feature in depth, I want to cover one of mine: the WCF test client, which I will show by way of creating a Workflow Service application.&lt;/p&gt; &lt;p&gt;Real quick, for those of you who didn't read the readme file, I know sometimes you just forget, there is an important note regarding how to get&amp;nbsp; this to work (out of the box you will probably get an exception in svcutil.exe).&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;b&gt;&lt;em&gt;Running a WCF Service Library results in svcutil.exe crashing and the test form not working&lt;/em&gt;&lt;/b&gt; &lt;p&gt;&lt;em&gt;Running a WCF Service Library starts the service in WcfSvcHost and opens a test form to debug operations on the service.&amp;nbsp; On the Beta2 build this results in crash of svcutil.exe and the test form doesn’t work due to a signing problem.&lt;/em&gt; &lt;p&gt;&lt;b&gt;&lt;em&gt;To resolve this issue &lt;/em&gt;&lt;/b&gt; &lt;p&gt;&lt;em&gt;Disable strong name signing for svcutil.exe by opening a Visual Studio 2008 Beta2 Command Prompt. At the command prompt run: &lt;strong&gt;sn –Vr “&amp;lt;program files&amp;gt;\Microsoft SDKs\Windows\v6.0A\Bin\SvcUtil.exe”&lt;/strong&gt;&amp;nbsp; (replace &amp;lt;program files&amp;gt; with your program files path – ex: c:\Program Files)&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Fire up VS 2008, create a new Sequential Workflow Service Library project:&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image.png" atomicselection="true"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="383" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_thumb.png" width="541" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;This creates a basic Sequential workflow with a Receive activity&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_2.png" atomicselection="true"&gt;&lt;img style="border-right: 0px; border-top: 0px; border-left: 0px; border-bottom: 0px" height="240" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_thumb_2.png" width="215" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;It also creates an app.config and IWorkflow1.cs&lt;/p&gt; &lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_3.png" atomicselection="true"&gt;&lt;img height="128" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_thumb_3.png" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt; &lt;p&gt;IWorkflow1.cs contains the contract our service is going to implement:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;using&lt;/span&gt; System;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Collections.Generic;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Linq;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.Text;
&lt;span class="kwrd"&gt;using&lt;/span&gt; System.ServiceModel;

&lt;span class="kwrd"&gt;namespace&lt;/span&gt; WFServiceLibrary1
{
    &lt;span class="rem"&gt;// NOTE: If you change the interface name "IWorkflow1" here, &lt;/span&gt;
    &lt;span class="rem"&gt;// you must also update the reference to "IWorkflow1" in App.config.&lt;/span&gt;
    [ServiceContract]
    &lt;span class="kwrd"&gt;public&lt;/span&gt; &lt;span class="kwrd"&gt;interface&lt;/span&gt; IWorkflow1
    {
        [OperationContract]
        &lt;span class="kwrd"&gt;string&lt;/span&gt; Hello(&lt;span class="kwrd"&gt;string&lt;/span&gt; message);
    }
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Now, we can modify this as needed, or we can delete it and create the contract as part of the Receive activity, see my previous post &lt;a href="http://blogs.msdn.com/mwinkle/archive/2007/04/27/dynamically-generating-an-operation-contract-in-orcas.aspx"&gt;here&lt;/a&gt; on the topic.&lt;/p&gt;
&lt;p&gt;Return to the workflow and take a quick look at the properties of the Receive activity, and note that the parameters for the method (message and (returnValue)) have already been promoted and bound as properties on the workflow, that saves us a quick step or two:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_4.png" atomicselection="true"&gt;&lt;img height="282" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_thumb_4.png" width="355" border="0"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Drop a code activity in the Receive shape, and double click to enter some code:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_5.png" atomicselection="true"&gt;&lt;img height="166" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_thumb_5.png" width="214" border="0"&gt;&lt;/a&gt; &lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;private&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; codeActivity1_ExecuteCode(&lt;span class="kwrd"&gt;object&lt;/span&gt; sender, EventArgs e)
{
    returnValue = String.Format(&lt;span class="str"&gt;"You entered '{0}'."&lt;/span&gt;, inputMessage);
}&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;Now, we're pretty much there, but let's take a quick look at the app.config&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;service&lt;/span&gt; &lt;span class="attr"&gt;name&lt;/span&gt;&lt;span class="kwrd"&gt;="WFServiceLibrary1.Workflow1"&lt;/span&gt; &lt;span class="attr"&gt;behaviorConfiguration&lt;/span&gt;&lt;span class="kwrd"&gt;="WFServiceLibrary1.Workflow1Behavior"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;host&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;baseAddresses&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;add&lt;/span&gt; &lt;span class="attr"&gt;baseAddress&lt;/span&gt;&lt;span class="kwrd"&gt;="http://localhost:8080/Workflow1"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;baseAddresses&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;host&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;endpoint&lt;/span&gt; &lt;span class="attr"&gt;address&lt;/span&gt;&lt;span class="kwrd"&gt;=""&lt;/span&gt;
            &lt;span class="attr"&gt;binding&lt;/span&gt;&lt;span class="kwrd"&gt;="wsHttpContextBinding"&lt;/span&gt;
            &lt;span class="attr"&gt;contract&lt;/span&gt;&lt;span class="kwrd"&gt;="WFServiceLibrary1.IWorkflow1"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;endpoint&lt;/span&gt; &lt;span class="attr"&gt;address&lt;/span&gt;&lt;span class="kwrd"&gt;="mex"&lt;/span&gt; 
            &lt;span class="attr"&gt;binding&lt;/span&gt;&lt;span class="kwrd"&gt;="mexHttpBinding"&lt;/span&gt; 
            &lt;span class="attr"&gt;contract&lt;/span&gt;&lt;span class="kwrd"&gt;="IMetadataExchange"&lt;/span&gt; &lt;span class="kwrd"&gt;/&amp;gt;&lt;/span&gt;
&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;service&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;We're going to use the wsHttpContextBinding, which you can think of as the standard wsHttpBinding with the addition of the Context channel to the channel stack.&amp;nbsp; Also note, we can right click the config and open it in the WCF config editor, slick!&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_6.png" atomicselection="true"&gt;&lt;img height="248" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_thumb_6.png" width="308" border="0"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Let's hit F5.&amp;nbsp; We build, do a little bit of processing and up pops the WCF test client.&amp;nbsp; You may also note this little pop up from your task tray:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_7.png" atomicselection="true"&gt;&lt;img height="103" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_thumb_7.png" width="240" border="0"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;What's this, the "autohosting" of your service, just like you get with ASP.NET on a machine.&amp;nbsp; This saves me the trouble of having to write a host as well as my service when I just want to play around a bit.&amp;nbsp; The test client looks like this:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_8.png" atomicselection="true"&gt;&lt;img height="388" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_thumb_8.png" width="590" border="0"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Double click on the hello operation and fill in a message to send to the service:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_9.png" atomicselection="true"&gt;&lt;img height="231" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_thumb_9.png" width="460" border="0"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Clicking "Invoke" will invoke the service, which will soon return with the value we hope to see.&amp;nbsp; Sure enough, after a bit of chugging along, this returns:&lt;/p&gt;
&lt;p&gt;&lt;a href="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_10.png" atomicselection="true"&gt;&lt;img height="227" alt="image" src="http://blogs.msdn.com/blogfiles/mwinkle/WindowsLiveWriter/VS2008Beta2Shipped0toWorkflowServicein60_B73F/image_thumb_10.png" width="475" border="0"&gt;&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Finally, let's hit the XML tab to see what's in there, and we see it is the full XML of the request and the response.&amp;nbsp; There's an interesting little tidbit in the header of the response:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;s:Envelope&lt;/span&gt; &lt;span class="attr"&gt;xmlns:s&lt;/span&gt;&lt;span class="kwrd"&gt;="http://www.w3.org/2003/05/soap-envelope"&lt;/span&gt; 
&lt;span class="attr"&gt;xmlns:a&lt;/span&gt;&lt;span class="kwrd"&gt;="http://www.w3.org/2005/08/addressing"&lt;/span&gt; 
&lt;span class="attr"&gt;xmlns:u&lt;/span&gt;&lt;span class="kwrd"&gt;="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;s:Header&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;a:Action&lt;/span&gt; &lt;span class="attr"&gt;s:mustUnderstand&lt;/span&gt;&lt;span class="kwrd"&gt;="1"&lt;/span&gt; &lt;span class="attr"&gt;u:Id&lt;/span&gt;&lt;span class="kwrd"&gt;="_2"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
       http://tempuri.org/IWorkflow1/HelloResponse
     &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;a:Action&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;a:RelatesTo&lt;/span&gt; &lt;span class="attr"&gt;u:Id&lt;/span&gt;&lt;span class="kwrd"&gt;="_3"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;urn:uuid:3f5b7eb5-cc35-4b01-b345-92f6edf728d7&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;a:RelatesTo&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;Context&lt;/span&gt; &lt;span class="attr"&gt;u:Id&lt;/span&gt;&lt;span class="kwrd"&gt;="_4"&lt;/span&gt; &lt;span class="attr"&gt;xmlns&lt;/span&gt;&lt;span class="kwrd"&gt;="http://schemas.microsoft.com/ws/2006/05/context"&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="kwrd"&gt;&amp;lt;&lt;/span&gt;&lt;span class="html"&gt;InstanceId&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;fc0f47fd-dd7b-4030-9883-acbf358583c3&lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;InstanceId&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="kwrd"&gt;&amp;lt;/&lt;/span&gt;&lt;span class="html"&gt;Context&lt;/span&gt;&lt;span class="kwrd"&gt;&amp;gt;&lt;/span&gt;&lt;/pre&gt;
&lt;style type="text/css"&gt;.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }
&lt;/style&gt;

&lt;p&gt;This is the context token that lets me know how to continue conversing with this workflow.&amp;nbsp; In the test client, I can't find a way to attach it to a subsequent request, meaning we can't use the test client for testing multiple steps through a workflow, but this new feature lets me get up and running, verify connectivity, and be able to set breakpoints and debug my workflow service, which is pretty cool.&lt;/p&gt;
&lt;p&gt;I've posted the following video on &lt;a href="http://channel9.msdn.com/ShowPost.aspx?PostID=330489"&gt;c9 as a screencast&lt;/a&gt;, which I will try to do with my subsequent blog postings.&lt;/p&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=4135568" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx">wf</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category></item><item><title>Orcas Beta 1 Samples (WF, WCF)</title><link>http://blogs.msdn.com/mwinkle/archive/2007/04/27/orcas-beta-1-samples-wf-wcf.aspx</link><pubDate>Fri, 27 Apr 2007 22:17:42 GMT</pubDate><guid isPermaLink="false">91d46819-8472-40ad-a661-2c78acb4018c:2302344</guid><dc:creator>mwinkle</dc:creator><slash:comments>1</slash:comments><comments>http://blogs.msdn.com/mwinkle/comments/2302344.aspx</comments><wfw:commentRss>http://blogs.msdn.com/mwinkle/commentrss.aspx?PostID=2302344</wfw:commentRss><description>&lt;p&gt;Beta 1 samples have been posted.&amp;nbsp; In this release there are separate installs for WF and WCF (and the workflow services are in the WCF one, go figure!)&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/ms752239(VS.90).aspx"&gt;WCF (and WF Services) Samples&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/ms742187(VS.90).aspx"&gt;WF Samples&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;From Laurence's &lt;a href="http://blogs.msdn.com/melloula/archive/2007/04/24/wcf-and-wf-samples-for-orcas-beta1-are-available-on-msdn.aspx"&gt;blog&lt;/a&gt;:&lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;&lt;em&gt;This is the only version of the new samples that works at this time.&amp;nbsp;The version that comes&amp;nbsp;with the VS Orcas Beta1 offline Help does not work.&lt;/em&gt;  &lt;p&gt;&lt;em&gt;New samples in this release:&lt;/em&gt;  &lt;p&gt;&lt;em&gt;WF Samples\Technologies\Rules And Conditions\Order Processing Policy&lt;/em&gt;  &lt;p&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WCF Technology Samples\Basic\Ajax&lt;/em&gt;  &lt;p&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WCF Technology Samples\Basic\Syndication&lt;/em&gt;  &lt;p&gt;&lt;em&gt;WCF Technology Samples\Basic\WorkflowServices&lt;/em&gt;  &lt;p&gt;&lt;em&gt;You can download the zip files through any of the samples. &lt;/em&gt; &lt;p&gt;&lt;em&gt;To setup and run the Orcas Beta1 samples:&lt;/em&gt;  &lt;p&gt;&lt;em&gt;1. Setup:&lt;/em&gt;  &lt;p&gt;&lt;em&gt;a. Check out the &lt;/em&gt;&lt;a href="http://msdn2.microsoft.com/en-us/library/bb410779(VS.90).aspx"&gt;&lt;em&gt;Setup Instructions for the Ajax, Syndication, and Workflow Services samples&lt;/em&gt;&lt;/a&gt;&lt;em&gt;.&lt;/em&gt;  &lt;p&gt;&lt;em&gt;i. Use the Setup scripts under the “OrcasSetup” dir in the downloaded WCF zip file. In contrast, the “Setup” dir includes the scripts necessary for the samples already released with WCF 3.0&lt;/em&gt;  &lt;p&gt;&lt;em&gt;b. On Win2K3, if you see a plain text page when connecting to &lt;/em&gt;&lt;a href="http://localhost/NetFx35Samples/service.svc"&gt;&lt;em&gt;http://localhost/NetFx35Samples/service.svc&lt;/em&gt;&lt;/a&gt;&lt;em&gt;, you need to run:&lt;/em&gt;  &lt;p&gt;&lt;em&gt;“%SystemDrive%\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe” -i –enable&lt;/em&gt;  &lt;p&gt;&lt;em&gt;"%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -i&lt;/em&gt;  &lt;p&gt;&lt;em&gt;c. The WCF Samples setup script Setupvroot.bat will not run unless MSMQ is installed or the NetMsmqActivator service is disabled&lt;/em&gt;  &lt;p&gt;&lt;em&gt;2. Ajax samples:&lt;/em&gt;  &lt;p&gt;&lt;em&gt;a. For the Simple and Post Ajax service samples, you will need to completely refresh your session to be able to reload ClientPage.htm from one service to another as there is an issue with IE. Or simply rename ClientPage.htm in one of the samples&lt;/em&gt;  &lt;p&gt;&lt;em&gt;3. &amp;nbsp;Workflow Services:&lt;/em&gt;  &lt;p&gt;&lt;em&gt;a. WorkflowServiceUtility is a&amp;nbsp;reference necessary to the CalculatorClient and DuplexWorkflowServices samples&lt;/em&gt;  &lt;p&gt;&lt;em&gt;b. CalculatorClient is the client for both DurableService and StateMachineWorkflowService. Click on “C” to stop the session (it becomes red) before switching services&lt;/em&gt;  &lt;p&gt;&lt;em&gt;c. The Conversations client is the window that has “Press enter to submit order”&lt;/em&gt;  &lt;p&gt;&lt;em&gt;d. In DuplexWorkflowServices, only the ServiceHost and ClientHost projects need to be started&lt;/em&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;div class="wlWriterSmartContent" id="0767317B-992E-4b12-91E0-4F059A8CECA8:8acbbcef-f9f9-4a51-86a1-250b99a7368c" contenteditable="false" style="padding-right: 0px; display: inline; padding-left: 0px; padding-bottom: 0px; margin: 0px; padding-top: 0px"&gt;Technorati Tags: &lt;a href="http://technorati.com/tags/orcas" rel="tag"&gt;orcas&lt;/a&gt;, &lt;a href="http://technorati.com/tags/wf" rel="tag"&gt;wf&lt;/a&gt;, &lt;a href="http://technorati.com/tags/wcf" rel="tag"&gt;wcf&lt;/a&gt;, &lt;a href="http://technorati.com/tags/samples" rel="tag"&gt;samples&lt;/a&gt;&lt;/div&gt;&lt;img src="http://blogs.msdn.com/aggbug.aspx?PostID=2302344" width="1" height="1"&gt;</description><category domain="http://blogs.msdn.com/mwinkle/archive/tags/wf/default.aspx">wf</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/Orcas/default.aspx">Orcas</category><category domain="http://blogs.msdn.com/mwinkle/archive/tags/WCF/default.aspx">WCF</category></item></channel></rss>