Beta 2.2 - accessing current workflowRuntime woes.......from an ASP.NET Web Service

Hi all, (specifically as a ASP.NET ws)

In beta 2 - I used the ...WorkflowRuntime.Current a fair bit in this solution.

It's not there anymore - I've seen some posts on some 'workarounds' or new ways to do it (i.e. instantiate your own runtime in the global.asax and store it somewhere safe - e.g. Application, static class etc.)

Here in lies my problem.

1) I created a standard sequential workflow and added the WS receive + WS response shapes - bound them and added a couple more code shapes. Assigned a simple interface to the WS Receive Activity.

2) Publish as WS....all good :)...so far....

3) Add a global.asax and add code to create my own WorkflowRuntime + add a couple of DataExchange services (no rocket science)

4) The WS info pages come up and I can even enter values in the browser (as my WS uses simple types - strings) and hit 'OK' to run the WS.

5) The WS runs and I get an error from 'WebServiceHost' stating that "Runtime could not be created, as only one is allowed per App Domain"

6) So it looks like somehow it doesnt recognise I've added one.
(so apart from using reflection on the AppDomain to pull the runtime out....any ideas )

I didnt do anything hard, and I was running it under the vs.net personal web server and not IIS.

Any thoughts

Many thanks,

Mick.




Answer this question

Beta 2.2 - accessing current workflowRuntime woes.......from an ASP.NET Web Service

  • simserob2

    Thanks Jon,

    It's a shame that exposing via as WS has taken this tune - of 'being a simple exposed' operation

    Through the beta cycle up until now, we've always had direct access to the runtime until beta 2.2.

    I dont mind creating and hosting my own runtime, as long as the other activities were able to see it. (Doesnt look like it.)

    I like the WS approach as it's a logical/physical entry/exit point to and from workflow.

    I also quite like the whole data queue approach when communicating and syncing with state based workflows (hence the manager type approach)

    Thanks for your thoughts.

    Cheers,

    Mick.

    p.s. Morale to the story.....dont upgrade to Beta 2.2 2 hours before a webcast!!! ;)



  • Mark Kuether

    Thanks for your response guys.

    I figured that the WS just goes and creates it's own runtime without checking if one already exists.

    To the question as to why I need to access it

    Basically I'm exposing 'Workflow Services' via a WebService - tidy, declarative etc.etc.

    Simply - within the webservice, I expose a sequential workflow (serves as a 'manager') and a whole series (70+) dynamically loaded State Driven workflows.

    One of the many reasons as to why I want to access the runtime, is to be able to 'add the DataExchange' class(es) so I can communicate to the State Workflows via Events (handleExternalEvents etc etc)

    (One of the main reasons for the 'manager' workflow - is to alleviate the need that the Webservice has on SessionID cookies being tied directly into a running/persisted workflow. The 'manager' workflow gets created for each call and looks into the received data to determine the path it should immediately take with the current call)

    So - there are a whole bunch of other reasons why I need access to the runtme, but this is the simplest.

    Deriving from an Activity gives me access to the runtime too late, as I need to get access to it at AppOnStart in the Global.asax (I suppose - I could start a very simple Workflow that contains that one shape and pass the reference back out of this workflow)

    To add additional services to the runtime, it first needs to be stopped, so it's going to get ugly stopping the runtime, in the middle of a workflow, that then needs to start up again...etc...etc...etc....the more you dig, the more code.

    So at this point, I'm looking to step back from this and create a native WCF service, and expose and host the WF environment in there - and removing the WS Receives etc.

    If either of you have good ideas....I'm all ears...:)



  • Noah

    Mick,
    the error is not that it can't find your runtime, it is that it ALREADY found one. The base class for the generated web services from a WF already has code to create an store a reference to the runtime. so, if you are in the same web application and trying to create one too, then you are going to have problems.

    so, back to Jon's question, what are you trying to do with the runtime If you want to access it in your web service, then derive from the WorkflowWebService and then use the property to get to the instance of the runtime.

    Matt



  • AU.T

    I think the reason they are not exposing it - is that mixing WebServiceInput with HandleExternalEvent doesn't sound like a good idea to me.

    I think you are right to create you own ws host and manage the workflows manually.

    IMO - WebServiceInput is only really for the simplest of Web Service applications. It is really for workflow that is going to have one operation - or one that is going to have multiple operations - which have to be called in a set order (or at least one has to be called first) and where the client is going to support HTTP sessions. Any other kind of scenario you should build your own host (at least for now that is where everything stands I think)



  • hazemabolrous

    Mick - if you are using the built-in WS input and output activities - why do you need or even want to get the WorkflowRuntime

  • Beta 2.2 - accessing current workflowRuntime woes.......from an ASP.NET Web Service