locked
Returning additional data formats other than AtomPub and JSON RRS feed

  • Question

  • I've been looking at implementing some web services that follow the Open Data Protocol. So naturally i've figured i'd use WCF Data Services as most of the hard work is already done for me out of the box. I did however want to take one thing a step further and that was also provide the data in CSV and KML. 

    The OData protocol does say you aren't limited to AtomPub and JSON (see: http://www.odata.org/developers/protocols/uri-conventions#FormatSystemQueryOption). However in my attempts to add this functionality to WCF Data Services i've hit a wall. As far as I can tell there is no way for somebody to build a custom formatter (let alone have WCF Data Services use it).

    I've looked into trying to intercept Data Services before it converts the Entities (EF entities) to AtomPub or JSON and it doesn't appear there is a way to do that either.

    Has anybody been able to do add additional formats to WCF Data Services? Or does anybody have any ideas on how I could return additional formats other than AtomPub and JSON from a WCF Data Service?

    Friday, May 7, 2010 8:48 PM

Answers

All replies

  • Hi,

    The WCF Data Services runtime only supports the atom and JSON formats. Currently, it is not possible to override those components.

    If this is something you'd like to see in a future release, please check out our Connect site (https://connect.microsoft.com/data/SearchResults.aspx?SearchQuery=WCF%2bData%2bServices) and add it as a suggestion.

     


    Matt Meehan, WCF Data Services (Astoria)
    Saturday, May 8, 2010 1:52 AM
    Moderator
  • Hi Matt,

    Is this still true in WCF Data Services 5.0?

    Friday, June 29, 2012 4:17 PM
  • Yes this is still true.

    On a related note though, the 5.0 release includes the ODataLib which contains he readers and writers for ATOM and JSON used by WCF Data Services. So if you would implement the server yourself and want to read and write the OData format, you don't have to reimplement that. And then you can support any other format as well.

    But the WCF DS server doesn't have an extensibility point to allow custom formats in itself yet.

    Thanks,


    Vitek Karas [MSFT]

    Friday, June 29, 2012 6:32 PM
    Moderator
  • Hi Vitek :),

    Just to clarify, existing WCF Data Service can still be extended if the AtomPub response is serialized into another format, correct? I know the performance will not be idealistic, but this would still be an option. However, I would hope that WCF Data Service make the output format extensible. I wanted to go to the voting site above but link seems to be broken (https://connect.microsoft.com/data/SearchResults.aspx?SearchQuery=WCF%2bData%2bServices).

    Thanks,

    Patrick


    Friday, June 29, 2012 6:40 PM
  • It is possible to implement a custom format on top of WCF DS (actually more like around it), by modifying the Accept header on the input and on the output parsing the ATOM response and producing the custom format. But I really didn't count that as a viable option since its performance is gonna be terrible as you note. But for the sake of completeness you're right :-)

    The voting site has moved to: http://data.uservoice.com/forums/72027-wcf-data-services-feature-suggestions

    Thanks,


    Vitek Karas [MSFT]

    Friday, June 29, 2012 8:22 PM
    Moderator
  • Hi William 

    I did the same kind of approach to extent my data service to support TXT/CSV format and project is shared at http://wcformatextensions.codeplex.com/ that you can use out of the box.

    May be you can use the same logic for other formats as well 

    Regards

    Ashwini

    Sunday, July 1, 2012 5:42 AM