WCF

WCF

WF4 Services Part 2 – Correlation

Continuing on from Part 1 now we are going to add the Calculation operations to our stateful workflow service. First we need to look back and understand our previous operation “Start”. If you look at the Receive activity for the Start operation you will see that it has a property in the properties panel (F4) called CanCreateInstance and it is set to true. This property means that a call to this operation will start a new instance of our workflow. Up to now our service has simply started when we called the “Start” method and ended after the response...

WF4 Services Part 1–The simple WF Service

I thought I’d do a series of posts on workflow services. There are plenty of resources out there already on how to build workflows and activities although not a huge amount has been said about workflow services. In my opinion this is the real power of workflow and its where WF4 really comes into its own. In fact I’m going to presume that you’ve played a little with workflow and understand what an activity is, that’s about it. Over the series we’re going to be building a calculator service which performs integer operations in a stateful way so that...

WCF Exceptions and Fault Contracts

I ran across an issue recently trying to get a custom exception across a WCF boundary. The trouble is, WCF does not like to tell you what the problem was, and for good reason. I was thinking about exceptions the wrong way. In reality we do not want to pass exceptions across a WCF service boundary, instead we want to pass a Fault back to the caller. An exception is a CLR concept, it does not make sense to expose this outside of the CLR, despite the fact that an exception contains potentially dangerous information (like the stack trace) which...

WCF: Custom Collections with Extra Payload

I came across a pretty annoying problem to solve in WCF today. Suppose you have a custom collection of items you wish to use in a WCF contract but it also has extra properties that you have added, for example change tracking.     [Serializable]     public class DtoCollection<T> : List<T>     {         private List<T> addedItems;         private List<T> removedItems;     }   It will serialize the collection fine but your added properties and fields will not appear. The [CollectionDataContract] attribute will not help you. If you look at this really great post from Sowmy Srinivasan's blog you can see the order of preference for WCF serialization markup....