index > Windows Workflow Foundation > Correct way to create a State Machine

Correct way to create a State Machine

Hi

I am trying to create a statefull booking service (state machine workflow exposed as webservice). It has the following states. Created, TicketSelected, Pay, Comfirmed. My question is twofold.

First:

The Created state is the Initial state and has an eventdriven activity that waits for a webserivce call to arrive. When this comes i need to do some actions and the wait for a new webservice call (SelectTicket) so I can go to the "TicketSelected" state. My question is. Where should i wait for this "SelectTicket" webservice call? In the "Created" state? og should i create a new state called "WaitForTicketSelect" ?

I guess my problem is that my Created state would have to listen for two web service calls, if i do not have the "WaitForTicketSelect". Of these two WS calls CreateTicket would have to come first (marked as IsActivating) but it doesnt seem "clean" to have these two webservice inputs..or does it?

Second:

Lets we now are in the "TicketSelected" state. How do i insure that this particluar Booking is "corrolated" so i can have multiple instances running? Would i have to send the workflow instance id with all the webservice call as parameter or is there some build-in webservice correlations functionality?

Thanks in regards if you take your time to read and come with inpout to the above.

Regards

Anders K.J

anderskj1

Anders

For #1, you can model two different events on the Created state, one for your initial call, and one for the event that should transition to the ticket selected state. Or, you could do as you say and add another state that goes between those two. Either way will work. In the first case, your activating sequence can just use SetState to go back to the Created state to wait for the second event.

For #2, there is a need to pass the worklfow instance id each time an event or web service input is sent. if you are using the Publish as Web Service functionality, or the equivalent manual process, the code is already in place to manage the id via cookies. This means your client code must support cookies for web services and correctly send back any cookies sent to it. Use the CookieContainer in .NET client code to do this.

You can also implement your own mechanism for instance correlation if you need to use something other than cookies.

Matt




See What You Can Learn -- http://www.pluralsight.com/courses/IntroducingWF.aspx
Matt Milner - Pluralsight

Thanks for your input.

I am a little lost when it comes to WF as WebServices. I have my my StateMachine workflow project. I have choosen "Publish as WebService" and this seems to work fine with state.

Now lets say i need to corrolate this manually (i need to call the Web Service from a WinForm GUI). I need to corrolate the Workflow Instances based on eg. the Workflow Instace ID which i return to the GUI in the CreateBooking WebSerivice call.

Now where do I do this "manual" corelation? I could always send the instance ID with every web service call, but where should i intercept this call and make sure that the web serivice call is delegated to the correct worfklow instance (based on the workflow ID I eg, send as the first parameter?)

Thanks in regards.

Anders

anderskj1
reply 3

You can use google to search for other answers

 

More Articles

• Create ".Rules" file dynamically
• Converting existing workflow from code based definition to xoml
• CreateWorkflow failing validation
• recursive workflow
• Possible to make working WWF runtime on Windows 2000 ?
• retrieving custom activity properties set at runtime
• Workflow event does not get fired
• Executing the workflow under a custom permission set
• How to create a new workflow instance at the same time completing...
• InnerException {"Event \"HighRiskEvent\" on interf...
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Problem with custom CallExternalMethodAc
• Error while executing the SQLDatabaseAct
• Deserialize XAML
• SqlWorkflowPersistenceService not loadin
• Getting exception: retrieve loaderexcept
• Workflow Services semantic error!!!
• Should I use WWF?
• Which is a better way to initialize work
• Some sample about AcivityBind and Workfl
• waiting for multiple events generated dy
• Hide "Bind to new member" tab
• workflow compiler with RuleconditionRefe
• Is Location.Top the same as Bounds.Top?
• How to make a StateMachine which show th
• SetState - how to create a Role Based one?

Hot Articles

• New Rules samples
• ExternalDataExchangeService API usage is
• Binding list to activity property
• Roles in WWF last versions
• Major compiler Error
• How to access <Activity Reference...&
• What's the type activity to implement th
• How to use the cancel handler?
• Unknown error in workflow1.xoml
• Using an enum as a dependencyProperty
• Correct way to configure SQlPersistence
• How do you handle Persistence with WWF B
• ExternalDataExchangeService's method Int
• WorkflowCompiler -
• Parallel Activity issue in Sequence Work

Recommend Articles

• Hands on Labs for Beta 2.2
• How to get the present Activity the work
• The workflow hosting environment does no
• Persistenced Workflow Instances
• RaiseDataChanged and DuplicateInstanceId
• Is Sequential workflow can be a base wor
• Problem with Windows Workflow Foundation
• Workflow Runtime Hosted in Windows Service
• CallExternalActivity Vs. CodeActivity ca
• Start the workflow from the "Break
• Workflows termined due to not serializab
• WorkflowMenuCommands.Undo not working?
• navigate page/forms?
• How to add some new properties or new pa
• WorkflowTrace.log being generated in Beta2