WorkflowHostingEndpoint.OnGetInstanceId(Object[], OperationContext) Method

Definition

Override to return the instance ID for the workflow instance being created.

protected public:
 virtual Guid OnGetInstanceId(cli::array <System::Object ^> ^ inputs, System::ServiceModel::OperationContext ^ operationContext);
protected internal virtual Guid OnGetInstanceId (object[] inputs, System.ServiceModel.OperationContext operationContext);
abstract member OnGetInstanceId : obj[] * System.ServiceModel.OperationContext -> Guid
override this.OnGetInstanceId : obj[] * System.ServiceModel.OperationContext -> Guid
Protected Friend Overridable Function OnGetInstanceId (inputs As Object(), operationContext As OperationContext) As Guid

Parameters

inputs
Object[]

The inputs to the service operation.

operationContext
OperationContext

The operation context of the service operation.

Returns

The instance ID for the newly created workflow instance.

Examples

The following example shows how to implement the OnGetInstanceId method.

protected override Guid OnGetInstanceId(object[] inputs, OperationContext operationContext)
{
    //Create was called by client
    if (operationContext.IncomingMessageHeaders.Action.EndsWith("Create"))
    {
        return Guid.Empty;
    }
    //CreateWithInstanceId was called by client
    else if (operationContext.IncomingMessageHeaders.Action.EndsWith("CreateWithInstanceId"))
    {
        return (Guid)inputs[1];
    }
    else
    {
        throw new InvalidOperationException("Invalid Action: " + operationContext.IncomingMessageHeaders.Action);
    }
}

Remarks

Return null to indicate that an instance ID should be automatically generated.

Applies to