Sharepoint and the WorkflowRuntime Engine (internals)

It seems that the Sharepoint team did a very intensive job in order to hide/encapsulate the Workflow Foundation WorkflowRuntime Engine.
There are some situations were it’s not very handy: for instance, it is a common pattern in workflow foundation to create a custom service , to register it into the workflowRuntime and to call it from custom activities as illustrated below :
 
public class MyCustomService : WorkflowRuntimeService{
 
public void DoSomething()
{
}
 
}
 
 
void Main()
{
           using(WorkflowRuntime workflowRuntime = new WorkflowRuntime())
            {
               workflowRuntime.AddService (new MyCustomService());
               // create a workflow instance that makes use of the MyCustomActivity(see below)
 
            }
}
 
 
class MyCustomActivity : Activity {
 
         protected override ActivityExecutionStatus Execute(ActivityExecutionContext executionContext)
        {
           //get the service
           MyCustomService  cs = executionContext.GetService<MyCustomService >();
           //actually my objective was to call 
            cs.DoSomething();
            
            return ActivityExecutionStatus.Closed;
        }
}
 
 
We cannot do that!!! I cannot  find a way to access the WorkflowRuntime in order to register a WF service.
 
On the other side, in "normal WF" we can dynamically register WF services by adding them in the web.config as illustrated in the WF sdk.
or in my case :
<configuration>
  <configSections>
    <section name="WorkflowRuntime" type="System.Workflow.Runtime.Configuration.WorkflowRuntimeSection, System.Workflow.Runtime, Version=3.0.00000.0, Culture=neutral, PublicKeyToken 31bf3856ad364e35" />
  </configSections>
    <WorkflowRuntime>
      <Services>
        <add type="WorkflowConsoleApplication4.MyworkfowRuntime, WorkflowConsoleApplication4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f3b4fb4cfb3c0030"/>
      </Services>
    </WorkflowRuntime>
  </configuration>
 
 
But when the application starts, you are supposed to provide the WorkflowRuntime section Name as in :
new WorkflowRuntime("WorkflowRuntime")
 
Nowhere can I find this in Sharepoint; no trace of a WorkflowRuntime section in the web.config.
 
–>so  far it seems impossible to add a service.
 
To be fair, what I had in mind was to enumerate the list of all workflow services loaded by sharepoint, so my intention was to write a WF service similar to this :
 
    class MyworkfowRuntime : WorkflowRuntimeService
    {
  
        public ReadOnlyCollection<object> getAllServices()
        {
           return this.Runtime.GetAllServices<object>();
        }
   }
 
Probably should I reflector the whole stuff to find a way…
 
 
 
 
 
Advertisements

2 responses to “Sharepoint and the WorkflowRuntime Engine (internals)

  1. I have the same problem. I would like to access to workflow runtime engine. If you find a solution please contact me.

  2. Hi Serge,
     
    I also have the same problem. Please keep me posted if you can find out any way around this.
     
    Max

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s