none
How do I put multiple ReceiveAndSendReply activities in a single .xamlx?

    Question

  • What I'm looking to do is the equivalent of several OperationContracts under a single ServiceContract.  How do I do this in a declarative service?  All of the examples I've seen only have a single operation in a .xamlx file, which isn't very realistic.

    If I just drop each ReceiveAndSendReply pair after each other in a Sequence, it shows a sequence to the activities that doesn't exist.  And the second RASR doesn't work.  That's clearly wrong.

    I've looked at using a Pick activity with a bunch of ReceiveAndSendReply activites inside but PickBranches have Triggers and Actions and ReceiveAndSendReply doesn't seem to fit that setup.  I could get it to work by dropping the whole RASR pair into the Trigger and having the Action empty but it doesn't feel right.  Is it?

    I also looked at a Parallel activity.  I put two RASR pairs, side by side, and added debug writelines before ("Started branch n") and after ("Finished branch n") each pair.  When I send a message to one, I get both Started branch n messages, then I get the reply, then I get the "Finished branch n" message for the relevant branch.  The other isn't received, as I'd expect.  According to the docs, it "completes when all of its Branches complete or when its CompletionCondition property evaluates to true" but when CompletionCondition "evaluates to true, then the other scheduled elements in the Branches collection are canceled".  Presumably that means that the unused branches above are hanging around for something?  What happens to them?  Cancelling the other branches doesn't feel like the right thing to be doing but should I be cancelling them?

    What's the correct approach to having several OperationContracts in a single ServiceContract?
    Wednesday, February 03, 2010 12:17 PM

Answers

  • Probably what you want to do is use a Pick activity. Instead of using the ReceiveAndSendReply template, drop Receive activities in the triggers of the PickBranches. For each reply you want to generate, right click the receive activity, select "Create SendReply". This copies a new SendReply activity to the clipboard. Now you can paste this SendReply activity in the Action portion of the PickBranch.

    The ReceiveAndSendReply template is just a pre-packaged Sequence with Receive and SendReply activities already pasted inside, this is a convenience feature. Using the Receive/SendReply pair generated manually produces a functionally equivalent messaging pattern.

    Thanks

    Friday, February 05, 2010 12:54 AM

All replies

  • Good question, I remember I asked some like that a while ago

    http://social.msdn.microsoft.com/Forums/en-US/wfprerelease/thread/41ecf7c5-8c74-4ec9-9bdf-437015b17ceb

    and the recommendation are basically to use  RoutingService among othesr;

    I wish we could have a better  partitioning support in WF 4....
    Wednesday, February 03, 2010 1:45 PM
  • Thanks for the reply and the link.  Could this really be how they designed it?  One ServiceContract has one OperationContract?  Surely people don't build real-world web services like that, do they?  Or am I missing something?
    Wednesday, February 03, 2010 3:32 PM
  • Probably what you want to do is use a Pick activity. Instead of using the ReceiveAndSendReply template, drop Receive activities in the triggers of the PickBranches. For each reply you want to generate, right click the receive activity, select "Create SendReply". This copies a new SendReply activity to the clipboard. Now you can paste this SendReply activity in the Action portion of the PickBranch.

    The ReceiveAndSendReply template is just a pre-packaged Sequence with Receive and SendReply activities already pasted inside, this is a convenience feature. Using the Receive/SendReply pair generated manually produces a functionally equivalent messaging pattern.

    Thanks

    Friday, February 05, 2010 12:54 AM
  • Thanks: I remember reading about the right-click option to create the Reply ages ago but I'd completely forgotten about it. 

    I've converted my test Picks to this and everythink works fine.

    Cheers.
    Saturday, February 06, 2010 2:54 PM