locked
Need help/advice regarding Workflow Services, IIdentity, Message Correlation etc. RRS feed

  • Question

  • All,

     

    Short version- How do you do this with all custom, code-based activities, assuming that the Pick itself is a designer element.

     

    Long Version:

    I've been working with WF4 for a few months and am currently developing a system that will be used for monitoring approval requests.  Basically, the system is pretty simple, for each of a handful of entities, there is a Workflow Service that is comprised of a few operations, and each Workflow service exposes the exact same operations.  One of the operations creates a new workflow instance and the others use correlation to resume the original workflow at various stages of the (human) process.  I had all of this working for a single entity (designer-based) without much trouble, but needed to abstract things in order to be able to make it easy to instantiate a new workflow service (new entity) when someone else is maintaining the system.  So I recreated what I had in the designer in code-based Activities which I also had working successfully.

    More head-scratching / trial and error got me to being able to invoke the new code-based workflows from within a workflow service.  Since, at that point all messaging housekeeping was still being done by the designer-based messaging activities, so this was pretty easy to get wired up.

    The problem came when a requirement came into view that I would need to access the IIdentity (impersonated through the WCF Bindings) of the client user.  This sounded like it should be relatively easy but turned out to be quite a challenge.  My first clue that this would be a challenge came with this MSDN entry:

    http://msdn.microsoft.com/en-us/library/ff452450.aspx

    After doing some more research, this seemed to imply that my designer based messaging activities would need to be replaced by code-based versions.  Okay...  So, three days later and I seem to be hitting a "can't get there from here" wall.

    I was able to get the suggested approach working by integrating the Receive/SendReply activities into a wrapper activity but since my service contract is implemented via a Pick activity, this approach was not acceptable because there is no way to satisfy the "Trigger / Body" relationship requirements by using a single workflow.

    If I separate the Receive and SendReply activities so that I can setup this:

    Pick Trigger - Code-based receive

    Pick Body - sequence(primary workflow -> sendReply)

    It seems nearly impossible to get either the original code-based Receive or a pre-generated SendReply to the code-based SendReply while still having the inferred service contract be correct (not one-way methods) or validation fail because the pre-generated SendReply is already a child of the Receive and so on ad infinitum.  I've been around and around and can't figure out how to do this.  One of the big problems is that the Request property of the SendReply activity is not a InArgument<Receive> but a public property  so wiring it up in Cache metadata seems to be surprisingly tricky.  In any case, what I want to do is this:

    Pick

    PickBranck

    PickBranch Trigger ->Custom Receive Activity that gets the IIdentity from ServiceSecurityContext

    PickBranch Action -> Sequence ( step 1 -> Run a custom Activity, step2->Send the Reply to the receive in the trigger)

    I would appreciate any guidance here, For some reason, this seems to be impossible which usually means I'm approaching the problem wrong.



    Friday, November 18, 2011 11:43 PM

Answers

  • I solved this by using a Parallel activity for hosting multiple service methods within a single service workflow.  Using a parallel activity eliminates the need to separate the Receive action (for the trigger) and the implementation (including the correlated reply). 
    • Edited by Russell Smallwood Tuesday, November 22, 2011 3:04 AM
    • Marked as answer by LeoTang Wednesday, November 23, 2011 6:12 AM
    Tuesday, November 22, 2011 3:04 AM