I am trying to write a web service for a specification, and this requires a different response body, depending on whether this method completed successfully or not. I tried to create two different DataContract classes, but how can I return them and are they serialized correctly?
The answer is yes , but it is difficult and you lose strong typing on your interface. If you return the stream , then the data can be xml, text, or even binary. For the DataContract classes, you then serialize the data using the DataContractSerializer .
BlogSvc RestAtomPubService.cs WCF . , , WCF, .
, - WCF , - FaultException. web.config , .
. . KnownType, , . , , Object , .
, , , , , . Silverlight 2, Beta 2 . , , , , , ...
ADO.NET Data Services, .
FaultContracts
xml, , . , , - . JSON , , . ( ), , JavaScriptSerializer , .