Hi!
I need examples of apps running in asp.net 2.0 using WWF (state machine WF) and the beta 2.2
At least I need some insigths about how to build this app, because all the examples that I found, use a class called WorkflowWebRequestContext that is not present in the beta 2.2 framework
My questions (apart from examples are)
1) How should I create the runtime
2) How can I use the instance from a page ... There will be 5 or more pages ... The first one will create the instance and the others will fire events to the instance, but I don't know how to fire the events and make the instance works ...
Please, I really need help
Thanks
Andres

WWF in asp.net and beta 2.2
gnick
appler
ok i add it to the application startup and it work but i have another question
now the workflow hosted under the asp.net process this mean if the server down my workflow 's down and if i have sechdule tasks it's not gone executed coz the server is down what do u think about this
Thanks,
Tamer
SkotChadwick
Andres,
Here is how I am doing currently in my project. I ran across the same problem last week and Paul Andrew and Mark Schmidt were very helpful to me, so let me attempt to return the favor.
In my global.asax I have
---------------------------------------------------------------------------------------------
<%
@ Import Namespace="System.Workflow.Runtime"%> Public Shared workflowRuntime As WorkflowRuntime = New WorkflowRuntime() Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)workflowRuntime.StartRuntime()
End Sub----------------------------------------------------------------------------------------------------------------------
In the page that runs the workflow I have
----------------------------------------------------------------------------------------------
Imports
SystemImports
System.DataImports
System.Collections.GenericImports
System.GlobalizationImports
System.ThreadingImports
System.Workflow.RuntimeImports
System.Workflow.Runtime.HostingPartial
Class ReferredBySearch Inherits System.Web.UI.Page 'A workflow is always run asychronously; the main thread waits on this event so the program ' doesn't exit before the workflow completes Shared WaitHandle As New AutoResetEvent(False) Public dt As DataTable Private Sub StartWorkflow() ' Set up the parameters Dim parameters As Dictionary(Of String, Object) = New Dictionary(Of String, Object)()parameters.Add(
"FirstName", txtFirstName.Text)parameters.Add(
"LastName", txtLastName.Text) 'NOTE: This requires the configuration section to be named "WorkflowRuntime". Dim workflowRuntime As WorkflowRuntime = Global.ASP.global_asax.workflowRuntime If Not workflowRuntime.IsStarted ThenworkflowRuntime.StartRuntime()
End If
AddHandler workflowRuntime.WorkflowCompleted, AddressOf OnWorkflowCompleted AddHandler workflowRuntime.WorkflowTerminated, AddressOf OnWorkflowTerminated'Workflow.findReferrer is the name of the project/workflow
Dim workflowInstance As WorkflowInstance = workflowRuntime.CreateWorkflow(GetType(Workflow.findReferrer), parameters, Guid.NewGuid)
workflowInstance.Start()
WaitHandle.WaitOne()
workflowRuntime.StopRuntime()
End Sub Protected Sub btnNameSearch_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNameSearch.ClickStartWorkflow()
End Sub Public Sub OnWorkflowCompleted(ByVal sender As Object, ByVal e As WorkflowCompletedEventArgs) Dim t As DataTable = CType(e.OutputParameters("dtReferrer"), DataTable)GridView1.DataSource = t
GridView1.DataBind()
WaitHandle.Set()
End Sub Public Sub OnWorkflowTerminated(ByVal sender As Object, ByVal e As WorkflowTerminatedEventArgs)Response.Write(e.Exception.Message) 'Just for now until I expand this
WaitHandle.Set()
End SubEnd
Class---------------------------------------------------------------------------------------------------------------------------
My web.config looks like this
---------------------------------------------------------------------------------------------------------------------------
<
configSections><
section name="WorkflowRuntime" type="System.Workflow.Runtime.Configuration.WorkflowRuntimeSection, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></
configSections><
WorkflowRuntime Name="WorkflowServiceContainer"><
Services><
add type="System.Workflow.Runtime.Hosting.ASPNetThreadingService, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </Services></
WorkflowRuntime><assemblies>
<
add assembly="System.Workflow.Activities, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><
add assembly="System.Workflow.ComponentModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><
add assembly="System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></
assemblies><
httpModules><
add name="WorkflowHost" type="System.Workflow.Runtime.Hosting.WorkflowWebHostingModule, System.Workflow.Runtime, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/></
httpModules>---------------------------------------------------------------------------------------------------------------------------
The workflow I created runs and returns a datatable back to the web page. This is what I have and it works with beta 2.2
If anyone has any pointers I would also greatly appreciate it, as I am new to WWF but really think that it will change the way in which we write apps, BIG TIME!!!
-John
Kieme Ile
I agree. But do not have a solution. Can anyone suggest a pattern to address this
-John
Vaidotas
ExternalDataExchangeService should i add it to the global too as static member actually i moved it to the global but still have problems
ExternalDataExchangeService dataService;dataService = ASP.global_asax.dataService;
messageService =
new MyWorkFlow.MessageService();dataService.AddService(messageService);
it work fine for first time but on the second one i get this error
An instance of ExternalDataExchangeService of type Escalation.IMessageService already exists in the runtime container
this errors is drive me crazy i'm doing gr8 with windows app but now with asp.net i can't do it oh my god
hope you can help
Thanks in advanced
MStrange
The first thing to recognize here, is that you'll need a more reliably hosting mode to work with this. Personally my opinion is: while hosting WF in ASP.NET can be seen as useful (and possibly simpler for some scenarios), this is only an acceptable for short-lived workflows such as page flows (modeling page interactions). ASP.NET most certainly is *not*, to me, an acceptable hosting environment for long-running workflows.
Now, I'll be honest and tell you that I don't know what an alternative hosting model might be. Most likely, we won't have that kind of robust hosting environment until BizTalk 200X (with X>6) ships with WF facilities (and I don't know how much change we'll need to see in WF itself for this to be a reality), but you might get at least something better using some form of clustering meanwhile. Perhaps you can host your ASP.NET app in a windows cluster. I would consider hosting my long-running workflows inside a Windows Service instead, and take advantage of the SCM facilities for automatic restarting of failed services, and possibly look into clustering the service in an active/passive fashion. This does bring a few problems with it, of course, and will take quite a bit more work (particularly communicating the workflows in your custom host with the external applications that access it).
Anyone has any other thoughts on this