<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" version="2.0">
  <channel>
    <title>Softwaremaker - Windows Workflow Foundation (WF)</title>
    <link>http://www.softwaremaker.net/blog/</link>
    <description>&lt;Challenging Conventions /&gt;</description>
    <language>en-us</language>
    <copyright>William T</copyright>
    <lastBuildDate>Thu, 12 Nov 2009 10:07:56 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.9.6264.0</generator>
    <managingEditor>itnews@softwaremaker.net</managingEditor>
    <webMaster>itnews@softwaremaker.net</webMaster>
    <item>
      <trackback:ping>http://www.softwaremaker.net/blog/Trackback.aspx?guid=da04beac-4557-4f52-8af8-d76c167762e2</trackback:ping>
      <pingback:server>http://www.softwaremaker.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.softwaremaker.net/blog/PermaLink,guid,da04beac-4557-4f52-8af8-d76c167762e2.aspx</pingback:target>
      <dc:creator>William Tay</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Q: There is a <a href="http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx" target="_blank">Windows
Workflow Foundation (WF)</a><font color="#000000" size="3" face="Calibri">workflow
service which contains only one pair of Receive and SendReply. Data will be sent through
the Receive activity and how do I get the workflow service to return the
GUID of the workflow instance in SendReply activity.</font></p>
        <p>
          <font color="#000000" size="3" face="Calibri">A: Write a custom activity to retrieve
it (See below). Bind that to a variable and bind that variable to the SendReply.Content</font>
        </p>
        <p>
          <font color="#808080">
            <strong>
              <em>    public sealed class GetWorkflowInstanceId
: CodeActivity&lt;Guid&gt;<br />
    {<br />
        protected override Guid Execute(CodeActivityContext
context)<br />
        {<br />
            return context.WorkflowInstanceId;<br />
        }<br />
    }</em>
            </strong>
          </font>
        </p>
        <img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=da04beac-4557-4f52-8af8-d76c167762e2" />
        <br />
        <hr />
© William Tay 2012 | Swinging Technologist 
<br /><a href="http://www.softwaremaker.net/blog">http://www.softwaremaker.net/blog</a></body>
      <title>Retrieving GUID of a WF Workflow Service</title>
      <guid isPermaLink="false">http://www.softwaremaker.net/blog/PermaLink,guid,da04beac-4557-4f52-8af8-d76c167762e2.aspx</guid>
      <link>http://www.softwaremaker.net/blog/RetrievingGUIDOfAWFWorkflowService.aspx</link>
      <pubDate>Thu, 12 Nov 2009 10:07:56 GMT</pubDate>
      <description>&lt;p&gt;
Q:&amp;nbsp;There is a &lt;a href=http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx target=_blank&gt;Windows
Workflow Foundation (WF)&lt;/a&gt; &lt;font color=#000000 size=3 face=Calibri&gt;workflow service
which contains only one pair of Receive and SendReply. Data will be sent through the
Receive activity and&amp;nbsp;how do I get the&amp;nbsp;workflow service to return the GUID
of the workflow instance in SendReply activity.&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#000000 size=3 face=Calibri&gt;A: Write a custom activity to retrieve it
(See below). Bind that to a variable and bind that variable to the SendReply.Content&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#808080&gt;&lt;strong&gt;&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public sealed class GetWorkflowInstanceId
: CodeActivity&amp;lt;Guid&amp;gt;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; protected override Guid Execute(CodeActivityContext
context)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return context.WorkflowInstanceId;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/em&gt;&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=da04beac-4557-4f52-8af8-d76c167762e2" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
© William Tay 2012 | Swinging Technologist 
&lt;br /&gt;
&lt;a href="http://www.softwaremaker.net/blog"&gt;http://www.softwaremaker.net/blog&lt;/a&gt;</description>
      <category>.NET;Windows Workflow Foundation (WF)</category>
    </item>
    <item>
      <trackback:ping>http://www.softwaremaker.net/blog/Trackback.aspx?guid=a6f055b0-1b64-4d90-bf00-7e9ffd1b4dc5</trackback:ping>
      <pingback:server>http://www.softwaremaker.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.softwaremaker.net/blog/PermaLink,guid,a6f055b0-1b64-4d90-bf00-7e9ffd1b4dc5.aspx</pingback:target>
      <dc:creator>William Tay</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I remember back in 2005/2006 when I was still touring the APAC circuits such as <a href="http://www.softwaremaker.net/blog/IndigoAscendInAsiaPacific.aspx" target="_blank">Sydney
(Australia)</a> and <a href="http://www.softwaremaker.net/blog/GettingDownAndDirtyWithWFAndWCFInKualaLumpur.aspx" target="_blank">Kuala
Lumpur (Malaysia)</a> doing training and consulting gigs for customers, partners about <a href="http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx" target="_blank">Windows
Workflow Foundation (WF)</a> and <a href="http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx" target="_blank">Windows
Communication Foundation (WCF, previously - Indigo)</a> and some of the initial Windows
Workflow questions came up regarding the use of <a href="http://wiki.windowsworkflowfoundation.eu/default.aspx/WF/ParallelActivity.html" target="_blank">Parallel
Activities</a>. It came as a surprise to many people that parallel activities
are not independently asynchronous.
</p>
        <p>
I explained that a WF instance gets only one instance from the runtime. There are
reasons for this single-threaded execution model so each activity have to work with
this single thread efficiently. There are ways to spin off differents thread when <em>real</em> parallelism
activities are reqquired but because documentation was scare at that time, I had some
trouble articulating how to do so.
</p>
        <p>
I just read "<a href="http://msdn2.microsoft.com/en-us/library/bb887609.aspx" target="_blank">Multithreaded
Parallelism in Windows Workflow Foundation</a>" on MSDN and while it is a
definite deep technical article, if you can grok it, you will understand how "MultiThreaded
Parallelism" can be done in WF using both the (rather hard-to-use) "<a href="http://wiki.windowsworkflowfoundation.eu/default.aspx/WF/CallExternalMethodActivity.html" target="_blank">Call
External Method Activity (CEMA)</a>" and the "<a href="http://wiki.windowsworkflowfoundation.eu/default.aspx/WF/HandleExternalEventActivity.html" target="_blank">Handle
External Event Activity (HEMA)</a>". Not only that, the authors (whom actually implemented
such a system for their own use) also shared how to pair those 2 activities
up using correlation and how to create wrappers aoround them so that it can be reused
and therefore "<em>not require talented software developer use of call-external-method
and handle-external-event activities along with the CLR thread-pool</em>"
</p>
        <p>
A <a href="http://msdn2.microsoft.com/en-us/library/bb887609.aspx" target="_blank">gem
of a read</a>.
</p>
        <img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=a6f055b0-1b64-4d90-bf00-7e9ffd1b4dc5" />
        <br />
        <hr />
