TechBubbles Microsoft Technology BLOG

Creating Web feeds with WCF

Introduction

A feed on the web is data format where users can read content from different web sites by subscribing using client applications. Building and exposing a web feed is not a new idea but in this post we are going to use WCF to build the feeds.WCF allows you to create feeds for both  Atom1 and RSS2 standards.

Building a Feed with WCF

The following are two important features in WCF allows us to build the feeds.

  1. WebGetAttribute
  2. System.ServiceModel.Syndication

Types in the Syndication namespace represents the structure of the feed in the memory and WCF can serialize those feeds into XML formats for feed readers to understand. SyndicationFeed type in this namespace supports two formats – RSS 2.0 and Atom 1.0.

The object model implemented by SyndicationFeed and types in the System.ServiceModel.Syndication namespace allows you to take the data from your feed and put into the WCF feed object model. The WCF object model then take care of serializing those objects into the appropriate XML for your feed.

You can create a WCF Syndication service in VS 2008 as follows

WCFFeed 

The following code creates a top-level SyndicationFeed object from EventLog data.

Feed

We have created a basic feed and now we look at the data inside the feed.

The most used property of SyndicationFeed is Items. Each <entry /> in the case of Atom or <item /> in the case of RSS represents the item in the feed.

Another important property is Content which represents the contents of an item can be text, XML or a URI. You can add the content to above created feed as follows

FeedContent

SyndicationFeed is not format-specific and you need to format the data inside the feed using SyndicationFeedFormatter.You can format feed either in RSS or Atom using the same SyndicationFeed object.

FeedFormatter

WriteTo method on SyndicationFeedFormatter is useful for writing feeds.

This article explained the basics for creating the webfeed with WCF and content is based on Jon Flander’s article on Visual Systems Journal.

In the next article I will discuss about exposing a Feed on Live URI.

Share this post :

About the author

Kalyan Bandarupalli

My name is kalyan, I am a software architect and builds the applications using Microsoft .NET technologies. Here I am trying to share what I feel and what I think with whoever comes along wandering to Internet home of mine.I hope that this page and its contents will speak for me and that is the reason I am not going to say anything specially about my self here.

1 Comment

By Kalyan Bandarupalli
TechBubbles Microsoft Technology BLOG

Follow me

Archives

Tag Cloud