views:

609

answers:

2

Hi,

I have a workflow service (defined declaretively in a .xamlx file) that currently contains one Recieve activity. As you may know, services usually expose more than one operation. And that's what I would like to do with my service too. How do I add more operations to this service? Without WF, that's really easy. Just add as many methods as you wish and decorate them with OperationContract. Then the client can call any of the operations that service offers. In WF4, on the other hand, when I try to add another Recieve activity to the service, I can only add it either before or after an existing activiy. I thought I might use the Pick activity to accomplish this, but I'm just guessing. Is this how I do it? Or should I add another workflow service and add the Receive activity to it? (doesn't sound like a good solution at all). Or perhaps there is a right way to accomplish this?

P.S As you can tell, I'm totally new to WF in general, and WF4 in particular.

Thanks, Avi

+2  A: 

Having a single Receive activity at the start of a workflow is not uncommon, after all there is usually a single event that starts a workflow. And once started it can wait for other messages to arrive. However there is no reason not to have a workflow listen for multiple different at the same time and, as you mentioned, a Pick activity is the way to go. Just drop a Pick on the design surface, add as many PickBrache with Receive activities as you like and you are good to go.

Maurice
Thanks Maurice!Hey, wait a second, you're Maurice, the problem solver :)I'm reading your blog to learn stuff about WF4.Thanks alot my friend.
Avi Shilon
Yes that's me :-)lad you like the blog, there will be more coming soon.
Maurice
OK, I did that and it worked. But (I didn't understand it earlier) now I understand what you said before, that it's quite common for a Receive activity to start a workflow and have other Receive activities listen for subsequent messages. That is actually exactly my scenario. The problem is that I now have several (three) Reveive activities that can all be called at any desired order. Is there a way to make sure that the first call that a client can preform will be on only a specific one, and subsequent calls only on the other two Receive activities?I greatly appreciate your help.
Avi Shilon
Add the first Receive start starts the workflow at the top. After the response is send add a Pick activity and add the other two Receive activities to either branches. Now the running workflow can be resumed with one of two different messages. If you want to accept multiple calls put the Pick activity inside of a DoWhile activity to reactivate the Pick and Receive after a message is handled.
Maurice
A: 

I have a similar scenario where I need to implement multiple Operation contract all of which are part of a single service contract (1 service contract containing multiple operation contracts ) Each opeartion contract is reflected as a large work flow sequential activity with a Recivive activity at the start. I am using .Net 3.5 and I would like one class that implements all of these operation which is what I will expose in my serviceType when I am hosting (windows service) - Can I put all the wf into a single sequential workflow but I am not sure how I will acheive the branching to each Receive activity - Suggestions (.Net 3.5)

Raj