© William Tay 2012 | Swinging Technologist 
<br /><a href="http://www.softwaremaker.net/blog">http://www.softwaremaker.net/blog</a></body>
      <title>Windows Workflow Foundation: MultiThreaded Parallelism</title>
      <guid isPermaLink="false">http://www.softwaremaker.net/blog/PermaLink,guid,a6f055b0-1b64-4d90-bf00-7e9ffd1b4dc5.aspx</guid>
      <link>http://www.softwaremaker.net/blog/WindowsWorkflowFoundationMultiThreadedParallelism.aspx</link>
      <pubDate>Mon, 25 Feb 2008 08:44:37 GMT</pubDate>
      <description>&lt;p&gt;
I remember back in 2005/2006 when I was still touring the APAC circuits such as &lt;a href="http://www.softwaremaker.net/blog/IndigoAscendInAsiaPacific.aspx" target=_blank&gt;Sydney
(Australia)&lt;/a&gt; and &lt;a href="http://www.softwaremaker.net/blog/GettingDownAndDirtyWithWFAndWCFInKualaLumpur.aspx" target=_blank&gt;Kuala
Lumpur (Malaysia)&lt;/a&gt; doing training and consulting gigs for customers, partners about &lt;a href=http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx target=_blank&gt;Windows
Workflow Foundation (WF)&lt;/a&gt; and &lt;a href=http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx target=_blank&gt;Windows
Communication Foundation (WCF, previously - Indigo)&lt;/a&gt; and some of the initial Windows
Workflow questions came up regarding the use of &lt;a href="http://wiki.windowsworkflowfoundation.eu/default.aspx/WF/ParallelActivity.html" target=_blank&gt;Parallel
Activities&lt;/a&gt;. It came&amp;nbsp;as a surprise to many people that parallel activities
are not independently asynchronous.
&lt;/p&gt;
&lt;p&gt;
I explained that a WF instance gets only one instance from the runtime. There are
reasons for this single-threaded execution model so each activity have to work with
this single thread efficiently. There are ways to spin off differents thread&amp;nbsp;when &lt;em&gt;real&lt;/em&gt; parallelism
activities are reqquired but because documentation was scare at that time, I had some
trouble articulating how to do so.
&lt;/p&gt;
&lt;p&gt;
I just read&amp;nbsp;"&lt;a href="http://msdn2.microsoft.com/en-us/library/bb887609.aspx" target=_blank&gt;Multithreaded
Parallelism in Windows Workflow Foundation&lt;/a&gt;"&amp;nbsp;on MSDN and while it is&amp;nbsp;a
definite deep technical article, if you can grok it, you will understand how&amp;nbsp;"MultiThreaded
Parallelism" can be done in WF using both the (rather hard-to-use) "&lt;a href="http://wiki.windowsworkflowfoundation.eu/default.aspx/WF/CallExternalMethodActivity.html" target=_blank&gt;Call
External Method Activity (CEMA)&lt;/a&gt;" and the "&lt;a href="http://wiki.windowsworkflowfoundation.eu/default.aspx/WF/HandleExternalEventActivity.html" target=_blank&gt;Handle
External Event Activity (HEMA)&lt;/a&gt;". Not only that, the authors (whom actually implemented
such a system for their own use) also shared how&amp;nbsp;to pair&amp;nbsp;those 2 activities
up using correlation and how to create wrappers aoround them so that it can be reused
and therefore "&lt;em&gt;not require talented software developer use of call-external-method
and handle-external-event activities along with the CLR thread-pool&lt;/em&gt;"
&lt;/p&gt;
&lt;p&gt;
A &lt;a href="http://msdn2.microsoft.com/en-us/library/bb887609.aspx" target=_blank&gt;gem
of a read&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=a6f055b0-1b64-4d90-bf00-7e9ffd1b4dc5" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
© William Tay 2012 | Swinging Technologist 
&lt;br /&gt;
&lt;a href="http://www.softwaremaker.net/blog"&gt;http://www.softwaremaker.net/blog&lt;/a&gt;</description>
      <category>.NET;Windows Workflow Foundation (WF)</category>
    </item>
    <item>
      <trackback:ping>http://www.softwaremaker.net/blog/Trackback.aspx?guid=142f6508-357f-483c-bd3c-be004ad9791d</trackback:ping>
      <pingback:server>http://www.softwaremaker.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.softwaremaker.net/blog/PermaLink,guid,142f6508-357f-483c-bd3c-be004ad9791d.aspx</pingback:target>
      <dc:creator>William Tay</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have been involved in a couple of pretty good competitive bids in some public
tenders recently and am thoroughly enjoying it. I have come head-to-head with the
usual suspects of heavy hitters in the areas of collaboration, SOA / ESB and portal
plays such as IBM, Oracle and the likes.
</p>
        <p>
On another related note: Since I am in the compete space recently, I have been
keeping watch on what is coming out of the <a href="http://www.oasis-open.org/committees/wsbpel" target="_blank">standards
body</a> and I think that <a href="http://www.oasis-open.org/committees/download.php/22036/wsbpel-specification-draft%20candidate%20CD%20Jan%2025%2007.pdf" target="_blank">WS-BPEL</a> (which
was <a href="http://msdn2.microsoft.com/en-us/library/aa479359.aspx" target="_blank">BPEL4WS</a> ...)
should have their specifications ready by next month (March 2007). Having said that,
one of the points that will make Microsoft a even stronger challenger in the enterprise
space is what I believe will come out of the pipelines next month is that the next
version of <a href="http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx" target="_blank">Windows
Workflow Foundation (WF)</a> (CTP) will support <a href="http://en.wikipedia.org/wiki/BPEL" target="_blank">BPEL</a> 1.1.
</p>
        <p>
Moving forward, I believe that the v.Next of <a href="http://msdn2.microsoft.com/en-us/vstudio/aa700830.aspx" target="_blank">Orcas</a> will
support BPEL 2.0 as well as BPEL 1.1 and that will be very important in the BizTalk
roadmap as well.
</p>
        <img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=142f6508-357f-483c-bd3c-be004ad9791d" />
        <br />
        <hr />
© William Tay 2012 | Swinging Technologist 
<br /><a href="http://www.softwaremaker.net/blog">http://www.softwaremaker.net/blog</a></body>
      <title>[Stay Tuned]: BPEL, Windows Worflow Foundation and BizTalk</title>
      <guid isPermaLink="false">http://www.softwaremaker.net/blog/PermaLink,guid,142f6508-357f-483c-bd3c-be004ad9791d.aspx</guid>
      <link>http://www.softwaremaker.net/blog/StayTunedBPELWindowsWorflowFoundationAndBizTalk.aspx</link>
      <pubDate>Fri, 09 Feb 2007 02:47:07 GMT</pubDate>
      <description>&lt;p&gt;
I have been involved&amp;nbsp;in a couple of pretty good competitive bids in some public
tenders recently and am thoroughly enjoying it. I have come head-to-head with the
usual suspects of heavy hitters in the areas of collaboration, SOA / ESB and portal
plays such as IBM, Oracle and the likes.
&lt;/p&gt;
&lt;p&gt;
On another related note: Since I&amp;nbsp;am in the compete space recently, I have been
keeping watch on what is coming out of the &lt;a href="http://www.oasis-open.org/committees/wsbpel" target=_blank&gt;standards
body&lt;/a&gt; and I think that &lt;a href="http://www.oasis-open.org/committees/download.php/22036/wsbpel-specification-draft%20candidate%20CD%20Jan%2025%2007.pdf" target=_blank&gt;WS-BPEL&lt;/a&gt; (which
was &lt;a href="http://msdn2.microsoft.com/en-us/library/aa479359.aspx" target=_blank&gt;BPEL4WS&lt;/a&gt;&amp;nbsp;...)
should have their specifications ready by next month (March 2007). Having said that,
one of the points that will make Microsoft a even stronger challenger in the enterprise
space is what I believe will come out of the pipelines next month is that the next
version of&amp;nbsp;&lt;a href=http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx target=_blank&gt;Windows
Workflow Foundation (WF)&lt;/a&gt; (CTP) will support &lt;a href="http://en.wikipedia.org/wiki/BPEL" target=_blank&gt;BPEL&lt;/a&gt; 1.1.
&lt;/p&gt;
&lt;p&gt;
Moving forward, I believe that the v.Next of &lt;a href="http://msdn2.microsoft.com/en-us/vstudio/aa700830.aspx" target=_blank&gt;Orcas&lt;/a&gt; will
support BPEL 2.0 as well as BPEL 1.1 and that will be very important in the BizTalk
roadmap as well.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=142f6508-357f-483c-bd3c-be004ad9791d" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
© William Tay 2012 | Swinging Technologist 
&lt;br /&gt;
&lt;a href="http://www.softwaremaker.net/blog"&gt;http://www.softwaremaker.net/blog&lt;/a&gt;</description>
      <category>Service-Orientation;Windows Workflow Foundation (WF)</category>
    </item>
    <item>
      <trackback:ping>http://www.softwaremaker.net/blog/Trackback.aspx?guid=283caaa9-2f3a-4a70-9e6b-a23312ff32e9</trackback:ping>
      <pingback:server>http://www.softwaremaker.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.softwaremaker.net/blog/PermaLink,guid,283caaa9-2f3a-4a70-9e6b-a23312ff32e9.aspx</pingback:target>
      <dc:creator>William Tay</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I dont think the world has seen so much emphasis on a feature of product
even before pre-launched. In this context, I am talking about <a href="http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx" target="_blank">Windows
Workflow Foundation (WF)</a> and the emphasis on a <em>non</em>-feature, actually
- that it is a non-product and it doesnt come with <strike>batteries</strike> host
included.
</p>
        <p>
Windows Workflow consists of an activity library and a framework, a runtime engine,
and a runtime services components. Most of these will work out-of-the-box and some
of them comes with extensibility mechanisms which you can further enhance or customize
on.
</p>
        <p>
All of those must run within a host application process - <strong><em>which you have
to build</em></strong>.
</p>
        <p>
In other words, Windows Workflow is just a framework with managed APIs and not a designed
as a product. It would be a lot of work to build your own host, which is why I wouldnt
recommend it. You can implement workflows in existing hosts such as <a href="http://www.microsoft.com/windowsserver2003/iis/" target="_blank">IIS6</a> or
a <a href="http://www.windowsitpro.com/Articles/Index.cfm?ArticleID=3459" target="_blank">Windows
NT Service</a> or soon-to-be-shipped - <a href="http://windowssdk.msdn.microsoft.com/en-us/library/ms734677.aspx" target="_blank">WAS
in IIS7</a>.
</p>
        <p>
That said, if you want ready hosts of domain-specific workflows with user-customizability,
you can always look at Windows Sharepoint Services v3.0. I believe BizTalk 2008
will be a host for Windows Workflows when it ships as well.
</p>
        <p>
Anyways, one of the key points that confuse many developers is how workflow instances
are scheduled by the workflow runtime engine. There are 2 ways - via a Synchronous
and an Asynchronous approach. Both of them are implemented via the <a href="http://windowssdk.msdn.microsoft.com/en-us/library/aa349374.aspx" target="_blank">ManualWorkflowSchedulerService</a> and <a href="http://windowssdk.msdn.microsoft.com/en-us/library/aa349443.aspx" target="_blank">DefaultWorkflowSchedulerService</a> respectively.
</p>
        <p>
Obviously, if you dont tinker with the WorkflowRuntime with regards to the Scheduling
Services, it will use the DefaultWorkflowSchedulerService service. It creates
and manages the threads that run workflow instances in an asynchronous manner on the runtime
engine and it supports multiple workflow instances queued in the runtime
thread pool. In other words, this default scheduler will automatically queue
the workflow to run on a thread from the process-wide CLR thread pool. With this default
setting on the WorkflowRuntime, the workflow will always execute asynchronously
on a different background thread which, in turn, explains why so many of
the SDK samples waits for the workflow to finish by blocking the main thread
with an AutoResetEvent.
</p>
        <p>
However, you can use the ManualWorkflowSchedulerService if you crave for synchronous
execution of workflow instances. The workflow instances are executed on the calling
thread from the host application, thus blocking the execution of the host application
until the workflow instance becomes idle. To do so, the host must donate threads
to the workflow runtime, which will then use this donated thread to execute
a workflow.
</p>
        <p>
Running a workflow with the ManualWorkflowSchedulerServic is slightly different as
well. It involves a two-step process. First, you call Start on the workflow
instance. But that is not enough as it only prepares the runtime for this instance
and does not actually run the workflow. We have to be more explicit by calling
RunWorkflow and passing the Workflow's Instance ID. This is how a thread is donated
by the host. The WorkflowRuntime will then use this calling thread to execute
the workflow synchronously. In other words, the workflow instance will execute on
the same thread as the calling program.
</p>
        <p>
Subtle differences, but understanding it will enable the use of the right tool to
do the right job.
</p>
        <p>
        </p>
        <img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=283caaa9-2f3a-4a70-9e6b-a23312ff32e9" />
        <br />
        <hr />
© William Tay 2012 | Swinging Technologist 
<br /><a href="http://www.softwaremaker.net/blog">http://www.softwaremaker.net/blog</a></body>
      <title>Windows Workflow: Scheduler and Threads</title>
      <guid isPermaLink="false">http://www.softwaremaker.net/blog/PermaLink,guid,283caaa9-2f3a-4a70-9e6b-a23312ff32e9.aspx</guid>
      <link>http://www.softwaremaker.net/blog/WindowsWorkflowSchedulerAndThreads.aspx</link>
      <pubDate>Thu, 14 Sep 2006 10:33:55 GMT</pubDate>
      <description>&lt;p&gt;
