WCF REST service operation with JSON and XML also supporting ATOM syndication feed format

I recently wrote a post about WCF REST services with JSON and XML:

WCF REST service with XML / JSON response format according to Content-Type header

Now I often see ATOM format appearing with REST services, next to JSON and XML (aka POX). However when creating my REST service, I didn’t easily get ATOM integrated. So I played a bit more with it till I got this solution to support ATOM next to JSON and XML on a single WCF REST operation.

First I tried to play a bit with ATOM format as Content-Type, but that thing does not seem to return ATOM results just by Content-Type header on itself. The WebOperationContext.Current.OutgoingResponse.Format only allows the possibility between JSON and XML as well. Somehow I managed to get ATOM results back on the GetEmployees() by the System.ServiceModel.Channels.Message result instead of a List<Employee>, which of course doesn’t allow us to use the exact same method as we used for the JSON or XML format:


We get an ATOM feed format back if we invoke this:

WCF REST Service ATOM Feed

Continue reading