k10n
Jim Klopfenstein's Radio Weblog

 



Subscribe to "k10n" in Radio UserLand.

Click to see the XML version of this web page.

Click here to send an email to the editor of this weblog.
 
 

Registering for RSS Notifications

Userland has created a simple xml-rpc endpoint that a program can use to register to receive RSS file-change notifications.  Here is a Windows console app (written in C# to run in the .NET framework) that makes an xml-rpc call to that endpoint and echoes the response message to the console.  I called the file RegisterRssCallback.cs.

using System;
using System.Net;
using System.IO;

namespace RegisterRssCallback
{
   class RegisterRssCallbackClass
   {
      static void Main(string[] args)
      {
         String requestString;
         HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://radio.xmlstoragesystem.com/RPC2");

         requestString = "<?xml version=\"1.0"?>n";
         requestString += "<methodCall>\n";
         requestString += " <methodName>xmlStorageSystem.rssPleaseNotify</methodName>\n";
         requestString += " <params>\n";
         requestString += "  <param>\n";
         requestString += "   <value>RssHasChanged</value>\n";
         requestString += "  </param>\n";
         requestString += "  <param>\n";
         requestString += "   <value><i4>80</i4></value>\n";
         requestString += "  </param>\n";
         requestString += "  <param>\n";
         requestString += "   <value>/HandlerTest/handler.aspx</value>\n";
         requestString += "  </param>\n";
         requestString += "  <param>\n";
         requestString += "   <value>xml-rpc</value>\n";
         requestString += "  </param>\n";
         requestString += "  <param>\n";
         requestString += "   <value><array>\n";
         requestString += "    <data>\n";
         requestString += "     <value>http://radio.weblogs.com/0105476/categories/testing/rss.xml</value>\n";
         requestString += "    </data>\n";
         requestString += "   </array></value>\n";
         requestString += "  </param>\n";
         requestString += " </params>\n";
         requestString += "</methodCall>\n";
        
         myRequest.Method = "POST";
         myRequest.ContentType = "text/xml";

         myRequest.ContentLength = requestString.Length;
         Stream outboundStream = myRequest.GetRequestStream();
         StreamWriter w = new StreamWriter(outboundStream);
         w.Write(requestString);
         w.Flush();
         w.Close();
         outboundStream.Close();

         // Return the response.
         WebResponse myResponse = myRequest.GetResponse();
         Stream myResponseStream = myResponse.GetResponseStream();
         StreamReader r = new StreamReader(myResponseStream);
         String s = r.ReadToEnd();
         Console.WriteLine(s);
        
         // Close the response to free resources.
         myResponse.Close();
      }
   }
}

This program can be built with the command:

csc /t:exe /r:System.Web.dll RegisterRssCallback.cs

to create RegisterRssCallback.exe.

The xml-rpc call says that there is an xml-rpc endpoint called RssHasChanged on port 80 of the same server that is making the call at the url http:///HandlerTest/handler.aspx"; It is asking for notification of changes to http://radio.weblogs.com/0105476/categories/testing/rss.xml; I created a new category called testing on my Radio site, so I could force changes to the rss.xml file without changing my Radio home page.

I knew to send this request to the method xmlStorageSystem.rssPleaseNotify at http://radio.xmlstoragesystem.com/RPC2 because I could see this XML fragment in the RSS file:

<cloud
   domain="radio.xmlstoragesystem.com"
   port="80"
   path="/RPC2"
   registerProcedure="xmlStorageSystem.rssPleaseNotify"
   protocol=XML-RPC />

To see the code I wrote to receive the xml-rpc notifications, check out this story.


						


Click here to visit the Radio UserLand website. © Copyright 2003 Jim Klopfenstein.
Last update: 2/10/2003; 8:43:43 AM.