I dont think the world has seen so much emphasis&amp;nbsp;on a&amp;nbsp;feature of product
even before pre-launched. In this context, I am talking about &lt;a href=http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx target=_blank&gt;Windows
Workflow Foundation (WF)&lt;/a&gt; and the emphasis on a &lt;em&gt;non&lt;/em&gt;-feature, actually
- that it is a non-product and it doesnt come with &lt;strike&gt;batteries&lt;/strike&gt; host
included.
&lt;/p&gt;
&lt;p&gt;
Windows Workflow&amp;nbsp;consists of an activity library and a framework, a runtime engine,
and a runtime services components. Most of these will work out-of-the-box and some
of them comes with extensibility mechanisms which you can further enhance or customize
on.
&lt;/p&gt;
&lt;p&gt;
All of those must run within a host application process - &lt;strong&gt;&lt;em&gt;which you have
to build&lt;/em&gt;&lt;/strong&gt;.
&lt;/p&gt;
&lt;p&gt;
In other words, Windows Workflow is just a framework with managed APIs and not a designed
as a product. It would be a lot of work to build your own host, which is why I wouldnt
recommend it. You can implement workflows in existing hosts such as &lt;a href="http://www.microsoft.com/windowsserver2003/iis/" target=_blank&gt;IIS6&lt;/a&gt; or
a &lt;a href="http://www.windowsitpro.com/Articles/Index.cfm?ArticleID=3459" target=_blank&gt;Windows
NT Service&lt;/a&gt; or soon-to-be-shipped - &lt;a href="http://windowssdk.msdn.microsoft.com/en-us/library/ms734677.aspx" target=_blank&gt;WAS
in IIS7&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
That said, if you want ready hosts of domain-specific workflows with user-customizability,
you can always look at Windows Sharepoint Services v3.0. I believe&amp;nbsp;BizTalk 2008
will be a host for Windows Workflows when it ships as well.
&lt;/p&gt;
&lt;p&gt;
Anyways, one of the key points that confuse many developers is how workflow instances
are scheduled by the workflow runtime engine. There are 2 ways - via a Synchronous
and an Asynchronous approach. Both of them are implemented via the &lt;a href="http://windowssdk.msdn.microsoft.com/en-us/library/aa349374.aspx" target=_blank&gt;ManualWorkflowSchedulerService&lt;/a&gt; and &lt;a href="http://windowssdk.msdn.microsoft.com/en-us/library/aa349443.aspx" target=_blank&gt;DefaultWorkflowSchedulerService&lt;/a&gt; respectively.
&lt;/p&gt;
&lt;p&gt;
Obviously, if you dont tinker with the WorkflowRuntime with regards to the Scheduling
Services, it will use the DefaultWorkflowSchedulerService service. It&amp;nbsp;creates
and manages the threads that run workflow instances in an asynchronous manner on the&amp;nbsp;runtime
engine and&amp;nbsp;it supports&amp;nbsp;multiple workflow instances queued in the runtime
thread pool. In other words,&amp;nbsp;this default scheduler will automatically queue
the workflow to run on a thread from the process-wide CLR thread pool. With this&amp;nbsp;default
setting on the WorkflowRuntime,&amp;nbsp;the workflow will always execute asynchronously
on a different background thread&amp;nbsp;which, in turn,&amp;nbsp;explains why so many of
the SDK samples&amp;nbsp;waits for the workflow to finish by blocking the main thread
with an AutoResetEvent.
&lt;/p&gt;
&lt;p&gt;
However, you can use the ManualWorkflowSchedulerService&amp;nbsp;if you crave for synchronous
execution of workflow instances.&amp;nbsp;The workflow instances are executed on the calling
thread from the host application, thus blocking the execution of the host application
until the workflow instance becomes idle. To do so,&amp;nbsp;the host must donate threads
to the workflow runtime, which will then&amp;nbsp;use&amp;nbsp;this donated thread to execute
a workflow.
&lt;/p&gt;
&lt;p&gt;
Running a workflow with the ManualWorkflowSchedulerServic is slightly different as
well. It involves&amp;nbsp;a two-step process. First, you&amp;nbsp;call Start on the workflow
instance. But that is not enough as it&amp;nbsp;only prepares the runtime for this instance
and does not actually run the workflow. We have to be more explicit by&amp;nbsp;calling
RunWorkflow and passing the Workflow's Instance ID. This is how a thread is donated
by the host. The&amp;nbsp;WorkflowRuntime will then use this calling thread to execute
the workflow synchronously. In other words, the workflow instance will execute on
the same thread as the calling program.
&lt;/p&gt;
&lt;p&gt;
Subtle differences, but understanding it will enable the use of the right tool to
do the right job.
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=283caaa9-2f3a-4a70-9e6b-a23312ff32e9" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
© William Tay 2012 | Swinging Technologist 
&lt;br /&gt;
&lt;a href="http://www.softwaremaker.net/blog"&gt;http://www.softwaremaker.net/blog&lt;/a&gt;</description>
      <category>Windows Workflow Foundation (WF)</category>
    </item>
    <item>
      <trackback:ping>http://www.softwaremaker.net/blog/Trackback.aspx?guid=090d9f24-6788-49e4-ba2b-1a775a2033b6</trackback:ping>
      <pingback:server>http://www.softwaremaker.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.softwaremaker.net/blog/PermaLink,guid,090d9f24-6788-49e4-ba2b-1a775a2033b6.aspx</pingback:target>
      <dc:creator>William Tay</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Fellow <a href="http://msdn.microsoft.com/isv/rd/default.aspx" target="_blank" title="Microsoft Regional Director">Microsoft
Regional Director</a> and well-known distributed systems expert <a href="http://www.request-response.com/blog" target="_blank">Matevz
Gacnik</a> has a great blog to add on top of mine called: <a href="http://www.request-response.com/blog/PermaLink,guid,21c95c2c-63d7-44f6-8357-1be0ecb6f264.aspx" target="_blank">Windows
Workflow Foundation: Exposing Workflows as Services</a>. Trust me, Matevz is a lot
more than Request-Response or what his blog suggested <img src="http://www.softwaremaker.net/pictures/swmemoticons/smile.gif" />.
</p>
        <p>
In it, he explains some of the ways you can do so and the pitfalls to watch out for.
Of course, you can get around the "<em>workflow runtime can only get loaded once per
appdomain</em>" issues by having it static to the service implementation class OR
if you want only one instance of each - <a href="http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx" target="_blank">Windows
Communication Foundation (WCF, previously - Indigo)</a> also gives you a singleton-like
instancing mode as well - <strong><em>InstanceContextMode:=InstanceContextMode.Single</em></strong>.
</p>
        <p>
(<em>I would be interested to find out the naming convention to call it Single in
the latest CTP instead of Singleton</em>)
</p>
        <p>
My tip highlighted <a href="http://www.softwaremaker.net/blog/HookingAWorkflowIntoYourWCFDispatcher.aspx" target="_blank">here</a> is
not really about exposing workflows as services. It is more about how you can hook
a workflow into a already-hosted WCF service as part of its configured behavior, if
need be. For example, you may want to have a non-intrusive workflow for you to raise
an event that calls into your defined <strong>HandleExternalMethod</strong> (called
EventSink before) and then you may just terminate that activity. The reason is because
the workflow thread doesnt return unless you called a <strong>WaitHandle.Set</strong>,
which you can call when a workflow is completed or terminated.
</p>
        <p>
