CSV Output from WCF Data service?
-
28 iulie 2010 12:37
Hi,
I'd like to implement a WCF data service that also optionally supports CSV as output format. Would this this be possible? And if it is possible, how can I implement it?
Thanks,
Adrian
Toate mesajele
-
28 iulie 2010 13:59Moderator
Hi,
It is possible, but not nice or efficient. One way to do this would be to use custom hosting through IDataServiceHost2 interface. When the request asks for CSV format, you actually ask WCF Data Services for an ATOM format. Then when the service replies, you parse the response and turn it into CSV.
Other than the hack above WCF Data Services currently doesn't support custom serializers.
Thanks,
Vitek Karas [MSFT] -
28 iulie 2010 16:00
Hi Vitek,
Thanks for your reply.
I am already using a custom data service provider, but it does not not seem to have to do anything with IDataServiceHost2... Is there any blog article or other resource describing how to implement something like this?
Also, how is the JSONPSupportBehavior attribute implemented? That does seem to do something very similar...
Thanks,
Adrian
-
29 iulie 2010 08:52Moderator
Hi,
I'm not sure about the JSONPSupportBehavior, although adding JSONP is somewhat simpler (you don't need to parse/overwrite the response, you just need to prepand/append astuff to it).
Unfortunately we don't have a good sample of usage of IDataServiceHost2 yet. The closest I could find is this: http://blogs.msdn.com/b/tom_laird-mcconnell/archive/2010/01/18/using-ado-net-wcf-data-services-for-streaming-infinite-event-result-sets.aspx
The blog itself is about something a bit different (although very interesting on its own), but it shows how you can implement the custom host in ASP.NET environment.
Thanks,
Vitek Karas [MSFT]- Marcat ca răspuns de Adrian Grigore 29 iulie 2010 12:06
-
7 martie 2012 18:35
I have implemented an extension and uploaded at codePlex , dropping the link here may me it could help some