Hosting a self-hosted WF in IIS
Does anyone know if it's possible to host a self-hosted WorkflowServiceHost application in IIS without turning it into a XAMLX file? If so, how?
Furthermore, does anyone have any good guidelines for deploying XAMLX files in general to IIS 7?
Thanks in 开发者_运维技巧advance
You can do the same basic thing by writing your own hosting engine instead of the XAMLX one. You can then load applications via ASP.NET, but have complete control on it's lifespan/lifecycle.
You have to create your own host to load the .XAML
workflows into something like a WorkflowApplication
and manage the lifespan of that workflow. It looks something like this:
private SqlWorkflowInstanceStore _InstanceStore { get; private set; }
private InstanceHandle _MyInstanceHandle { get; private set; }
_InstanceStore = new SqlWorkflowInstanceStore(DataStore.ConnectionString.Replace("MultipleActiveResultSets=True", "MultipleActiveResultSets=False"));
_InstanceStore.HostLockRenewalPeriod = new TimeSpan(0, 0, 30);
_InstanceStore.InstanceEncodingOption = InstanceEncodingOption.None;
_InstanceStore.InstanceLockedExceptionAction = InstanceLockedExceptionAction.BasicRetry;
_InstanceStore.InstanceCompletionAction = InstanceCompletionAction.DeleteNothing;
_MyInstanceHandle = _InstanceStore.CreateInstanceHandle();
var CreateOwnerCommand = new CreateWorkflowOwnerCommand();
var MyView = _InstanceStore.Execute(_MyInstanceHandle, CreateOwnerCommand, TimeSpan.FromSeconds(30));
_InstanceStore.DefaultInstanceOwner = MyView.InstanceOwner;
WorkflowApplication ThisApplication = null;
if (parameters == null)
ThisApplication = new WorkflowApplication(activity);
else
ThisApplication = new WorkflowApplication(activity, parameters);
ThisApplication.PersistableIdle = e => PersistableIdleAction.Unload;
ThisApplication.InstanceStore = this.InstanceStore;
ThisApplication.Run();
There is a bit more to it then just the above, but it gives the basic concepts of how it would work.
EDIT (3/23/2011)
If anyone wants a copy of the basic code to do this, find a way to contact me.
精彩评论