Windows Workflow Foundation 3


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.
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)
Mick - if you are using the built-in WS input and output activities - why do you need or even want to get the WorkflowRuntime?
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
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...:)
 
 
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)
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!!! ;)

Related Links

How to display the provider type summary in RuleSetDialog
Windows WF3.0 - get activity information from TrackingRecord object
Workflow Rules - Chaining for Indexers
WCSF PageFlow
front end
Dynamic Workflow Creation
ApplyworkflowChanges takes long time and some time crashes the application.
CLR20r3 Error when i run exe file (C#)
Process is terminated due to StackOverflowException
HandleExternalEvent: event filter / correlation
SqlTrackingService & User Events
How to change the sendemail activity property at run time?
Question on Queue Management
Load rules in the Designer Rehosting demo
IExtendedUIService must be installed
Does WF support transactions?

Categories

MSDN
Microsoft Office for D...
Windows Embedded Standard
SQL Server (Pre-release)
Microsoft Atlas API: D...
OneDrive Development
Microsoft Partner Center
Skype for Business
Visual Studio General ...
Submitting and Publish...
Promote Your App
App & Ad Unit Management
XboxLiveDevelopment
Developing Windows Des...
Media Foundation Devel...
Network Monitor
Application Security f...
Windows Desktop Pro-Au...
Access for Developers
Azure Search
Azure CDN
Azure Log Analytics
Cognitive Services
Azure DevTest Labs
Azure Database for Pos...
Windows Workflow Found...
Team Foundation Server...
The Forum of Sho
Debugger Canvas
ISV Open Discussions
Visual Studio Smart De...
SQL Server Tools
SQL Server Data Access
SQL Server XML
SQL Server Replication
SQL Server High Availa...
Getting started with S...
Database Mirroring
SQL Server Data Wareho...
Standard 2009: Embedde...
Standard 2009: Tools
Standard 7: Components...
Windows Embedded Compa...
SQL Server 2012 Setup ...
SQL Server 2012 PowerP...
SQL Server 2012 High A...
SQL Server 2012 Analys...
SQL Server 2012 Databa...
Windows Live Messenger...
CRM Deployment
Bing Maps REST, SOAP, ...
Bing Maps Web Controls
SharePoint Server Prot...
Visio General Question...
Getting Started with S...
Visual Studio & Silver...
Accessing Web Services...
WCF RIA Services with ...
PivotViewer Control wi...
Silverlight for Window...
Reference Source Serve...
Search Server: Install...
Visual Studio Report C...
Retired InfoPath Forms...
Project Online General...
.NET Platform Architec...
AppFabric Service and ...
Building Windows Store...
App Producer (archived)
Commerce Server 2002 a...
Game Technologies: Aud...
Hobbyist Zone
Moderator Posting Only...
MS-Build, Multi-Target...
Network Class Library ...
Office Development wit...
Popfly General Discussion
Search Server: Known B...
Search Server: Report ...
Sharepoint Development...
Small Business Applica...
Software Transactional...
SQL Server 2014 In Azu...
Transactions Programming
Tools for Windows Stor...
Visual Basic for Appli...
Visual C# Express 2008...
Visual C# Language
Visual C++ Express Edi...
Visual Studio 2008 Exp...
Visual Studio Class De...
Visual Studio UI Autom...
WCF Data Services (Pre...
Windows Developer Prev...
Windows Live Controls ...
Windows MultiPoint Mou...
Windows Presentation F...
Working with Data in W...
Mango Update (Archived)
Windows Phone Preview ...
Kinect for Windows v2 SDK

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile