Click here to Skip to main content
15,895,709 members
Articles / Programming Languages / C# 4.0

Establishing Correlation Between Multiple RECEIVE in WF4

Rate me:
Please Sign up or sign in to vote.
4.00/5 (4 votes)
22 Jan 2010CPOL7 min read 40.4K   785   12  
A simple program to understand correlation in WF4
<Activity mc:Ignorable="sap" x:Class="CustomerSupport.Activity1" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:c="clr-namespace:Customer;assembly=Customer, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" xmlns:c1="clr-namespace:Customer;assembly=Customer" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:p="http://schemas.microsoft.com/netfx/2009/xaml/servicemodel" xmlns:s="clr-namespace:System;assembly=mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" xmlns:s1="clr-namespace:System;assembly=mscorlib" xmlns:s2="clr-namespace:System;assembly=System" xmlns:s3="clr-namespace:System;assembly=System.Xml" xmlns:s4="clr-namespace:System;assembly=System.Core" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sd1="clr-namespace:System.Data;assembly=System.Data.DataSetExtensions" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:ssa="clr-namespace:System.ServiceModel.Activities;assembly=System.ServiceModel.Activities" xmlns:ssx="clr-namespace:System.ServiceModel.XamlIntegration;assembly=System.ServiceModel" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Sequence sad:XamlDebuggerXmlReader.FileName="D:\Bhaskar\WFTest\CorrelCust\Experiment\CustomerSupport\Activity1.xaml" sap:VirtualizedContainerService.HintSize="299,1228">
    <Sequence.Variables>
      <Variable x:TypeArguments="p:CorrelationHandle" Name="_handle1" />
      <Variable x:TypeArguments="c1:Customer" Name="CurrCustomer" />
    </Sequence.Variables>
    <sap:WorkflowViewStateService.ViewState>
      <scg:Dictionary x:TypeArguments="x:String, x:Object">
        <x:Boolean x:Key="IsExpanded">True</x:Boolean>
      </scg:Dictionary>
    </sap:WorkflowViewStateService.ViewState>
    <Sequence sap:VirtualizedContainerService.HintSize="277,532">
      <Sequence.Variables>
        <Variable x:TypeArguments="p:CorrelationHandle" Name="__handle1" />
      </Sequence.Variables>
      <sap:WorkflowViewStateService.ViewState>
        <scg:Dictionary x:TypeArguments="x:String, x:Object">
          <x:Boolean x:Key="IsExpanded">True</x:Boolean>
        </scg:Dictionary>
      </sap:WorkflowViewStateService.ViewState>
      <p:Receive x:Name="__ReferenceID0" CanCreateInstance="True" CorrelatesWith="[__handle1]" DisplayName="Receive" sap:VirtualizedContainerService.HintSize="255,86" OperationName="CreateCustomer" ServiceContractName="CustomerService">
        <p:Receive.CorrelatesOn>
          <p:XPathMessageQuery x:Key="key1">
            <p:XPathMessageQuery.Namespaces>
              <ssx:XPathMessageContextMarkup>
                <x:String x:Key="xg0">http://schemas.datacontract.org/2004/07/Customer</x:String>
                <x:String x:Key="xgSc">http://tempuri.org/</x:String>
              </ssx:XPathMessageContextMarkup>
            </p:XPathMessageQuery.Namespaces>sm:body()/xgSc:CreateCustomer/xgSc:value/xg0:CustomerID</p:XPathMessageQuery>
        </p:Receive.CorrelatesOn>
        <p:Receive.CorrelationInitializers>
          <p:RequestReplyCorrelationInitializer CorrelationHandle="[__handle1]" />
        </p:Receive.CorrelationInitializers>
        <p:ReceiveParametersContent>
          <OutArgument x:TypeArguments="c1:Customer" x:Key="value">[CurrCustomer]</OutArgument>
        </p:ReceiveParametersContent>
      </p:Receive>
      <Assign sap:VirtualizedContainerService.HintSize="255,57">
        <Assign.To>
          <OutArgument x:TypeArguments="x:Int32">[CurrCustomer.CustomerID]</OutArgument>
        </Assign.To>
        <Assign.Value>
          <InArgument x:TypeArguments="x:Int32">[New Random().Next()]</InArgument>
        </Assign.Value>
      </Assign>
      <p:SendReply Request="{x:Reference __ReferenceID0}" DisplayName="SendReplyToReceive" sap:VirtualizedContainerService.HintSize="255,86">
        <p:SendParametersContent>
          <InArgument x:TypeArguments="x:String" x:Key="resultAdd">["Customer Added. ID for " + CurrCustomer.FirstName + " is " + CurrCustomer.CustomerID.ToString()]</InArgument>
        </p:SendParametersContent>
      </p:SendReply>
      <WriteLine sap:VirtualizedContainerService.HintSize="255,59" Text="[&quot;Customer ID Created for &quot; + CurrCustomer.FirstName + &quot; &quot; + CurrCustomer.LastName + &quot;=&quot; + CurrCustomer.CustomerID.ToString()]" />
    </Sequence>
    <Sequence sap:VirtualizedContainerService.HintSize="277,532">
      <Sequence.Variables>
        <Variable x:TypeArguments="p:CorrelationHandle" Name="__handle1" />
        <Variable x:TypeArguments="x:String" Name="lName" />
        <Variable x:TypeArguments="x:Int32" Name="custID" />
      </Sequence.Variables>
      <sap:WorkflowViewStateService.ViewState>
        <scg:Dictionary x:TypeArguments="x:String, x:Object">
          <x:Boolean x:Key="IsExpanded">True</x:Boolean>
        </scg:Dictionary>
      </sap:WorkflowViewStateService.ViewState>
      <p:Receive x:Name="__ReferenceID1" CorrelatesWith="[__handle1]" sap:VirtualizedContainerService.HintSize="255,86" OperationName="AddLastName" ServiceContractName="CustomerService">
        <p:Receive.CorrelatesOn>
          <p:XPathMessageQuery x:Key="key1">
            <p:XPathMessageQuery.Namespaces>
              <ssx:XPathMessageContextMarkup>
                <x:String x:Key="xgSc">http://tempuri.org/</x:String>
              </ssx:XPathMessageContextMarkup>
            </p:XPathMessageQuery.Namespaces>sm:body()/xgSc:AddLastName/xgSc:ID</p:XPathMessageQuery>
        </p:Receive.CorrelatesOn>
        <p:Receive.CorrelationInitializers>
          <p:RequestReplyCorrelationInitializer CorrelationHandle="[__handle1]" />
        </p:Receive.CorrelationInitializers>
        <p:ReceiveParametersContent>
          <OutArgument x:TypeArguments="x:String" x:Key="value">[lName]</OutArgument>
          <OutArgument x:TypeArguments="x:Int32" x:Key="ID">[custID]</OutArgument>
        </p:ReceiveParametersContent>
      </p:Receive>
      <Assign sap:VirtualizedContainerService.HintSize="255,57">
        <Assign.To>
          <OutArgument x:TypeArguments="x:String">[CurrCustomer.LastName]</OutArgument>
        </Assign.To>
        <Assign.Value>
          <InArgument x:TypeArguments="x:String">[lName]</InArgument>
        </Assign.Value>
      </Assign>
      <p:SendReply Request="{x:Reference __ReferenceID1}" DisplayName="SendReplyToReceive" sap:VirtualizedContainerService.HintSize="255,86">
        <p:SendParametersContent>
          <InArgument x:TypeArguments="x:String" x:Key="resultAdd">["last Name " + CurrCustomer.LastName + " added to Customer ID " + CurrCustomer.CustomerID.ToString()]</InArgument>
        </p:SendParametersContent>
      </p:SendReply>
      <WriteLine sap:VirtualizedContainerService.HintSize="255,59" Text="[&quot;Customer Name :&quot; + CurrCustomer.FirstName + &quot; &quot; + CurrCustomer.LastName + &quot; ID : &quot; + CurrCustomer.CustomerID.ToString()]" />
    </Sequence>
  </Sequence>
</Activity>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Technical Lead
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions