mpco

< xml:namespace prefix = v ns = "urn:schemas-microsoft-com:vml" />  < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

static void Main(string[] args)

        {

           

            lh.Workflow1 ws = new lh.Workflow1();

            string sid = ws.Step1("P-MMMMM");

            Console.WriteLine(sid);

            ws.Step2("P-MMMMM", "MMM");

// above line causes runtime error

//.InvalidOperationException: Current session has no workflow instance associated

//with it. Send activation message to start new instance in current session.

           

  
How can I call Step2 method on the web service exposed workflow           

 

          

           

        }




Re: Windows Workflow Foundation web service exposed workflow

Arjun Banker

Before calling methods on the workflow proxy, set the cookie container:

ws.CookieContainer = new System.Net.CookieContainer();





Re: Windows Workflow Foundation web service exposed workflow

Leela

Hi,

I am facing the same issue.

Even though I have set the coookie container I am not able to solve the issue.

My Scenario:

I am currently working on the expense Module.

Step 1: Submit the expense

Step 2: Manager will Approve/Reject based upon his decision.

I have implemented the WorkFlow using Sequential WorkFlow.

Then I published teh workFlow as WebService and trying to use in ASP.NET application.

I have three pages:

In Login Page I am instantiating the workflow

ExpenseClaim.ExpClaimWorkFlow_WebService ws = new ExpenseClaim.ExpClaimWorkFlow_WebService();

ws.CookieContainer = new System.Net.CookieContainer();

//Storing the instance in the USession

this.Session[Constants.wsKey] = ws;

In Submit Page I am submitting the Report by calling SubmitExpenseReport(claimNumber);

// Creating the current workflow instance

ExpenseClaim.ExpClaimWorkFlow_WebService ws = this.Session[Constants.wsKey] as ExpenseClaim.ExpClaimWorkFlow_WebService;

ws.SubmitExpenseReport(claimNumber);

In Approve/Reject Page I am calling the Approve ExpenseReport Method to approve which will be done by manager.

// Creating the current workflow instance

ExpenseClaim.ExpClaimWorkFlow_WebService ws = this.Session[Constants.wsKey] as ExpenseClaim.ExpClaimWorkFlow_WebService;

ws.ApproveExpenseReport(e.CommandArgument.ToString());

While I call submitExpenseReport I am able to access Workflow.

But when I call ApproveExpenseReport I am getting an error message saying

Server was unable to process request. ---> Current session has no workflow instance associated with it. Send activation message to start new instance in current session.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> Current session has no workflow instance associated with it. Send activation message to start new instance in current session.

Source Error:

Line 94:     [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/ApproveExpenseReport", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 95:     public void ApproveExpenseReport(string claimNumber) {
Line 96:       this.Invoke("ApproveExpenseReport", new object[] {
Line 97:             claimNumber});
Line 98:     }





Re: Windows Workflow Foundation web service exposed workflow

Indigo Cowboy

Hi Leela, you have to add cookie to proxy before later calls to workflow webInputActivity. Here is example

1. First call method and create workflow on webservice

ConsumerLoan.ConsumerLoan_WebService proxy = new PSClient.Test.ConsumerLoan.ConsumerLoan_WebService();

proxy.CookieContainer = new System.Net.CookieContainer();

proxy.SubmitForm("Form");

2. Save Cookie data from proxy received after first call

System.Net.Cookie wfId = _Proxy.CookieContainer.GetCookies(new Uri(_Proxy.Url))[0];

System.Net.Cookie _Cookie = new Cookie(wfId.Name, wfId.Value, wfId.Path, wfId.Domain);

3. Use new cookie for later calls, as you will see cookie saves workflow instanceId in order to connect to wright workflow instance on server

ConsumerLoan.ConsumerLoan_WebService proxy = new PSClient.Test.ConsumerLoan.ConsumerLoan_WebService();

proxy.CookieContainer = new CookieContainer();

proxy.CookieContainer.Add(_Cookie);

proxy.FinishProcess("Process finished");

Does this helps

Indigo Cowboy





Re: Windows Workflow Foundation web service exposed workflow

Leela

Hi Indigo,

I am using ASPPersistence the WF ID is storing in the DB.

Still whether I need to use cookie to retrieve the WF ID.

I am having three calls SubmitReport,Approve Report and Reject Report.

All the Calls are in three different Page.





Re: Windows Workflow Foundation web service exposed workflow

Indigo Cowboy

If I understood your question I thing that you can choose. Tha main thing is that after you create proxy in order to call Approve Report or Reject Report you should add Cookie to proxy. In cookie constructor you should pass something like this, If you knwo wwfId from persistance database, than you can use that one

Cookie cookie = new Cookie("WF_WorkflowInstanceId", DatabaseWWFIdValue /*"ef75bbca-1bf7-4f92-823e-aa5cf0418d0b"*/, "/", "localhost");

Hope that this is the answer that you expected.

Indigo Cowboy





Re: Windows Workflow Foundation web service exposed workflow

Leela

Hi ,

I am using the below code still I face the problem.

Please help. I am very new to workflow and it is taking up my lot of time.

protected void btnSubmit_Click(object sender, EventArgs e)

{

localhost.ExpClaimWorkFlow_WebService ws = new localhost.ExpClaimWorkFlow_WebService();

ws.CookieContainer = new System.Net.CookieContainer();

ws.SubmitExpenseReport("284");

wfId = ws.CookieContainer.GetCookies(new Uri(ws.Url))[0];

_Cookie = new Cookie(wfId.Name, wfId.Value, wfId.Path, wfId.Domain);

this.Session["_cookieValue"] = _Cookie;

}

protected void btnApprove_Click(object sender, EventArgs e)

{

localhost.ExpClaimWorkFlow_WebService ws = new localhost.ExpClaimWorkFlow_WebService();

ws.CookieContainer = new CookieContainer();

_Cookie= (Cookie)Session["_cookieValue"];

ws.CookieContainer.Add(_Cookie);

ws.ApproveExpenseReport("284");

}

System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: The workflow hosting environment does not have a persistence service as required by an operation on the workflow instance "f41d66f2-43c0-4b32-b1ca-28162c4252f0".
at System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor, WorkflowInstance workflowInstance)
at System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationContext context, WorkflowInstance workflowInstance)
at System.Workflow.Runtime.WorkflowRuntime.GetWorkflow(Guid instanceId)
at System.Workflow.Activities.WorkflowWebService.Invoke(Type interfaceType, String methodName, Boolean isActivation, Object[] parameters)
at ExpenseClaimWorkFlow.ExpClaimWorkFlow_WebService.ApproveExpenseReport(String claimNumber) in C:\Documents and Settings\leelakrishnan\Local Settings\Temp\_l_xpdsr.cs:line 46
--- End of inner exception stack trace ---

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.InvalidOperationException: The workflow hosting environment does not have a persistence service as required by an operation on the workflow instance "f41d66f2-43c0-4b32-b1ca-28162c4252f0".
at System.Workflow.Runtime.WorkflowRuntime.InitializeExecutor(Guid instanceId, CreationContext context, WorkflowExecutor executor, WorkflowInstance workflowInstance)
at System.Workflow.Runtime.WorkflowRuntime.Load(Guid key, CreationContext context, WorkflowInstance workflowInstance)
at System.Workflow.Runtime.WorkflowRuntime.GetWorkflow(Guid instanceId)
at System.Workflow.Activities.WorkflowWebService.Invoke(Type interfaceType, String methodName, Boolean isActivation, Object[] parameters)
at ExpenseClaimWorkFlow.ExpClaimWorkFlow_WebService.ApproveExpenseReport(String claimNumber) in C:\Documents and Settings\leelakrishnan\Local Settings\Temp\_l_xpdsr.cs:line 46
--- End of inner exception stack trace ---

Source Error:

Line 94:     [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/ApproveExpenseReport", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
Line 95:     public void ApproveExpenseReport(string claimNumber) {
Line 96:       this.Invoke("ApproveExpenseReport", new object[] {
Line 97:             claimNumber});
Line 98:     }