Having said all that - Remember that most of the current implementations of Web Services
today work on a Request-Response model and many more are betting on that it will remain
like that for a long time. Isnt this one of the reasons we have long arguments
of <a href="http://en.wikipedia.org/wiki/POX" target="_blank">POX</a>/<a href="http://en.wikipedia.org/wiki/Representational_State_Transfer" target="_blank">REST</a> ?
Workflows, on the other hand, are made to handle long running work and therefore,
you need to design and handle both properly as its design principles and most-used
implementations do conflict.
</p>
        <p>
Now, if you forsake the Request-Response model and think about the wonderful partnership
and the options abound once you hit <strong>&lt;OperationContract(IsOneWay:=True)&gt;</strong> on
top of the MSMQ transport, <a href="http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx" target="_blank">Windows
Workflow Foundation (WF)</a> + <a href="http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx" target="_blank">Windows
Communication Foundation (WCF, previously - Indigo)</a> does look very delicious and
promising indeed.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=090d9f24-6788-49e4-ba2b-1a775a2033b6" />
        <br />
        <hr />
© William Tay 2012 | Swinging Technologist 
<br /><a href="http://www.softwaremaker.net/blog">http://www.softwaremaker.net/blog</a></body>
      <title>Matevz adds his weight on Workflows and Services...</title>
      <guid isPermaLink="false">http://www.softwaremaker.net/blog/PermaLink,guid,090d9f24-6788-49e4-ba2b-1a775a2033b6.aspx</guid>
      <link>http://www.softwaremaker.net/blog/MatevzAddsHisWeightOnWorkflowsAndServices.aspx</link>
      <pubDate>Wed, 10 May 2006 10:21:25 GMT</pubDate>
      <description>&lt;p&gt;
Fellow &lt;a href="http://msdn.microsoft.com/isv/rd/default.aspx" target="_blank" title="Microsoft Regional Director"&gt;Microsoft
Regional Director&lt;/a&gt; and well-known distributed systems expert &lt;a href="http://www.request-response.com/blog" target=_blank&gt;Matevz
Gacnik&lt;/a&gt; has a great blog to add on top of mine called: &lt;a href="http://www.request-response.com/blog/PermaLink,guid,21c95c2c-63d7-44f6-8357-1be0ecb6f264.aspx" target=_blank&gt;Windows
Workflow Foundation: Exposing Workflows as Services&lt;/a&gt;. Trust me, Matevz is a lot
more than Request-Response or what his blog suggested &lt;img src="http://www.softwaremaker.net/pictures/swmemoticons/smile.gif"&gt;.
&lt;/p&gt;
&lt;p&gt;
In it, he explains some of the ways you can do so and the pitfalls to watch out for.
Of course, you can get around the "&lt;em&gt;workflow runtime can only get loaded once per
appdomain&lt;/em&gt;" issues by having it static to the service implementation class OR
if you want only one instance of each - &lt;a href=http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx target=_blank&gt;Windows
Communication Foundation (WCF, previously - Indigo)&lt;/a&gt; also gives you a singleton-like
instancing mode as well - &lt;strong&gt;&lt;em&gt;InstanceContextMode:=InstanceContextMode.Single&lt;/em&gt;&lt;/strong&gt;.
&lt;/p&gt;
&lt;p&gt;
(&lt;em&gt;I would be interested to find out the naming convention to call it Single in
the latest CTP instead of Singleton&lt;/em&gt;)
&lt;/p&gt;
&lt;p&gt;
My&amp;nbsp;tip highlighted &lt;a href="http://www.softwaremaker.net/blog/HookingAWorkflowIntoYourWCFDispatcher.aspx" target=_blank&gt;here&lt;/a&gt;&amp;nbsp;is
not really about exposing workflows as services. It is more about how you can hook
a workflow into a already-hosted WCF service as part of its configured behavior, if
need be. For example, you may want to have a non-intrusive workflow for you to raise
an event that calls into your defined &lt;strong&gt;HandleExternalMethod&lt;/strong&gt; (called
EventSink before) and then you may just terminate that activity. The reason is because
the workflow thread doesnt return unless you called a &lt;strong&gt;WaitHandle.Set&lt;/strong&gt;,
which you can call when a workflow is completed or terminated.
&lt;/p&gt;
&lt;p&gt;
Having said all that - Remember that most of the current implementations of Web Services
today work on a Request-Response model and many more are betting on that it will remain
like that for a long time. Isnt this&amp;nbsp;one of the reasons we have long arguments
of &lt;a href="http://en.wikipedia.org/wiki/POX" target=_blank&gt;POX&lt;/a&gt;/&lt;a href="http://en.wikipedia.org/wiki/Representational_State_Transfer" target=_blank&gt;REST&lt;/a&gt; ?
Workflows, on the other hand, are made to handle long running work and therefore,
you need to design and handle both properly as its&amp;nbsp;design principles and most-used
implementations do conflict.
&lt;/p&gt;
&lt;p&gt;
Now, if you forsake the Request-Response model and think about the wonderful partnership
and the options abound once you hit &lt;strong&gt;&amp;lt;OperationContract(IsOneWay:=True)&amp;gt;&lt;/strong&gt; on
top of the MSMQ transport, &lt;a href=http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx target=_blank&gt;Windows
Workflow Foundation (WF)&lt;/a&gt; + &lt;a href=http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx target=_blank&gt;Windows
Communication Foundation (WCF, previously - Indigo)&lt;/a&gt; does look very delicious and
promising indeed.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=090d9f24-6788-49e4-ba2b-1a775a2033b6" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
© William Tay 2012 | Swinging Technologist 
&lt;br /&gt;
&lt;a href="http://www.softwaremaker.net/blog"&gt;http://www.softwaremaker.net/blog&lt;/a&gt;</description>
      <category>Windows Communication Foundation (WCF) aka Indigo;XML Services;Windows Workflow Foundation (WF)</category>
    </item>
    <item>
      <trackback:ping>http://www.softwaremaker.net/blog/Trackback.aspx?guid=0dd9ebed-4ad1-4b8b-8824-19bbad48985a</trackback:ping>
      <pingback:server>http://www.softwaremaker.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.softwaremaker.net/blog/PermaLink,guid,0dd9ebed-4ad1-4b8b-8824-19bbad48985a.aspx</pingback:target>
      <dc:creator>William Tay</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One of the common questions I came across my <a href="http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx" target="_blank">Windows
Workflow Foundation (WF)</a> and <a href="http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx" target="_blank">Windows
Communication Foundation (WCF, previously - Indigo)</a> consultancy <a href="http://www.softwaremaker.net/blog/YesIWillCoverInfocardsAsWell.aspx" target="_blank">tour</a> is
how do we logically use WF inside a WCF-hosted service.
</p>
        <p>
I had spent some time talking about how we can host a WF in a WCF:ServiceHost and
how we can create a channel to invoke a workflow inside a WCF Service.
</p>
        <p>
Of course, we can always bring up a Workflow runtime and create a new workflow
instance within the ServiceHost. However, some of us may prefer a more non-intrusive
mode of a workflow invocation style.
</p>
        <p>
There are actually many extensible points at the Service Dispatcher which you can
hook into that is part of a service behavior. There is the <strong>IServiceBehavior</strong>, <strong>IOperationBehavior</strong> and
one of my favourite extensible behavior points I like to hook into is at the <strong>IEndpointBehavior.</strong></p>
        <p>
For instance, you may want to inspect a message in its raw glory and depending on
its headers or the request properties, you may choose to invoke an appropriate
action or workflow. You<strong> </strong>would need to implement the ApplyDispatchBehavior
routine which gives you acccess to an EndpointDispatcher, which in turn, gives you
a chance to implement a <strong>IDispatchMessageInspector. </strong>The<strong> IDispatchMessageInspector</strong> exposes
some very useful routines which allows you to hook into the request message just after
it has been received as well as before sending the reply message back.
</p>
        <p>
I would probably inspect the messages at this point and invoke the appropriate workflow
and send the appropriate values into the <strong>ExternalDataEventArgs</strong> of
the workflow based on the message values.
</p>
        <p>
Of course, this is not a hard and fast rule. How and when you do it is totally up
to you. You may want to do it at the <strong>IOperationBehaviour</strong> and have
the message dispatched to another entirely different operation if you want to (or
if you dont agree with how WCF dispatches its messages).
</p>
        <p>
Below are some snippets that will help you along. I will be going more in-depth into
these details in <a href="http://www.microsoft.com/malaysia/techedsea2006/" target="_blank">TechED
Asia 2006</a> in Malaysia where I will show some really cool never-seen-before demos
that is a mixture of WF and WCF. If you havent planned to be be there at TechED Asia
2006, do so now ! <img src="http://www.softwaremaker.net/pictures/swmemoticons/smile.gif" /></p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Namespace</span> Softwaremaker.NET.Wcf.Demos<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Class</span> WcfMessageInspectorWorkflowInvoker
: <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Implements</span> IDispatchMessageInspector<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span>()<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">MyBase</span>.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span>()<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span> AfterReceiveRequest(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByRef</span> request <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> Message, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> channel <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> IClientChannel, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> instanceContext <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> InstanceContext) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Object</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Implements</span> IDispatchMessageInspector.AfterReceiveRequest<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'Inspecting
Message Request ...</span><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'Invoking
appropriate Workflows based on values found in request message</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Catch</span> e <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> Exception<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Throw</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> FaultException(e.Message)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Return</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Nothing</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Function</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> BeforeSendReply(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByRef</span> reply <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> Message, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> correlationState <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Object</span>) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Implements</span> IDispatchMessageInspector.BeforeSendReply<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'Inspecting
Message Reply ...</span><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'Invoking
appropriate Workflows based on values found in reply message</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Catch</span> e <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> Exception<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Throw</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> FaultException(e.Message)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Try</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Class</span></span>
        </p>
        <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
          <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <p>
              <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span>
                <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Class</span> WcfMessageInspectorWorkflowInvokerBehavior
: <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Implements</span> IEndpointBehavior<br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'...</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span> ApplyDispatchBehavior(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> serviceEndpoint <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> ServiceEndpoint, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">ByVal</span> endpointDispatcher <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">As</span> EndpointDispatcher) <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Implements</span> IEndpointBehavior.ApplyDispatchBehavior<br />
endpointDispatcher.DispatchRuntime.MessageInspectors.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Add</span>(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> WcfMessageInspectorWorkflowInvoker)<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Sub</span><br /><br /><span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">'...</span><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">End</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Class</span></span>
            </p>
          </span>
        </span>
        <p>
