Receive Receive Receive Receive Class


An activity that receives a message.

public ref class Receive sealed : System::Activities::Activity
public sealed class Receive : System.Activities.Activity
type Receive = class
    inherit Activity
Public NotInheritable Class Receive
Inherits Activity


The following example shows how to create a Receive activity and add it to a workflow in code.

Variable<string> message = new Variable<string> { Name = "message" };
Variable<string> echo = new Variable<string> { Name = "echo" };
Receive receiveString = new Receive
    OperationName = "Echo",
    ServiceContractName = "Echo",
    CanCreateInstance = true,
    //parameters for receive
    Content = new ReceiveParametersContent
        Parameters = 
            {"message", new OutArgument<string>(message)}

Sequence workflow = new Sequence()
    Variables = { message, echo },
    Activities =
            new WriteLine
                Text = new InArgument<string>(env =>("Message received: " + message.Get(env)))
            new Assign<string>
                Value = new InArgument<string>(env =>("<echo> " + message.Get(env))),
                To = new OutArgument<string>(echo)
            //parameters for reply
            new SendReply
                Request = receiveString,                            
                Content = new SendParametersContent
                    Parameters =
                        { "echo", new InArgument<string>(echo) }
            new WriteLine
                Text = new InArgument<string>(env =>("Message sent: " + echo.Get(env)))

service = new WorkflowService
    Name = "Echo",
    Body = workflow

The following example shows how to create a Receive activity and add it to a workflow service in XAML.

<WorkflowService mc:Ignorable="sap" ConfigurationName="Service1" Name="Service1" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces" xmlns="" xmlns:mc="" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:p="" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clr-namespace:System;assembly=System.Core" xmlns:sad="clr-namespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="" xmlns:scg="clr-namespace:System.Collections.Generic;assembly=System" xmlns:scg1="clr-namespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clr-namespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clr-namespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clr-namespace:System.Data;assembly=System.Data" xmlns:sl="clr-namespace:System.Linq;assembly=System.Core" xmlns:ssa="clr-namespace:System.ServiceModel.Activities;assembly=System.ServiceModel.Activities" xmlns:st="clr-namespace:System.Text;assembly=mscorlib" xmlns:x="">  
  <p:Sequence sad:XamlDebuggerXmlReader.FileName="c:\Projects\WFServiceSnippets\WFServiceSnippets\Service1.xamlx" sap:VirtualizedContainerService.HintSize="277,644" mva:VisualBasic.Settings="Assembly references and imported namespaces serialized as XML namespaces">  
      <p:Variable x:TypeArguments="CorrelationHandle" Name="__handle1" />  
      <p:Variable x:TypeArguments="x:String" Name="Message" />  
      <p:Variable x:TypeArguments="x:String" Name="Echo" />  
      <scg3:Dictionary x:TypeArguments="x:String, x:Object">  
        <x:Boolean x:Key="IsExpanded">True</x:Boolean>  
    <Receive x:Name="__ReferenceID0" CanCreateInstance="True" DisplayName="ReceiveString" sap:VirtualizedContainerService.HintSize="255,90" OperationName="Echo" ServiceContractName="Echo">  
        <RequestReplyCorrelationInitializer CorrelationHandle="[__handle1]" />  
        <p:OutArgument x:TypeArguments="x:String" x:Key="message">[Message]</p:OutArgument>  
    <p:WriteLine sap:VirtualizedContainerService.HintSize="255,61" Text="[&quot;Message received: &quot; + Message]" />  
    <p:Assign sap:VirtualizedContainerService.HintSize="255,58">  
        <p:OutArgument x:TypeArguments="x:String">[Echo]</p:OutArgument>  
        <p:InArgument x:TypeArguments="x:String">["&lt;echo&gt; " + Message]</p:InArgument>  
    <SendReply Request="{x:Reference __ReferenceID0}" DisplayName="SendReply" sap:VirtualizedContainerService.HintSize="255,90">  
        <p:InArgument x:TypeArguments="x:String" x:Key="echo">[Echo]</p:InArgument>  
    <p:WriteLine sap:VirtualizedContainerService.HintSize="255,61" Text="[&quot;Message sent: &quot; + Echo]" />  


