Manish Sinha

Hi,

I have created a statemachine workflow and exposed this as web service. Now i want to return workflowinstance from a method exposed through WebServiceResponse Activity. the problem is that i am able to get WorkflowInstanceId but not the workflowinstance.

Interface IHelloWorld

{

Guid Process_Event();

//WorkflowInstance Process_Event();

void Review_Event();

void Approval_Event();

void Completed_Event();

//Guid GetCurrentWorkflow();

}

public partial class HelloWorld : StateMachineWorkflowActivity

{

private Guid myWorkflowInstanceID;

public Guid MyWorkflowInstanceID

{

get { return myWorkflowInstanceID; }

set{myWorkflowInstanceID = value;}

}

private void debug_ExecuteCode(object sender, EventArgs e)

{

Activity currentActivity = (Activity)sender;

System.Diagnostics.Debug.Print("State: {0}", currentActivity.Parent.QualifiedName);

}

private void Process_Event(object sender, EventArgs e)

{

MyWorkflowInstanceID = this.WorkflowInstanceId;

}

}

please help me out.

thanks in advance




Re: Windows Workflow Foundation How to get Workflowinstance from a StateMachineWorkflowActivity ?

Bill Zunis

Manish,

There is a class called StateMachineWorkflowInstance that returns the State's Workflow Instance. Have you tried that

Cheers,

Billz






Re: Windows Workflow Foundation How to get Workflowinstance from a StateMachineWorkflowActivity ?

Tom Lake

Why do you want to return the WorkflowInstance How are you intending to use it after it is returned It is not available from within a workflow. You can't use StateMachineWorkflowInstance either because its constructor takes a WorkflowRuntime and that is not accessible from within a workflow either.




Re: Windows Workflow Foundation How to get Workflowinstance from a StateMachineWorkflowActivity ?

Manish Sinha

Hi,

Since i am using using a workflow exposed as web service, only thing available to the host application(asp.net) is the method exposed through the web service

Now what i do is, i start a workflow runtime , call the web service method which will give the workflowinstance and then use that instance to load the workflow using the already started runtime.

If i dont get the workflowinstance from within the workflow, then how can i manage the different states as well as persistence through a workflow exposed as web service a and asp.net host using the exposed web service.

Thanks in advance,

Manish sinha






Re: Windows Workflow Foundation How to get Workflowinstance from a StateMachineWorkflowActivity ?

msdnjota

I have the same requirement, but with a Sequential Workflow.

Basically, I have an activity that adds other activitities to the workflow instance via the parent activity. But I need the workflow instance to save the changes.

Any help greatly appreciated...





Re: Windows Workflow Foundation How to get Workflowinstance from a StateMachineWorkflowActivity ?

Tom Lake - MSFT

If you haven't already, take a look at the Dynamic Update from workflow sample found at http://msdn2.microsoft.com/en-us/library/ms741713.aspx. If that doesn't help please post the code that you are using that isn't working along with any errors you might be getting.