Sample code from Second Life Developer's Wiki - specifically http://www.lslwiki.com/lslwiki/wakka.php?wakka=ExampleBrowserXMLRPC

Getting Started With XML-RPC In Second Life

Ruben Kleiman (SomeScripter) 11/14/06

This page will help you to quickly get started sending and receiving XML requests in Second Life.

Copy the HTML contents of this page into a file in your own computer and run it from there.

Important: This works only in Internet Explorer. Why? For all other parental-guidance-required browsers, I would need to use digital signatures or gruesome hacks that defeat it--which, unfortunately, is a waste of time for me.

The way it works is as follows (detailed instructions here):

Detailed Instructions

First, in Second Life, do the following:

  1. Create some object (any type or size will do).
  2. For the sake of reference in what follows, name the object MyRCPObject. The name doesn't really matter.
  3. Create a script for the object.
  4. Replace the default script in MyRCPObject with this script:
  5. 
    string EXPECTED_REQUEST_STRING_MESSAGE = "hello there";
    string BAD_RESPONSE_STRING_MESSAGE = "I do not understand what you said";
    string GOOD_RESPONSE_STRING_MESSAGE = "Hi.";
    key myChannel;
    
    default {
      state_entry() {
        llOwnerSay("Touch me to start listening for XML-RPC requests.");
      }
    
      touch_start(integer n) {
        llOpenRemoteDataChannel();
        llOwnerSay("Waiting for channel to open");
      }
    
      remote_data(integer type, key channel, key uid, string from, integer integerValue, string stringValue) {
        if (type == REMOTE_DATA_CHANNEL) {
          myChannel = channel;
          llOwnerSay("Channel Open. Channel Key="+(string)channel);
          state waiting;
        }
      }
    }
    
    state waiting {
    
      state_entry() {
        llOwnerSay("Waiting for XML-RPC Requests...");
      }
    
      remote_data(integer type, key channel, key uid, string from, integer integerValue, string stringValue) {
        if (type == REMOTE_DATA_REQUEST) {
          if (stringValue == EXPECTED_REQUEST_STRING_MESSAGE) {
        // uid is the identifier for the request message.
        llRemoteDataReply(channel, uid, GOOD_RESPONSE_STRING_MESSAGE, 1);
          } else {
        llRemoteDataReply(channel, uid, BAD_RESPONSE_STRING_MESSAGE, 0);
          }
        } else {
          // Code would go here to respond to a new open channel, etc...
          // Check the options for 'type' in the LSL Wiki.
        }
      }
    
      touch_start(integer n) {
        state default;
      }
    
      state_exit() {
        llCloseRemoteDataChannel(myChannel);
        llOwnerSay("Channel closed. Touch again to start listening on channel.");
      }
    }
    
  6. What does this script do? It listens for an XML-RPC request and checks whether its string message is 'hello there'. If it is, it sends a response to the browser with a string message 'Hi.' Otherwise, it sends a response with a string message 'I do not understand what you said'.
  7. Save the script and follow its instructions.

Finally, fill-in the form below:

  1. Enter the key of MyRCPObject's channel. This key would have been printed by MyRCPObject on the chat line after you touch that object. You can use copy/paste from the chat history. You can click on the 'Talk With...' button now and see what happens; else, read the following steps.
  2. Leave the String Message and Integer Message as they are.
  3. Click on the 'Talk With XML-RPC Script' button.
  4. After you click on the button, an XML-RPC request will be sent to MyRCPObject, but, before sending it, an alert box will show you the contents of the XML request. Click OK on the alert box to allow the request to be sent.
  5. The browser will wait for a response from MyRCPObject. When it arrives, an alert box will show a status code: if is equal to 200, then the request has succeeded (it has found the server and the response has been answered by MyRCPObject. Click OK on the alert box.
  6. Finally, another alert box will show you the XML document returned in the response by MyRCPObject. If you look hard at the XML document, you'll notice that the string "Hi." has been returned in the response.

For more details, read this page's HTML code; in particular, the callRPCScript() script, which sends the message and receives the response.

Important Tidbits (valid 11/14/06):


Channel's Key:
String Message:
Integer Message: