Question: I am trying to write a web service to spec and it requires a different response body depending on whether the method completes successfully or not. I have tried creating two different DataContract classes, but how can I return them and have them serialized correctly?

Answer: 
The answer is **yes** but it is tricky and you lose strong typing on your interface. If you return a **Stream** then the data could be xml, text, or even a binary image. For DataContract classes, you'd then serialize the data using the **DataContractSerializer**.

See the [BlogSvc](http://codeplex.com/blogsvc) and more specifically the [**RestAtomPubService.cs** WCF service](http://blogsvc.codeplex.com/SourceControl/changeset/22604#Main/Source/Services/AtomPub/RestAtomPubService.cs) for more details. Note, that source code will also show you how to accept different types of data into a WCF rest method which requires a content type mapper.
If you are using a xml based binding, then I believe there is no way to do that. A simple solution in that case would to just have part of the message flag if there was a failure, and store the failure information somewhere if needed. For a JSON binding you may be able to use a method that returns an object, then return two different types of objects. If I remember correctly (which is rare), that is possible because the JavaScriptSerializer class uses reflection if the object is clean of serialization attributes.