Wednesday, October 22, 2008

Building a RSS News Aggregation application using Wolf

Hi friends,

We recently helped a partner to build an RSS News Aggregation application.

RSS is a popular format for delivering regularly changing web content over the internet. Many news-related sites,blogs, etc. syndicate their content as an RSS Feed to subscribers and doesn't need any further introduction.

This Wolf application allows users to obtain their favourite web content and store/view the content from their own website. Moreover, it allows filtering and searching of the obtained RSS content, etc.

The first step to using the RSS News Aggregation was to enter the URL for the RSS news feeds.
This is done as shown below-

On pressing the "Update" button -

1. The entered URL is checked for validity.

Here's the simple code attached below

HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(RSSfeedLocation);
webRequest.Timeout = 6000;
HttpWebResponse webResponse = (HttpWebResponse)webRequest.GetResponse();
Stream responseStream = webResponse.GetResponseStream();
string responseEncoding = webResponse.ContentEncoding.Trim();
if (responseEncoding.Length == 0)
responseEncoding = "us-ascii";
StreamReader responseReader = new StreamReader(responseStream, System.Text.Encoding.GetEncoding(responseEncoding));
return responseReader.ReadToEnd();

2.The XML content at the given URL is obtained.

3. The URL specific XML format is processed & converted into the Wolf specific XML format.

Here's the simple code attached below

string transformedXML = string.Empty;
XPathDocument xPathDoc = new XPathDocument(new StringReader(sXML));
XslCompiledTransform xslTran = new XslCompiledTransform();
xslTran.Load(new XmlTextReader(stream));
using (StringWriter sw = new StringWriter())
xslTran.Transform(xPathDoc.CreateNavigator(), null, sw);
transformedXML = sw.ToString();
return transformedXML;

4. The data in Wolf XML format is then automatically presented to the user in his Wolf application.

WolfSession.Session obj = new WolfSession.Session();
System.Net.CookieContainer c = new System.Net.CookieContainer();
obj.CookieContainer = c;
string userAuthentication = obj.IsUserAuthenticated("youruserid", "yourpasword", "yourapplicationid");
//call the commit webservice method with the transformed XML
wfobject.Object comObj = new wfobject.Object();
comObj.CookieContainer = c;
string xmlfname = comObj.commit(wsfCommitXML);
catch (Exception error)

You can see the consolidated RSS aggregation from the Wolf application as shown below -

The RSS news aggregation obtained from the URL is presented item wise to the User in Wolf PaaS. The user is presented with all the details of the news items such as Headline, Description, etc.

The User can click on the individual items to view the full story!

Let me know if you need more assistance, will be happy to do more.

No comments: