This project is read-only.

Version 1.0 (Support only single page response)


This extension is targeted to extend WCF Data Service response formats to beyond Atom and JSON

This release support only TEXT type response with custom separator characters. This feature will be helpful to extend the data service so that they can be consumed by legacy applications too.

Using this extension

There are two project in this solution one is sample data service project that consume the TXT extensions and other is actual extension project. below is the steps to use the extension

  1. Import the project (Add-Project)"WCFDataServiceFormatExtensions" of its dll in your Data Service solution.
  2. Reference the project (Or DLL) to your data service application
  3. Add WCFDataServiceFormatExtensions namespace to your data service class
  4. Decorate your Data Service class with [EnableTextOutput] attribute


 using System;
    using System.Collections.Generic;
    using System.Data.Services;
    using System.Data.Services.Common;
    using System.Linq;
    using System.ServiceModel.Web;
    using System.Web;
    using WCFDataServiceFormatExtensions;

    public class WCFDataService : DataService<NORTHWNDEntities>
        // This method is called only once to initialize service-wide policies.
        public static void InitializeService(DataServiceConfiguration config)
            // TODO: set rules to indicate which entity sets and service operations are visible, updatable, etc.
            // Examples:

            config.SetEntitySetAccessRule("*", EntitySetRights.AllRead);
            config.DataServiceBehavior.MaxProtocolVersion = DataServiceProtocolVersion.V2;


This will enable TXT support out of the box

URI Convention

Once you are plug-in this extension you are ready for querying TEXT out out from data service . URI Semantic are below


<Any Data Service GET URL>&$format=TXT[@ Separator Character ]

Default Separator is pipe ('|') but it can explicit be defined if required otherwise optional.


  • http://localhost:11002/WCFDataService.svc/Products?$format=txt
  • http://localhost:11002/WCFDataService.svc/Products?$top=5&$format=txt

How Does it works

Actually idea of this implementation was taken from an MSDN post   about adding JSONP in data service

Here is the summary of steps

  1. Browser send a request with $format=txt parameter
  2. Attribute[EnableTextOutput] route the request to Text Handler Class (TextHandler.cs)
  3. This class modified the request by removing $format parameter and relay to WCF Data Service for processing
  4. Once response comes back  it relay the response to AtomFeedConverter calss  (AtomFeedConverter.cs).
  5. AtomFeedConverter reads the response stream chunk by chunk with the help of base64 reader class (Base64StreamReader.cs)
  6. At the end of read AtomFeedConverter feed converter flush all the data to a TXT file.
  7. TextHandler class then publish the url of the file created.
    1. By default it creates a download folder under the root directory to publish the file bit this behavior can be altered by supplied appropriate config keys in you web.config file
          <add key="DownloadFolderPhysicalPath" value="TODO" />
          <add key="DownloadFolderVirtualHTTPPath" value="TODO" />
    Once file is ready for publish CustomBinaryWriter calls flush the required information to WCF output stream.

This Release may have Bugs

This implementation has been tested only against Northwind data base (attached with this project). It is quite possible that it may break for some custom implementation however fine tuning should be easy.

If you are still facing any problem please report bugs.

What Next

Version 2.0 has been released check out what is new 

Last edited Apr 27, 2012 at 9:47 PM by ashwini47, version 1


vkap Jun 28, 2012 at 9:57 PM 
hi ..its really useful..i am trying the same on a different database though EDM and getting an error on $format not supported. I know WCF doesnt support this type of format? could u pls provide any examples how i can resolve this? thanks!