What I have described above is a good way to abstract how and when you invoke a workflow
away from your WCF-Hosting or business code. How do I add this behavior into my <strong>serviceHost</strong> ?
Easy. Just call the below before your <strong>serviceHost.Open</strong></p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">serviceHost.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Description</span>.Endpoints(0).Behaviors.<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">Add</span>(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">New</span> Softwaremaker.NET.Wcf.Demos.WcfMessageInspectorWorkflowInvokerBehavior)</span>
        </p>
        <p>
Now, if you decide that the above code sentence intrudes into your hosting code and
you would like it to be configured in your config file for flexibility as well, I
will show in a later blog post how to add your own custom-defined <strong>behaviorExtension</strong> into
your configuration file. Think: <strong>BehaviorExtensionSection.</strong></p>
        <p>
... OR you can always go to <a href="http://www.microsoft.com/malaysia/techedsea2006/" target="_blank">TechED
Asia 2006</a> in Malaysia where you sure would derive more value than a single non-interactive
blog post. <img src="http://www.softwaremaker.net/pictures/swmemoticons/wink.gif" /></p>
        <p>
Enjoy.
</p>
        <img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=0dd9ebed-4ad1-4b8b-8824-19bbad48985a" />
        <br />
        <hr />
© William Tay 2012 | Swinging Technologist 
<br /><a href="http://www.softwaremaker.net/blog">http://www.softwaremaker.net/blog</a></body>
      <title>Hooking a Workflow into your WCF Dispatcher</title>
      <guid isPermaLink="false">http://www.softwaremaker.net/blog/PermaLink,guid,0dd9ebed-4ad1-4b8b-8824-19bbad48985a.aspx</guid>
      <link>http://www.softwaremaker.net/blog/HookingAWorkflowIntoYourWCFDispatcher.aspx</link>
      <pubDate>Mon, 08 May 2006 05:12:54 GMT</pubDate>
      <description>&lt;p&gt;
One of the common questions I came across&amp;nbsp;my &lt;a href=http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx target=_blank&gt;Windows
Workflow Foundation (WF)&lt;/a&gt; and &lt;a href=http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx target=_blank&gt;Windows
Communication Foundation (WCF, previously - Indigo)&lt;/a&gt; consultancy &lt;a href="http://www.softwaremaker.net/blog/YesIWillCoverInfocardsAsWell.aspx" target=_blank&gt;tour&lt;/a&gt;&amp;nbsp;is
how do we logically use WF inside a WCF-hosted service.
&lt;/p&gt;
&lt;p&gt;
I had spent some time talking about how we can host a WF in a WCF:ServiceHost and
how we can create a channel to invoke a workflow inside a WCF Service.
&lt;/p&gt;
&lt;p&gt;
Of course, we can always bring up a Workflow runtime and create&amp;nbsp;a new workflow
instance within the ServiceHost. However, some of us may prefer a more non-intrusive
mode of a workflow invocation style.
&lt;/p&gt;
&lt;p&gt;
There are actually many extensible points at the Service Dispatcher which you can
hook into that is part of a service behavior. There is the &lt;strong&gt;IServiceBehavior&lt;/strong&gt;, &lt;strong&gt;IOperationBehavior&lt;/strong&gt; and
one of my favourite&amp;nbsp;extensible behavior points I like to hook into is at the &lt;strong&gt;IEndpointBehavior.&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
For instance, you may want to inspect a message in its raw glory and depending on
its headers or the request&amp;nbsp;properties, you may choose to invoke an appropriate
action or workflow.&amp;nbsp;You&lt;strong&gt;&amp;nbsp;&lt;/strong&gt;would need to implement the ApplyDispatchBehavior
routine which gives you acccess to an EndpointDispatcher, which in turn, gives you
a chance to implement a &lt;strong&gt;IDispatchMessageInspector. &lt;/strong&gt;The&lt;strong&gt; IDispatchMessageInspector&lt;/strong&gt; exposes
some very useful routines which allows you to hook into the request message just after
it has been received as well as before sending the reply message back.
&lt;/p&gt;
&lt;p&gt;
I would probably inspect the messages at this point and invoke the appropriate workflow
and send the appropriate values into the&amp;nbsp;&lt;strong&gt;ExternalDataEventArgs&lt;/strong&gt; of
the workflow based on the message values.
&lt;/p&gt;
&lt;p&gt;
Of course, this is not a hard and fast rule. How and when you do it is totally up
to you. You may want to do it at the &lt;strong&gt;IOperationBehaviour&lt;/strong&gt; and have
the message dispatched to another entirely different operation if you want to (or
if you dont agree with how WCF dispatches&amp;nbsp;its messages).
&lt;/p&gt;
&lt;p&gt;
Below are some snippets that will help you along. I will be going more in-depth into
these details in &lt;a href="http://www.microsoft.com/malaysia/techedsea2006/" target=_blank&gt;TechED
Asia 2006&lt;/a&gt; in Malaysia where I will show some really cool never-seen-before demos
that is a mixture of WF and WCF. If you havent planned to be be there at TechED Asia
2006, do so now ! &lt;img src="http://www.softwaremaker.net/pictures/swmemoticons/smile.gif"&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Namespace&lt;/span&gt; Softwaremaker.NET.Wcf.Demos&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Class&lt;/span&gt; WcfMessageInspectorWorkflowInvoker
: &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Implements&lt;/span&gt; IDispatchMessageInspector&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt;()&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;MyBase&lt;/span&gt;.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt;()&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt; AfterReceiveRequest(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByRef&lt;/span&gt; request &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; Message, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; channel &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; IClientChannel, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; instanceContext &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; InstanceContext) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Object&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Implements&lt;/span&gt; IDispatchMessageInspector.AfterReceiveRequest&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'Inspecting
Message Request ...&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'Invoking
appropriate Workflows based on values found in request message&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Catch&lt;/span&gt; e &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; Exception&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Throw&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; FaultException(e.Message)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Return&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Nothing&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Function&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; BeforeSendReply(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByRef&lt;/span&gt; reply &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; Message, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; correlationState &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Object&lt;/span&gt;) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Implements&lt;/span&gt; IDispatchMessageInspector.BeforeSendReply&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'Inspecting
Message Reply ...&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'Invoking
appropriate Workflows based on values found in reply message&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Catch&lt;/span&gt; e &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; Exception&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Throw&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; FaultException(e.Message)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Try&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Class&lt;/span&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Class&lt;/span&gt; WcfMessageInspectorWorkflowInvokerBehavior
: &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Implements&lt;/span&gt; IEndpointBehavior&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'...&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt; ApplyDispatchBehavior(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; serviceEndpoint &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; ServiceEndpoint, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;ByVal&lt;/span&gt; endpointDispatcher &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;As&lt;/span&gt; EndpointDispatcher) &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Implements&lt;/span&gt; IEndpointBehavior.ApplyDispatchBehavior&lt;br&gt;
endpointDispatcher.DispatchRuntime.MessageInspectors.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Add&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; WcfMessageInspectorWorkflowInvoker)&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Sub&lt;/span&gt;
&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;'...&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;End&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Class&lt;/span&gt;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&gt;
&lt;p&gt;
What I have described above is a good way to abstract how and when you invoke a workflow
away from your WCF-Hosting or business code. How do I add this behavior into my &lt;strong&gt;serviceHost&lt;/strong&gt; ?
Easy. Just call the below before your &lt;strong&gt;serviceHost.Open&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;serviceHost.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Description&lt;/span&gt;.Endpoints(0).Behaviors.&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;Add&lt;/span&gt;(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;New&lt;/span&gt; Softwaremaker.NET.Wcf.Demos.WcfMessageInspectorWorkflowInvokerBehavior)&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
Now, if you decide that the above code sentence intrudes into your hosting code and
you would like it to be configured in your config file for flexibility as well, I
will&amp;nbsp;show&amp;nbsp;in a later blog post how to add your own custom-defined &lt;strong&gt;behaviorExtension&lt;/strong&gt; into
your configuration file. Think: &lt;strong&gt;BehaviorExtensionSection.&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
... OR you can always go to &lt;a href="http://www.microsoft.com/malaysia/techedsea2006/" target=_blank&gt;TechED
Asia 2006&lt;/a&gt; in Malaysia where you sure would derive more value than a single non-interactive
blog post. &lt;img src="http://www.softwaremaker.net/pictures/swmemoticons/wink.gif"&gt;
&lt;/p&gt;
&lt;p&gt;
Enjoy.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=0dd9ebed-4ad1-4b8b-8824-19bbad48985a" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
© William Tay 2012 | Swinging Technologist 
&lt;br /&gt;
&lt;a href="http://www.softwaremaker.net/blog"&gt;http://www.softwaremaker.net/blog&lt;/a&gt;</description>
      <category>Software Development;Windows Communication Foundation (WCF) aka Indigo;Windows Workflow Foundation (WF)</category>
    </item>
    <item>
      <trackback:ping>http://www.softwaremaker.net/blog/Trackback.aspx?guid=e3351661-bde9-48be-9759-e1a57c279bd2</trackback:ping>
      <pingback:server>http://www.softwaremaker.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.softwaremaker.net/blog/PermaLink,guid,e3351661-bde9-48be-9759-e1a57c279bd2.aspx</pingback:target>
      <dc:creator>William Tay</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Microsoft announced <strong><em>Go Live</em></strong> licenses this morning for <a href="http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx" target="_blank">Windows
Communication Foundation (WCF, previously - Indigo)</a> and <a href="http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx" target="_blank">Windows
Workflow Foundation (WF)</a> , which lets customers use the January Go Live
releases of WCF and WWF in their deployment environments. Do note that these are unsupported
Go Lives.)  
</p>
        <p>
More information about the Go Live program is at <a href="http://msdn.microsoft.com/winfx/getthebeta/golive/default.aspx" target="_blank">http://msdn.microsoft.com/winfx/getthebeta/golive/default.aspx</a>.
</p>
        <p>