The Receive activity can receive a single item or multiple items depending on the type of receive content used.


When a workflow contains multiple Receive activities with the same operation name, the CorrelatesOn property must be set to the same set of correlation queries.


Receive() Receive() Receive() Receive()

Initializes a new instance of the Receive class.


Action Action Action Action

Gets or sets the value of the action header of the message.

CacheId CacheId CacheId CacheId

Gets the identifier of the cache that is unique within the scope of the workflow definition.

(Inherited from Activity)
CanCreateInstance CanCreateInstance CanCreateInstance CanCreateInstance

Gets or sets a value that indicates whether a new workflow instance is created to process the message if the message does not correlate to an existing workflow instance.

Constraints Constraints Constraints Constraints

Gets a collection of Constraint activities that can be configured to provide validation for the Activity.

(Inherited from Activity)
Content Content Content Content

Gets or sets the data to receive. The content can be either a ReceiveMessageContent or a ReceiveParametersContent.

CorrelatesOn CorrelatesOn CorrelatesOn CorrelatesOn

Gets or sets the MessageQuerySet used to query the message to extract correlation data.

CorrelatesWith CorrelatesWith CorrelatesWith CorrelatesWith

Gets or sets a correlation handle that is used to route the message to the appropriate workflow instance.

CorrelationInitializers CorrelationInitializers CorrelationInitializers CorrelationInitializers

Gets a collection of correlation initializers that initialize query-based, context, callback context, or request-reply correlations with a Send activity runs.

DisplayName DisplayName DisplayName DisplayName

Gets or sets an optional friendly name that is used for debugging, validation, exception handling, and tracking.

(Inherited from Activity)
Id Id Id Id

Gets an identifier that is unique in the scope of the workflow definition.

(Inherited from Activity)
Implementation Implementation Implementation Implementation

Gets or sets the delegate that returns an Activity that contains the execution logic.

(Inherited from Activity)
ImplementationVersion ImplementationVersion ImplementationVersion ImplementationVersion

Gets or sets the version of the implementation used.

(Inherited from Activity)
KnownTypes KnownTypes KnownTypes KnownTypes

Gets a collection of known types for the operation.

OperationName OperationName OperationName OperationName

Gets or sets the name of the operation implemented by the Receive.

ProtectionLevel ProtectionLevel ProtectionLevel ProtectionLevel

Gets or sets a value that indicates the protection level for the operation.

SerializerOption SerializerOption SerializerOption SerializerOption

Gets or sets a value that specifies the serializer to use for this operation.

ServiceContractName ServiceContractName ServiceContractName ServiceContractName

Gets or sets the name of the service contract.


CacheMetadata(ActivityMetadata) CacheMetadata(ActivityMetadata) CacheMetadata(ActivityMetadata) CacheMetadata(ActivityMetadata)

Creates and validates a description of the activity's arguments, variables, child activities, and activity delegates.

(Inherited from Activity)
Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
FromOperationDescription(OperationDescription) FromOperationDescription(OperationDescription) FromOperationDescription(OperationDescription) FromOperationDescription(OperationDescription)

Returns the receive activity from the given contract operation description.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
OnCreateDynamicUpdateMap(UpdateMapMetadata, Activity) OnCreateDynamicUpdateMap(UpdateMapMetadata, Activity) OnCreateDynamicUpdateMap(UpdateMapMetadata, Activity) OnCreateDynamicUpdateMap(UpdateMapMetadata, Activity)

Raises an event when creating dynamic update map.

(Inherited from Activity)
ShouldSerializeCorrelatesOn() ShouldSerializeCorrelatesOn() ShouldSerializeCorrelatesOn() ShouldSerializeCorrelatesOn()

Returns a value that indicates whether the CorrelatesOn property has changed from its default value and should be serialized.

ShouldSerializeDisplayName() ShouldSerializeDisplayName() ShouldSerializeDisplayName() ShouldSerializeDisplayName()

Indicates whether the DisplayName property should be serialized.

(Inherited from Activity)
ToString() ToString() ToString() ToString()

Returns a String that contains the Id and DisplayName of the Activity.

(Inherited from Activity)

Applies to

See also