I have a .NET 4 WCF service (MEX and HttpGET).
For the HttpGET endpoint, I would like to override the default MessageFormatter.DeserializeRequest to map UriTemplate to strongly-typed objects.
Ideally, a custom attribute would be used to decorate the methods that should use this formatter, but I’m not sure whether I can switch the formatter in that regard.
Is this doable, and can someone walk me through the configuration needed in app.config?
If you want fine grained formatting control for WCF REST, I’d suggest one of the following two options:
Override WebHttpBehavior to specify your own message formatter. This gives you a lot of control, but requires a lot of legwork. http://msdn.microsoft.com/en-us/library/system.servicemodel.description.webhttpbehavior.getrequestclientformatter.aspx
Use the new WCF Web API, which offers much more configurability for REST services. http://wcf.codeplex.com/wikipage?title=WCF%20HTTP.
However, if ALL you want to do is map certain query string parameters to strongly typed objects, you can just implement your own QueryStringConverter class :
http://msdn.microsoft.com/en-us/library/system.servicemodel.dispatcher.querystringconverter.aspx
and use that in your custom WebHttpBehavior:
http://msdn.microsoft.com/en-us/library/system.servicemodel.description.webhttpbehavior.getrequestclientformatter.aspx ).