Welcome to Windows Communication Foundation (WCF)
Top Tasks :

WCF Team Bloggers

Browse by Tags

All Tags » Blogging;Indigo AKA WCF;Web Services/XML   (RSS)
Sorry, but there are no more tags available to filter with.

  • WCF-based RSS and Atom Implementation for DasBlog

    Well, writing this up took longer than I thought :-) I guess I've been really busy. So, to implement the WCF-based RSS and Atom endpoints for dasBlog, I used the new System.ServiceModel.Syndication namespace from the Orcas CTP, except that the engineers created a separate DLL (Microsoft.ServiceModel.Synidcation.dll) that contains all the classes and can be used on top of NetFX 3.0 (i.e. no Orcas dependencies). Complete source for the whole thing is available upon request :-) The main implementation file is WCFSyndicationServiceImplementation.cs, and looks like this. using System.ServiceModel.Activation; using System.ServiceModel.Syndication; ... [AspNetCompatibilityRequirements(RequirementsMode=AspNetCompatibilityRequirementsMode.Allowed)] public class WCFSyndicationServiceImplementation : SyndicationServiceBase, IWCFSyndicationService { [HttpTransferContract(Method = "GET", Path = "")] public SyndicationFeed GetFeed() { int maxDays = siteConfig.RssDayCount; int maxEntries = siteConfig.RssMainEntryCount; return GetFeedWithCounts(maxDays, maxEntries); } Note that we're in AspNet compat mode, and that I inherit my implementation class from a new ServiceBase called SyndicationServiceBase. The contract (IWCFSyndicationService) has just the GetFeed method, so I elide it here. Also worth noting is the HttpTransferContract attribute - this is new and allows you to indicate that this method is dispatched from an HTTP GET (as opposed to the default POST). Finally, note the SyndicationFeed return type - this is a type that is automatically serialized either as Atom or RSS, depending on an endpoint behavior that I will set in config later. The following snippet is the core of the implementation, and creates a new SyndicationFeed and all the items underneath it. It has alot of dasBlog-isms (takes advantage of many helper classes in dasBlog) so it may be a bit hard to follow, but you'll get the gist of the OM... private SyndicationFeed GetFeedCore(string category, int maxDayCount, int maxEntryCount) { //... SyndicationFeed feed = HttpContext.Current.Cache[CacheKey] as SyndicationFeed; if (feed == null) //we'll have to build it... { feed = new SyndicationFeed (); if (siteConfig.RssLanguage != null && siteConfig.RssLanguage.Length > 0) { //feed.Lang = siteConfig.RssLanguage; feed.Language = siteConfig.RssLanguage; } if (category == null) { feed.Title = new TextSyndicationContent (siteConfig.Title); } feed.Description = new TextSyndicationContent(siteConfig.Subtitle); Read More...
  • WCF-based Syndication Endpoints for OhmBlog

    DasBlog has asmx-based syndication endpoints for RSS and Atom (at http://www.gazitt.com/blog/SyndicationService.asmx/GetRss and http://www.gazitt.com/blog/SyndicationService.asmx/GetAtom , respectively). I added parallel syndication endpoints based on WCF, using the SyndicationFeed classes we're going to preview in an upcoming Orcas CTP. The endpoints are at http://www.gazitt.com/blog/SyndicationService.svc/rss/GetFeed and http://www.gazitt.com/blog/SyndicationService.svc/atom/GetFeed , respectively. One cool thing is that all I had to do was define one service contract which returns SyndicationFeed, and expose it on two separate WCF POX endpoints (/atom and /rss), each with a different endpoint behavior (which serialize the SyndicationFeed as Atom and RSS, respectively). One implementation, two different serialization formats. This may not be the final design for the feature (since Atom and RSS are different enough that creating a single API for both isn't trivial), but it was still a fairly trivial exercise to port the dasBlog Atom implementation to SyndicationFeed. I'll post the code when I get a chance... Read More...

Copyright © 2006 Microsoft Corporation. All Rights Reserved. | Terms of Use | Privacy Statement | Contact Us