Sunday, July 13, 2008

Really Simple Syndication with Silverlight 2 Beta 2

I've been working with Silverlight 2 Beta 2 a bit lately on my personal side project and wanted to build a very simple RSS viewer. I've found it's pretty easy to do, but there are a few gotchas along the way. I've put up some sample code for doing this, please feel free to use it in anyway you see fit.

Sample code for Silverlight RSS viewer

Here is a non-exhaustive list of things to check out in the source:

1 Silverlight 2 Beta 2 still has some cross-domain access issues, so instead of spending time figuring out why my HttpWebRequests weren't working from Silverlight, I built a WCF service to fetch the RSS XML for me.

2 On the topic of WCF, review the web.config in the ASP.NET project; make sure the binding attribute for the WCF RSS feed service is set to "basicHttpBinding".

3 In ServiceReferences.ClientConfig file in the Silverlight project, make sure you change the endpoint address's port for the WCF service to whatever your local ASP.NET development server's port is, otherwise you won't be able to run the sample locally.

4 If you want to put this code up on a live server, you may run into WCF activation issues. If you do, take a look at this blog post from Joe's Blog about using a custom ServiceHostFactory workaround.

That's all the gotchas I can think about at the second, I'll update this post with more if I remember anything else later. WCF can get a bit tricky now and then... WCF has a nasty way of trapping you inside a cave. That has a bear inside. That you can't see.

Have fun with the source; you can do a lot of cool stuff in Silverlight 2 Beta 2. Throw a DataTemplate on the ListBox and make your data look spectacular (and give yourself extra points if you recognize the Mitch Hedberg reference I just made).

Good luck!

No comments: