Hosting WorkflowService (WorkflowRuntime) in IIS using WCF
- Hi,
I'd like to host some kind workflow service (using Windows Workflow Foundation) within the IIS. Therefore I have configured a service file (.svc) and an appropriate web.config file.
When the service starts (managed by IIS?) it should load the WorkflowRuntime instance. Therefore I've created a class implementing the IExtension<ServiceHostBase> interface holding that instance.
Because my application is not directly responsible for creating the ServiceHost (-> IIS) - how can I add this extension to the service host? Is it possible to configure this via the web.config file (<extensions>-Element)? Or do I have to write such a class inheriting from ServiceHostFactoryBase and configuring the service file?
Thank you!
Answers
That's a WCF question, not a WF question
.You can either attach the IExtension using a custom ServiceHostFactory, or inject it using a IServiceBehavior. The latter approach can be implemented using an attribute that you can attach to your service implementation:
[WorkflowBehavior]
public class MyWorkflowEnabledService : IMyWorkflowEnabledService
{
//...
}
There's also a new whitepaper on integrating WCF and WF.
All Replies
- Did you ever found the solution for this ?
That's a WCF question, not a WF question
.You can either attach the IExtension using a custom ServiceHostFactory, or inject it using a IServiceBehavior. The latter approach can be implemented using an attribute that you can attach to your service implementation:
[WorkflowBehavior]
public class MyWorkflowEnabledService : IMyWorkflowEnabledService
{
//...
}
There's also a new whitepaper on integrating WCF and WF.
What I am doing now is the following: when I need the workflow runtime I am going to check if I have an extension, if not I create one. From then on I will reuse this one until my extension is shut down.
private WorkflowRuntime myWFRuntime
{
get
{
myExtension ext ;
if (OperationContext.Current.Host.Extensions.Find<myExtension>()==null)
{
ext = new myExtension();
OperationContext.Current.Host.Extensions.Add<myExtension>(ext);
return ext.WorkFlowRuntime;
}
else
return OperationContext.Current.Host.Extensions.Find<myExtension>().WorkFlowRuntime;
}}
Is this a correct approach ?- That might be problematic due to race conditions — I don't think that ServiceHostBase.Extensions collecition is tread-safe. Attaching the workflow runtime during service activation is IMHO a better design.

