Jon Schull's Weblog





Click to see the XML version of this web page.

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


Sunday, March 24, 2002
 

Experimenting with services


Thanks to Jy Stervinou I've been pointed to background information on Radio and Web Services and Python (why is this stuff so hard to unearth)?

Jy published this enigmatic gem

which is based upon this admirable tutorial by Dave Winer: http://radio.userland.com/webServicesTutorial 
(Don't fail to read Dave's backgrounder at http://davenet.userland.com/1998/07/14/xmlRpcForNewbies)

....
The tutorial advises entering this text as Source: <%params = {Dave}; xml.rpc ("127.0.0.1", 5335, "radio.helloWorld", @params)%>

So I am doing that here: 
Now we get to see what happens.

So far so good.  It said "Hello Dave!". when I posted.  (Didn't even have to publish.  So this is coming off my own radio server, by virtue of the file called HelloWorld.txt the tutorial had me put into the Radio WebServices directory.)

To quote the tutorial,

See where we're going? 

Now we've called a trivial script over the Internet. Of course the same mechanism works if it's not a trivial script. And it gets even better. Not only can you call it from Radio, you can call it from any scripting environment that supports XML-RPC. In a very real way, we've turned the Internet into a big honking scripting enviroment, with lots of power and choice, just like the Web. (That's why they're called Web services.)

OK the second example from the tutorial is <ol><%params = {5, "<li>", "</li>"}; xml.rpc ("127.0.0.1", 5335, "radio.myFavoriteWeblogs", @params)%></ol> which invokes

on myFavoriteWeblogs (ctfavorites, pretext="<p>", posttext="</p>\r") {
   local (htmltext = "", ct = 0);
   while ct < ctfavorites {
      local (ix = random (1, sizeof (weblogsComData.favorites)));
      local (weblogname = nameof (weblogsComData.favorites [ix]));
      local (adrweblog = @weblogsComData.weblogs.[weblogname]);
      if defined (adrweblog^) {
         local (link = "<a href=\"" + adrweblog^.url + "">" + weblogname + "</a>");
         htmltext = htmltext + pretext + link + posttext;
         ct++}};
   return (htmltext)}

(I suppose this is Frontier script?.  It would be nice if this had been made explicit?)

Here goes:

    [Macro error: The server, 127.0.0.1, returned error code 7: Can't evaluate the expression because the name "myFavoriteWeblogs" hasn't been defined.]



 

How'd we do?
Not bad, considering that we're listing 5 out of 2 favorites.


comments? [] 5:59:02 PM    


Click here to visit the Radio UserLand website. © Copyright 2003 Jon Schull.
Last update: 11/10/03; 6:32:58 PM.
March 2002
Sun Mon Tue Wed Thu Fri Sat
          1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31            
Feb   Apr