Welcome to Windows Workflow Foundation (WF)
Top Tasks :

WF Team Bloggers

Browse by Tags

All Tags » WCF   (RSS)

  • Advanced Workflow Service Talk (Demo 4 of 4)

    When we start doing this two way style of messaging, we now open up to start modeling some interesting business problems.  In the previous post, you'll note that I did not include the code, because I mentioned we needed to be more clever in scenarios where we listen in parallel.  First, a brief diversion into how the Receive activity works.  Everybody remembers the workflow queues, the technology that underlies all communication between a host and a workflow instance.  The Receive activity works by creating a queue that the WorkflowServiceHost (specifically the WorkflowOperationInvoker) will use to send the message received off the wire into the workflow.  Now, the Receive activity normally just creates a queue that is named the same as the operation the Receive activity is bound to.  However, if we have two Receive activities listening for the same operation at the same time, no longer is a single queue useful to route responses back as we want to route to the correct Receive activity instance.  There is property on the Receive activity called ContextToken.  Normally this is null in the simple case.  However, when we want our Receive activity to operate in parallel, we need to indicate that it needs to be smarter when it creates a queue.  By setting this property (you can just type in a name, and then select the common owner all of the parallel receive's share.  This will cause the Receive activity to create a queue named Read More...
  • Advanced Workflow Services Talk (Demo 3 of 4)

    So, we've seen in part 1 how to manage context, we saw in part 2 how we can take that basic knowledge to do duplex messaging.  Once we start doing duplex work, there are some interesting patterns, and the first one is one that we like to call "long running work".  Why are we interested in this?  Well, as you probably know, the execution of a workflow is single threaded (this is a feature, not a bug).  We also don't have a mechanism to force the workflow to be "pinned" in memory.  What this means is that things like the asynchronous programming model  (APM), can't be used, since there isn't a guarantee that there will be something to call back when we are done.  What this means is that the send activity can not take advantage of the APM to be more thread friendly. We may want to do things in parallel, like this If each of these branches takes 3 seconds, the whole of this workflow will complete in about 9 seconds.  The general expectation is that in parallel, this would happen at the length of the longest branch + some minor delta for overhead.  The trouble is, APM programming is tricky, especially relative to the layout above. In order to model APM style service calls, but allowing for the service operations to be extremely long running, where extremely is defined as "long enough to where I would want to be able to persist."  The approach then is to model this as disjoint send and receive activities. Read More...
  • Q & A on Advanced Workflow Services talk

    Martin posted an interesting question here on my last post: <quote> The first thing that we need to do in order to enable this duplex messaging to occur is that the "client" workflow has to explicitly provide its context token to the service so that the service can address the appropriate instance of the client workflow. Note, in the real world, you'll probably need to supply more than just the context token, you will need some address and binding information. </quote> Shouldn't we have this built into a custom binding? (or an extra binding element) So with every call from the client the (WF)context information is included. And the developer is not required to follow a (artificial) state machine. Note, at the time, when the service calls back, the endpoint (and the binding) of the client may have changed... So we may need dynamic name-endpoint resolution (sounds like DNS?) Martin The question here is generally also asked as "wait, why do I need to explicitly provide a context token and change the contract to have this context thing?"  This is a common question, as changing the contract to reflect implementation details is generally a no-no.  There's one part I left out as well, so let me add that here: In the real world, one may also wish to not change the contract (or may not have the ability to).  In that case, we still need to explicitly provide the context token and endpoint information in order to allow me to call back.  Read More...
  • Advanced Workflow Services Talk (Demo 2 of 4)

    A continuation of my series of demos from my advanced workflow services talk.  Here we focus on duplex message exchange patterns. Duplex messaging is something that we model at the application level (as opposed to the infrastructure level) because we want to model that message exchange at the level of the application.  Here's some scenarios where I could use duplex messaging: [concrete] I submit an order, and you tell me when it ships [abstract] I ask you do to do some long running work, let me know when it is done [abstract] I ask you to start doing something, you update me on the status One may ask the question, "But, what about the wsHttpDualBinding, or WCF duplex bindings."  That's a valid question, but it's important to point out that those bindings are really used to describe the behavior of a given proxy instance (and associated service artifacts).  When my proxy dies, or the underlying connection goes away, I lose the ability for the service to call back to me.  Additionally, this binds me to listen in the same way that I sent out the initial message.  By modeling this at the application layer, we do lose some of the "automagicity" of the WCF duplex behavior, but I get more flexibility, and I get the ability to sustain potentially repeated recycling of the services and clients.  Also, you could imagine a service that I call that turns around and calls a third party service.  That third party service could call Read More...
  • Advanced Workflow Services Talk (Demo 1 of 4)

    So, last week I wrapped up a conversation at TechReady, our internal conference, where I was talking about the integration between WF and WCF in .NET 3.5.  This talk was somewhat bittersweet, it's the last conference where I'm scheduled to talk about WF 3.0/3.5, I'll start talking about WF 4.0 at PDC this fall.  There are a series of 4 demos that we'll talk about in this series: Basic Context Management Simple Duplex Long Running Work Pattern Conversations Pattern I've gotten a lot of requests to post the code samples, so I want to do that here: Sample 1, Basic Management of Context The goal of this sample is to show the way that the context channel works, and how to interact with it from imperative code. Ingredients: One basic workflow service that simply has two Receive activities bound to the same operation inside of a sequence. Inside each Receive, I have placed a Code Activity that simply outputs a little bit of info (the vars declared on lines 1 and 2 are used by the Receive activities:   1: public String returnValue = default (System.String); 2: public String inputMessage = default (System.String); 3:   4: private void codeActivity1_ExecuteCode( object sender, EventArgs e) 5: { 6: returnValue = string .Format( "first activity {0}" , inputMessage); 7: Output(inputMessage + " Activity 1" ); 8: } 9:   10: private void Output( string message) 11: { 12: Console.WriteLine( "Workflow {0} : Message {1}" , this .WorkflowInstanceId, Read More...
  • Workflows that don't start with a Receive

    A question recently came up on an internal list about how to start a workflow to do some work and then have it accept a message via a Receive activity.  This led to an interesting discussion that provides some insight into how the WorkflowServiceHost instantiates workflows in conjunction with the ContextChannel. Creating a Message Activated Workflow By default, the WorkflowServiceHost will create a workflow when the following two conditions are true: The message received is headed for an operation that is associated with a RecieveActivity that has the CanCreateInstance property set to true The message contains no context information It is interesting to note that you don't even need to use a binding element collection that contains a ContextBindingElement.  The ContextBindingElement is responsible for creating the ContextChannel.  The job of the ContextChannel is to do two things on the Receive side Extract the context information and pass that along up the stack (hand it off into the service model) On the creation, and only on the creation, of a new instance, return the context information to the caller in the header of the response. So, if we want to create workflows based on messages dropped into an MSMQ queue, we can do that by not trying to add the ContextBindingElement into a custom binding on top of the netMsmqBinding, and associating the operation with a Receive activity with the CanCreateInstance equaling true. Note, that any subsequent communication with Read More...
  • Regarding Re-use of Context-aware Proxies

    Yesterday, following my "What's the context for this conversation" presentation, I was approached with the following question: I am sharing a singleton client that I want to use to interact with multiple workflow instances, how do I change the context for each of them. Completely unbeknownst to me, Wenlong, one of the product team's more prolific bloggers, addressed this very topic in his post here , conveniently posted yesterday :-) Read More...
  • Recent WF Content Summary

    I've been having some fun playing around with Visual Studio 2008 and the .NET Framework 3.5, and wanted to summarize some of the content I've put up on channel9 and other places. Samples The Conversation Sample remixed -- if there is one sample in the SDK to help you understand what is going on with context passing and duplex messaging, this is the sample that helped me learn it. I had this sample reworked a little bit so that you don't have 5 console windows open. Pageflow sample 1 , live hosted -- watch this as pageflow is hosted "live" in the cloud. This lets you interact with a pageflow as well as dive into the code using some tools my team has built. Pageflow sample 2 , live hosted as above -- this is the sample that shows how we can leverage the navigator workflow type to be in multiple paths at the same time (a parallel state machine almost). Screencasts Intro demo -- a 10 minute walk through of building Workflow Services 0 to Workflow Service in 60 seconds -- a very quick tools walkthrough Dynamically creating service contracts using Workflow Services in Net 3.5 -- the way to dynamically create a contract using a workflow first approach to building it. BizTalk Server 2006 Extensions for WF -- A screencast from Jon Flanders walking through the work that has been done to host WF inside BizTalk. Building WCF Services with WF -- A screen recording with the PM responsible for the WF-WCF integration Introduction to the Windows Workflow Foundation Pageflow Sample -- A screen Read More...
  • Picture Services

    As Justin announces here , my team recently released the picture services sample. This is a cool way to expose the pictures on a machine that are found via Windows Desktop Search out in a simple, easy to consume REST endpoint. There are a few things here that I think are pretty cool Pretty easily return POX and Syndication formatted data, and creating a URI hierarchy ( here ) Querying Windows Desktop Search ( here ) Adding Simple List Extensions ( here ) Justin has a screencast here . Read More...
  • VS 2008 Beta 2 Shipped : 0 to Workflow Service in 60 seconds

    So, per Soma's blog , this great Channel9 video , and a bunch of other places, VS 2008 Beta 2 is available for download ( go here ). Others are covering their favorite feature in depth, I want to cover one of mine: the WCF test client, which I will show by way of creating a Workflow Service application. Real quick, for those of you who didn't read the readme file, I know sometimes you just forget, there is an important note regarding how to get this to work (out of the box you will probably get an exception in svcutil.exe). Running a WCF Service Library results in svcutil.exe crashing and the test form not working Running a WCF Service Library starts the service in WcfSvcHost and opens a test form to debug operations on the service. On the Beta2 build this results in crash of svcutil.exe and the test form doesn’t work due to a signing problem. To resolve this issue Disable strong name signing for svcutil.exe by opening a Visual Studio 2008 Beta2 Command Prompt. At the command prompt run: sn –Vr “<program files>\Microsoft SDKs\Windows\v6.0A\Bin\SvcUtil.exe” (replace <program files> with your program files path – ex: c:\Program Files) Fire up VS 2008, create a new Sequential Workflow Service Library project: This creates a basic Sequential workflow with a Receive activity It also creates an app.config and IWorkflow1.cs IWorkflow1.cs contains the contract our service is going to implement: using System; using System.Collections.Generic; using System.Linq; using System.Text; Read More...
  • Orcas Beta 1 Samples (WF, WCF)

    Beta 1 samples have been posted. In this release there are separate installs for WF and WCF (and the workflow services are in the WCF one, go figure!) WCF (and WF Services) Samples WF Samples From Laurence's blog : This is the only version of the new samples that works at this time. The version that comes with the VS Orcas Beta1 offline Help does not work. New samples in this release: WF Samples\Technologies\Rules And Conditions\Order Processing Policy WCF Technology Samples\Basic\Ajax WCF Technology Samples\Basic\Syndication WCF Technology Samples\Basic\WorkflowServices You can download the zip files through any of the samples. To setup and run the Orcas Beta1 samples: 1. Setup: a. Check out the Setup Instructions for the Ajax, Syndication, and Workflow Services samples . i. Use the Setup scripts under the “OrcasSetup” dir in the downloaded WCF zip file. In contrast, the “Setup” dir includes the scripts necessary for the samples already released with WCF 3.0 b. On Win2K3, if you see a plain text page when connecting to http://localhost/NetFx35Samples/service.svc , you need to run: “%SystemDrive%\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe” -i –enable "%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -i c. The WCF Samples setup script Setupvroot.bat will not run unless MSMQ is installed or the NetMsmqActivator service is disabled 2. Ajax samples: a. For the Simple and Post Ajax service samples, you will need to completely Read More...
  • Dynamically Generating an Operation Contract in Orcas using WF

    This kicks off a set of posts where I'll be discussing some of the interesting features coming out in Orcas. I want to focus on this post on the Receive Activity, and a nice little feature in the designer that lets you create a contract on the fly, without having to drop into code and write a decorated interface. This allows us to divide the world into two approaches: One where I design my contract first, and then start creating a workflow to implement the operations on the contract. Design my workflow first, and have it figure out the contract for me (this is what I will focus on in more detail) Designing a Contract First This is what most WCF folks will be familiar with: [ServiceContract] public interface IOrderProcessing { [OperationContract] bool SubmitOrder(Order order); [OperationContract] Order[] GetOrders( int customerId); } .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } When I drop a receive activity Read More...

Copyright © 2006 Microsoft Corporation. All Rights Reserved. | Terms of Use | Privacy Statement | Contact Us