Side-by-Side Hosting of Two Versions of a Workflow Using WorkflowServiceHost

The concept of WorkflowIdentity has been introduced in Windows Workflow Foundation 4.5. This identity is stamped on each WorkflowService instance that is created by a host and allows the same WorkflowServiceHost to support multiple versions of a given definition of a Workflow.

C# (178.1 KB)
 
 
 
 
 
5 Star
(2)
1,516 times
Add to favorites
10/21/2011
E-mail Twitter del.icio.us Digg Facebook

Solution explorer

C#
<Activity mc:Ignorable="sap sap2010 sads" x:Class="WFSHSxS.Workflow2" sap2010:ExpressionActivityEditor.ExpressionActivityEditor="C#" sap2010:WorkflowViewState.IdRef="WorkflowConsoleApplication2.WorkflowCurrent_1"
 xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
 xmlns:mca="clr-namespace:Microsoft.CSharp.Activities;assembly=System.Activities"
 xmlns:p="http://tempuri.org/"
 xmlns:p1="http://schemas.microsoft.com/netfx/2009/xaml/servicemodel"
 xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
 xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
 xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
 xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
 xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
 xmlns:ssx="clr-namespace:System.ServiceModel.XamlIntegration;assembly=System.ServiceModel"
 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <TextExpression.NamespacesForImplementation>
    <sco:Collection x:TypeArguments="x:String">
      <x:String>System</x:String>
      <x:String>System.Collections.Generic</x:String>
      <x:String>System.Data</x:String>
      <x:String>System.Linq</x:String>
      <x:String>System.Text</x:String>
    </sco:Collection>
  </TextExpression.NamespacesForImplementation>
  <TextExpression.ReferencesForImplementation>
    <sco:Collection x:TypeArguments="AssemblyReference">
      <AssemblyReference>mscorlib</AssemblyReference>
      <AssemblyReference>System</AssemblyReference>
      <AssemblyReference>System.Core</AssemblyReference>
      <AssemblyReference>System.Data</AssemblyReference>
      <AssemblyReference>System.ServiceModel</AssemblyReference>
      <AssemblyReference>System.Xml</AssemblyReference>
    </sco:Collection>
  </TextExpression.ReferencesForImplementation>
  <Sequence sap2010:WorkflowViewState.IdRef="Sequence_4">
    <Sequence.Variables>
      <Variable x:TypeArguments="x:Double" Default="10" Name="currentRate" />
      <Variable x:TypeArguments="x:Double" Name="loanAmount" />
    </Sequence.Variables>
    <Sequence sap2010:WorkflowViewState.IdRef="Sequence_3">
      <Sequence.Variables>
        <Variable x:TypeArguments="p1:CorrelationHandle" x:Name="__ReferenceID0" Name="__handle1" />
      </Sequence.Variables>
      <p1:Receive x:Name="__ReferenceID1" CanCreateInstance="True" sap2010:WorkflowViewState.IdRef="Receive_2" OperationName="GetAQuote" ServiceContractName="p:IService">
        <p1:Receive.CorrelationInitializers>
          <p1:RequestReplyCorrelationInitializer>
            <p1:RequestReplyCorrelationInitializer.CorrelationHandle>
              <InArgument x:TypeArguments="p1:CorrelationHandle">
                <VariableValue x:TypeArguments="p1:CorrelationHandle" Variable="{x:Reference __ReferenceID0}" />
              </InArgument>
            </p1:RequestReplyCorrelationInitializer.CorrelationHandle>
          </p1:RequestReplyCorrelationInitializer>
          <p1:QueryCorrelationInitializer>
            <p1:XPathMessageQuery x:Key="key1">
              <p1:XPathMessageQuery.Namespaces>
                <ssx:XPathMessageContextMarkup>
                  <x:String x:Key="xgSc">http://tempuri.org/</x:String>
                </ssx:XPathMessageContextMarkup>
              </p1:XPathMessageQuery.Namespaces>sm:body()/xgSc:GetAQuote/xgSc:yourName</p1:XPathMessageQuery>
          </p1:QueryCorrelationInitializer>
        </p1:Receive.CorrelationInitializers>
        <p1:ReceiveParametersContent>
          <OutArgument x:TypeArguments="x:String" x:Key="yourName" />
        </p1:ReceiveParametersContent>
      </p1:Receive>
      <p1:SendReply Request="{x:Reference __ReferenceID1}" DisplayName="SendReplyToReceive" sap2010:WorkflowViewState.IdRef="SendReply_2">
        <p1:SendParametersContent>
          <InArgument x:TypeArguments="x:Double" x:Key="yourRate">
            <mca:CSharpValue x:TypeArguments="x:Double">currentRate</mca:CSharpValue>
          </InArgument>
        </p1:SendParametersContent>
      </p1:SendReply>
    </Sequence>
    <Sequence sap2010:WorkflowViewState.IdRef="Sequence_5">
      <Sequence.Variables>
        <Variable x:TypeArguments="p1:CorrelationHandle" x:Name="__ReferenceID2" Name="__handle1" />
      </Sequence.Variables>
      <p1:Receive x:Name="__ReferenceID3" sap2010:WorkflowViewState.IdRef="Receive_3" OperationName="CalculatePaybackAmount" ServiceContractName="p:IService">
        <p1:Receive.CorrelatesOn>
          <p1:XPathMessageQuery x:Key="key1">
            <p1:XPathMessageQuery.Namespaces>
              <ssx:XPathMessageContextMarkup>
                <x:String x:Key="xgSc">http://tempuri.org/</x:String>
              </ssx:XPathMessageContextMarkup>
            </p1:XPathMessageQuery.Namespaces>sm:body()/xgSc:CalculatePaybackAmount/xgSc:yourName</p1:XPathMessageQuery>
        </p1:Receive.CorrelatesOn>
        <p1:Receive.CorrelationInitializers>
          <p1:RequestReplyCorrelationInitializer>
            <p1:RequestReplyCorrelationInitializer.CorrelationHandle>
              <InArgument x:TypeArguments="p1:CorrelationHandle">
                <VariableValue x:TypeArguments="p1:CorrelationHandle" Variable="{x:Reference __ReferenceID2}" />
              </InArgument>
            </p1:RequestReplyCorrelationInitializer.CorrelationHandle>
          </p1:RequestReplyCorrelationInitializer>
        </p1:Receive.CorrelationInitializers>
        <p1:ReceiveParametersContent>
          <OutArgument x:TypeArguments="x:String" x:Key="yourName" />
          <OutArgument x:TypeArguments="x:Double" x:Key="amount">
            <mca:CSharpReference x:TypeArguments="x:Double">loanAmount</mca:CSharpReference>
          </OutArgument>
        </p1:ReceiveParametersContent>
      </p1:Receive>
      <p1:SendReply Request="{x:Reference __ReferenceID3}" DisplayName="SendReplyToReceive" sap2010:WorkflowViewState.IdRef="SendReply_3">
        <p1:SendParametersContent>
          <InArgument x:TypeArguments="x:Double" x:Key="PaybackAmount">
            <mca:CSharpValue x:TypeArguments="x:Double">(1+currentRate/100)*loanAmount</mca:CSharpValue>
          </InArgument>
        </p1:SendParametersContent>
      </p1:SendReply>
    </Sequence>
    <sads:DebugSymbol.Symbol>d2lDOlxVc2Vyc1xoYW5pa25cRG9jdW1lbnRzXFZpc3VhbCBTdHVkaW8gRGV2MTFcUHJvamVjdHNcV0ZTSFN4U1xXb3JrZmxvd0NvbnNvbGVBcHBsaWNhdGlvbjJcV29ya2Zsb3cyLnhhbWwNIQNuDgIBASM0IzgCAQImBUcQAgERSAVsEAIBAyoHPxQCARlAB0YWAgESTAdkFAIBC2UHaxYCAQQvES9xAgEaQw1DVgIBE2ENYV0CAQ1ZEVlxAgEMaA1oaQIBBw==</sads:DebugSymbol.Symbol>
  </Sequence>
  <sap2010:WorkflowViewState.ViewStateManager>
    <sap2010:ViewStateManager>
      <sap2010:ViewStateData Id="Receive_2" sap:VirtualizedContainerService.HintSize="255,86" />
      <sap2010:ViewStateData Id="SendReply_2" sap:VirtualizedContainerService.HintSize="255,86" />
      <sap2010:ViewStateData Id="Sequence_3" sap:VirtualizedContainerService.HintSize="277,336">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="Receive_3" sap:VirtualizedContainerService.HintSize="255,86" />
      <sap2010:ViewStateData Id="SendReply_3" sap:VirtualizedContainerService.HintSize="255,86" />
      <sap2010:ViewStateData Id="Sequence_5" sap:VirtualizedContainerService.HintSize="277,336">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="Sequence_4" sap:VirtualizedContainerService.HintSize="299,836">
        <sap:WorkflowViewStateService.ViewState>
          <scg:Dictionary x:TypeArguments="x:String, x:Object">
            <x:Boolean x:Key="IsExpanded">True</x:Boolean>
          </scg:Dictionary>
        </sap:WorkflowViewStateService.ViewState>
      </sap2010:ViewStateData>
      <sap2010:ViewStateData Id="WorkflowConsoleApplication2.WorkflowCurrent_1" sap:VirtualizedContainerService.HintSize="339,916" />
    </sap2010:ViewStateManager>
  </sap2010:WorkflowViewState.ViewStateManager>
</Activity>