Posts

Showing posts from August, 2009

Changing the type of a returned object in WCF

[ Download Full Solution ] Every once and a while the returned object type from a service is too simple/generic, and a more rich, or specialized object would be a better fit. This is typically easy to achieve by instructing a new type that's comparable with the same service contract to be the resulting type. What about if one XML representation could best be described as multiple classes though? What this article tries to demonstrate is how to closely manage the DataContractSerializer in such a way that the returned type through the WCF endpoint is the desired type, while remapping it at the level of the serializer if appropriate. What we have below is how we are going to update the DataContractSerializer to do our bidding. We are going to create a new implementation of IEndpointBehavior which will update the DataContractSerializer on the operational contracts of the assigned endpoint. <?xml version="1.0" encoding="utf-8" ?> <configuration> ...