Syndication API for .NET Compact Framework

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

Few weeks ago Microsoft announced  the APLHA version of “BizTalk Services”. Small part of the package implemented in the new assembly System.ServiceModel.Web is related to features called "WCF Web Programming". One interesting example which shows how to invoke one service operation as a web-operation is described here.

In this post I would like to focus the Syndication API, which will probably become a part of .NET3.5. This API allows one to build the WCF based services which render RSS-Feeds according to RSS20 and Atom10. For example, following code snippet shows the contract for rendering of feeds:

[ServiceContract]   
[
ServiceKnownType( typeof( Atom10FeedFormatter ) )]   
[
ServiceKnownType( typeof( Rss20FeedFormatter ) )]   
public interface IMyService   
{
       
  [
OperationContract]
  [WebGet( UriTemplate="myservice" )]     
 
SyndicationFeedFormatter<SyndicationFeed> GetPosts();   
}
 


Following example shows how to start the hosting of the feed-service:

 Uri baseAddress = new Uri(http://169.254.242.1/); 
 
 WebServiceHost
host =
 new WebServiceHost(typeof(GpsService),
 baseAddress);
 
 
 host.AddServiceEndpoint(
typeof(MyFeedService),
 
new WebHttpBinding(), ""); 
 
 host.Open();

Note that the operation GetPosts() has an attribute “UriTemplate”. This attribute specifies the relative address of the feed. For example, the example above loads the service at the address http://169.254.242.1/. If you want to open the feed in your browser you would have to enter following Uri: http://169.254.242.1/myservice.

The good thing is that the .NET3.5 will also contain the client based API able to deal with feeds. For example, next line of code shows how simple is to retrieve the post from one blog:

SyndicationFeed feed =
SyndicationFeed.Load(new Uri(http://169.254.242.1/myservice));
         

I would like to announce that DAENET has developed the “same” Syndication-Feed API for compact framework. I quoted the word “same”, because it is usually not possible and not reasonable to have a full set of functionality in the desktop and mobile framework. For example, at this moment we do not have support for media types. The picture bellow shows all currently supported classes:


Here is one example which loads the GPS information from the GPS feed-service contained  .NET3.5 WCF samples:

SyndicationFeed feed = SyndicationFeed.Load(new Uri(http://169.254.242.1/gps));
foreach (SyndicationItem feedItem in feed.Items)
{
  string msg = String.Format("Title: {0}\nAuthor:{1}\n"
  feedItem.Title, feedItem.Authors[0].Name,
  feedItem.Content.Value);
  MessageBox.Show(msg);
}
 

Personally, I see the “syndication” as consisted part of Windows Communication Foundation. The "syndicated" sharing of information is not just about blogging and news distribution. It could become soon more and more important for sharing of many other content types.

The ALPHA version of DAENET Syndication API for .NET Compact Framework can be downloaded here.

 


Posted Sep 09 2007, 10:58 PM by Damir Dobric
Filed under:

Comments

Damir Dobric Posts wrote Mobility Day Zagreb 2007
on 09-10-2007 9:02

At Sept. 11. 2007 I will talk at Mobility Day in Zagreb about new communication possibilities around

developers.de is a .Net Community Blog powered by daenet GmbH.