There are also a couple of community sites for WCF and WWF here:<br /><a href="http://windowscommunication.net/" target="_blank">http://windowscommunication.net</a><br /><a href="http://windowsworkflow.net/" target="_blank">http://windowsworkflow.net</a></p>
        <p>
The community sites give users everything they need to start using WWF and WF today. 
If you have some great samples, do post them to the sites;  The
WCF sample gallery and WF activity gallery allow you to host the samples/activities
on your own site and create links to your own site from the galleries.
</p>
        <p>
As <a href="http://www.softwaremaker.net/blog/InitializingWindowsWorkflowFoundationAndWindowsPresentationFoundation.aspx" target="_blank">mentioned</a>,
I will be introducing more WWF Blogging to this site. Do stay tuned.
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=e3351661-bde9-48be-9759-e1a57c279bd2" />
        <br />
        <hr />
© William Tay 2012 | Swinging Technologist 
<br /><a href="http://www.softwaremaker.net/blog">http://www.softwaremaker.net/blog</a></body>
      <title>[Go_Live_Licenses]WCF and WWF[/Go_Live_Licenses]</title>
      <guid isPermaLink="false">http://www.softwaremaker.net/blog/PermaLink,guid,e3351661-bde9-48be-9759-e1a57c279bd2.aspx</guid>
      <link>http://www.softwaremaker.net/blog/GoLiveLicensesWCFAndWWFGoLiveLicenses.aspx</link>
      <pubDate>Wed, 18 Jan 2006 21:58:09 GMT</pubDate>
      <description>&lt;p&gt;
Microsoft&amp;nbsp;announced &lt;strong&gt;&lt;em&gt;Go Live&lt;/em&gt;&lt;/strong&gt; licenses this morning for &lt;a href=http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx target=_blank&gt;Windows
Communication Foundation (WCF, previously - Indigo)&lt;/a&gt;&amp;nbsp;and &lt;a href=http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx target=_blank&gt;Windows
Workflow Foundation (WF)&lt;/a&gt;&amp;nbsp;, which&amp;nbsp;lets customers use the January Go Live
releases of WCF and WWF in their deployment environments. Do note that these are unsupported
Go Lives.)&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
More information about the Go Live program is at &lt;a href="http://msdn.microsoft.com/winfx/getthebeta/golive/default.aspx" target=_blank&gt;http://msdn.microsoft.com/winfx/getthebeta/golive/default.aspx&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
There&amp;nbsp;are also a couple of community sites for WCF and WWF here:&lt;br&gt;
&lt;a href="http://windowscommunication.net/" target=_blank&gt;http://windowscommunication.net&lt;/a&gt;
&lt;br&gt;
&lt;a href="http://windowsworkflow.net/" target=_blank&gt;http://windowsworkflow.net&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The community sites give users everything they need to start using WWF and WF today.&amp;nbsp;
If you have some&amp;nbsp;great samples, do&amp;nbsp;post them to the sites;&amp;nbsp;&amp;nbsp;The
WCF sample gallery and WF activity gallery allow you to host the samples/activities
on your own site and create links to your own site from the galleries.
&lt;/p&gt;
&lt;p&gt;
As &lt;a href="http://www.softwaremaker.net/blog/InitializingWindowsWorkflowFoundationAndWindowsPresentationFoundation.aspx" target=_blank&gt;mentioned&lt;/a&gt;,
I will be introducing more WWF Blogging to this site. Do stay tuned.
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=e3351661-bde9-48be-9759-e1a57c279bd2" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
© William Tay 2012 | Swinging Technologist 
&lt;br /&gt;
&lt;a href="http://www.softwaremaker.net/blog"&gt;http://www.softwaremaker.net/blog&lt;/a&gt;</description>
      <category>Announcements;Community;Windows Communication Foundation (WCF) aka Indigo;Windows Workflow Foundation (WF)</category>
    </item>
    <item>
      <trackback:ping>http://www.softwaremaker.net/blog/Trackback.aspx?guid=a8be816a-8c61-4614-8300-0af59931bd77</trackback:ping>
      <pingback:server>http://www.softwaremaker.net/blog/pingback.aspx</pingback:server>
      <pingback:target>http://www.softwaremaker.net/blog/PermaLink,guid,a8be816a-8c61-4614-8300-0af59931bd77.aspx</pingback:target>
      <dc:creator>William Tay</dc:creator>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Besides being deeply involved in <a href="http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx" target="_blank">Windows
Communication Foundation (WCF, previously - Indigo)</a>, I have also been very engaged
with the technologies of <a href="http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx" target="_blank">Windows
Workflow Foundation (WF)</a> and <a href="http://msdn2.microsoft.com/en-us/netframework/aa663326.aspx" target="_blank">Windows
Presentation Foundation (WPF)</a>.
</p>
        <p>
I will be blogging actively on these 2 technologies as we move towards <a href="http://www.microsoft.com/windowsvista" target="_blank">Vista</a></p>
        <img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=a8be816a-8c61-4614-8300-0af59931bd77" />
        <br />
        <hr />
© William Tay 2012 | Swinging Technologist 
<br /><a href="http://www.softwaremaker.net/blog">http://www.softwaremaker.net/blog</a></body>
      <title>Initializing Windows Workflow Foundation and Windows Presentation Foundation</title>
      <guid isPermaLink="false">http://www.softwaremaker.net/blog/PermaLink,guid,a8be816a-8c61-4614-8300-0af59931bd77.aspx</guid>
      <link>http://www.softwaremaker.net/blog/InitializingWindowsWorkflowFoundationAndWindowsPresentationFoundation.aspx</link>
      <pubDate>Mon, 07 Nov 2005 13:18:53 GMT</pubDate>
      <description>&lt;p&gt;
Besides being deeply involved in &lt;a href=http://msdn2.microsoft.com/en-us/netframework/aa663324.aspx target=_blank&gt;Windows
Communication Foundation (WCF, previously - Indigo)&lt;/a&gt;, I have also been very engaged
with the technologies of &lt;a href=http://msdn2.microsoft.com/en-us/netframework/aa663328.aspx target=_blank&gt;Windows
Workflow Foundation (WF)&lt;/a&gt; and &lt;a href=http://msdn2.microsoft.com/en-us/netframework/aa663326.aspx target=_blank&gt;Windows
Presentation Foundation (WPF)&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
I will be blogging actively on these 2 technologies as we move towards &lt;a href=http://www.microsoft.com/windowsvista target=_blank&gt;Vista&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.softwaremaker.net/blog/aggbug.ashx?id=a8be816a-8c61-4614-8300-0af59931bd77" /&gt;
&lt;br /&gt;
&lt;hr /&gt;
© William Tay 2012 | Swinging Technologist 
&lt;br /&gt;
&lt;a href="http://www.softwaremaker.net/blog"&gt;http://www.softwaremaker.net/blog&lt;/a&gt;</description>
      <category>Windows Presentation Foundation (WPF) aka Avalon;Windows Workflow Foundation (WF)</category>
    </item>
  </channel>
</rss>