Thursday, February 22, 2007

Reading Syndic8 Feeds with Xml-RPC using C#

Recently , i need to query syndic8 database for feeds with some interest. The syndic8 is an excellent source for all types of feeds. This site is caching feeds since 2001 and got richer in content by its graceful users.

Syndic8 lets query in XML-RPC. The web-service section of the site provides all the necessary function informations to get you started. There are also some references of how to write app consuming XML-RPC.As i like to get things done in C#. I found a pretty cool xml-rpc library written completely in C# that enables you to make proxy in WCF(Windows communication foundation) style.I would definitely suggest to give a try. The library could be found at- http://www.xml-rpc.net/.

To get started with this , all it takes an Interface with endpoint defination and some method skeletons.

For example , a sample interface could look something like the following.

[XmlRpcUrl("http://www.syndic8.com/xmlrpc.php")] -- // end point
public interface ISyndic8 : IXmlRpcProxy
{
[XmlRpcMethod("syndic8.GetAllFeedTags")] -- function signature in sydnic8
string[] GetAllTags();

[XmlRpcMethod("syndic8.FindFeeds")]
int[] FindFeeds(string pattern, string field, int limit, int index);

[XmlRpcMethod("syndic8.GetFeedFields")]
string[] GetFeedFields();

[XmlRpcMethod("syndic8.GetFeedInfo")]
Feed GetFeedInfo(int feedId);

[XmlRpcMethod("syndic8.GetFeedInfo")]
Feed[] GetFeedInfos(int[] feedId);

}

Note, i have also defined a custom struct for holding the syndic8 feed ,which is nothing but a struct filled with properties defined in sydic8 that i have found from their own GetFeedFields routine.

Finally to wrap this up , i just created simple interface reference using the rpc library and the rest is just call and get.

ISyndic8 proxy = (ISyndic8)XmlRpcProxyGen.Create(typeof(Syndic8Test.ISyndic8));
//the proxy will expire after single call, so that you can call multple methods in one instance. Default is true.
proxy.KeepAlive = false;


Hope, this gives a brief overview of sydic8 repo and xml-rpc libray for .net for getting your database filled with feeds in no time.

2 comments:

Anonymous said...

Hi Mehfuz,
Thanks for this very useful article. Can you give me a sample C# project or file which shows how to connect to the syndic8 database and how to use the C# xml-rpc library? I am having new to rss and syndication and having a tough time retrieving feeds from syndic8.com. I would be very grateful if you can help me. My Gmail ID is 'rhythmyst'. Thank you.

dersenator said...

I'd be interested in whether your could make that work with this:

http://blogs.msdn.com/clemensv/archive/2007/08/21/xml-rpc-with-wcf.aspx

Cheers
Clemens