Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

XML-RPC error help

Hatta Muir
Registered User
Join date: 25 Jun 2005
Posts: 11
07-27-2005 01:47
I'm having a little difficulty with the XML-RPC interface implemented in SL, and any help woudl be appreciated.

I have some active scripts working which initiate an email from inside SL to a RL email account. This includes the apparent remote_data channel needed for return communication. I've checked, and the RPC channel string generated in SL is the same one sent via email, and the same one used for return messaging.

When I initiate a return message using XML-RPC (using the code found elsewhere in this forum to construct and send an XML-RPC message without using the xml-rpc libraries), I get an error message:

[faultString] => Invalid channel
[faultCode] => 2

This happens every time I try and send an XML-RPC message back to SL, even if I am still in the world, and the object that initiated the email (and the script itself) still exists, has not been re-rezzed, has not been reset, and has not been deleted.

I can send the same request from the same object twice, and I will get the same channel identifier each time.

Any suggestions would be most appreciated.
Satchmo Prototype
eSheep
Join date: 26 Aug 2004
Posts: 1,323
07-27-2005 09:36
From: Hatta Muir


Any suggestions would be most appreciated.


What language are you using, and do you mind providing a server code snippet?
_____________________

----------------------------------------------------------------------------------------------------------------
The Electric Sheep Company
Satchmo Blogs: The Daily Graze
Satchmo del.icio.us
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
07-27-2005 09:53
Are you sending back a channel parameter? When you open a remote data channel using llOpenRemoteDataChannel, the remote_data event is called with a UUID (key) that identifys the channel opened by that script. When communicating with SecondLife via XML-RPC, you need to send this channel, as well as a string value and integer value, for the request to be properly routed to your script. Im not exactly sure of the language you're using, so I cant give you a detailed explanation of why your error is occuring, but it seems to be that SL either receives an unregistered channel or doesnt receive a channel at all, so it doesnt know which script your message is for.

See http://secondlife.com/badgeo/wakka.php?wakka=XMLRPC for more details about how to contact objects in SL via XMLRPC.

Also, give us some more details about exactly what you're doing, so we can be of more assistance :)
==Chris
_____________________
October 3rd is the Day Against DRM (Digital Restrictions Management), learn more at http://www.defectivebydesign.org/what_is_drm
Hatta Muir
Registered User
Join date: 25 Jun 2005
Posts: 11
07-27-2005 11:09
Well...

It seems it was caused by an extraneous CR/LF that crept in at the end of the RPC channelID as part of the parsing I was doing of the email. Once I trim()'d the string it was fine (I'm using PHP server side by the way.)

Since I've written my own email parser to directly read the email inbox via IMAP in PHP, I was reading the body of the email which contained the relevant information, but I forgot to strip out non whitespace :)

Just goes to show what coding late at night does to you :)

Of course my issue now is that I can send a reply via XML-RPC and I get a proper response from the server, but the text doesn't appear where I expect it to... That's probably down to a bug in my LSL code though :)

Thanks for all the offers of help though!
nonnux white
NN Dez!gns
Join date: 8 Oct 2004
Posts: 90
off-topic:
07-28-2005 08:09
i am using ExampleRPC2PHP and i found out that my debian box is not correctly setup for xmlrpc_encode_request

i checked everywhere, and there is no extensions on my php.ini so i uncomment. what am i missing? i got this error:

Fatal error: Call to undefined function: xmlrpc_encode_request() in /bla/bla/bla on line 22

i am running Apache/1.3.26 (Unix) Debian GNU/Linux (php 4)
_____________________
Hatta Muir
Registered User
Join date: 25 Jun 2005
Posts: 11
07-28-2005 13:02
From: nonnux white
i am using ExampleRPC2PHP and i found out that my debian box is not correctly setup for xmlrpc_encode_request

i checked everywhere, and there is no extensions on my php.ini so i uncomment. what am i missing? i got this error:

Fatal error: Call to undefined function: xmlrpc_encode_request() in /bla/bla/bla on line 22

i am running Apache/1.3.26 (Unix) Debian GNU/Linux (php 4)

Most likely you don't have the XMLRPC libraries compiled into PHP (and don't ask me how to do that) or your version of PHP is too low. Are you using 4.1.0 or above?
nonnux white
NN Dez!gns
Join date: 8 Oct 2004
Posts: 90
07-28-2005 13:50
yes, i know i need the extensions on my php, but i saw how to do it for win... there is an include of the extension (but is a dll, and no dll's under linus)

yes i am using above 4.1 (i know xml_rpc is only for 4.1 and above)

i didn't found any information on how to install it under linux... maybe searching for wrong words :\
_____________________
Satchmo Prototype
eSheep
Join date: 26 Aug 2004
Posts: 1,323
07-28-2005 15:51
I do all my XML-RPC in Perl and I've just learned PHP for Riddle City Ransom work, so I don't know much about PHP XML-RPC, but I would try php-pear ...

As in: apt-get install php-pear
_____________________

----------------------------------------------------------------------------------------------------------------
The Electric Sheep Company
Satchmo Blogs: The Daily Graze
Satchmo del.icio.us
Roger Wake
Registered User
Join date: 16 Jan 2006
Posts: 5
Also receiving invalid channel via XML-RPC
02-18-2006 08:35
Hi,

I am also having some trouble sending an XML-RPC message to an object. I am using XML-RPC.net, an implementation for .NET. I have written a c# client which sends a message to the channel id provided by the example script on the wiki.

The client works fine against the XML-RPC server I wrote.

Here is the code, any ideas on how to troubleshoot this welcome!

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using CookComputing.XmlRpc;


namespace SumAndDiffClient
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Label label1;
private System.Windows.Forms.Button button2;
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.Container components = null;

struct SumAndDiffValue
{
public int sum;
public int difference;
}

struct SLRPCStruct
{
public string Channel;
public string StringValue;
public int IntValue;
}

[XmlRpcUrl("http://xmlrpc.secondlife.com/cgi-bin/xmlrpc.cgi";)]
interface IRemoteData
{
[XmlRpcMethod]
SLRPCStruct llRemoteData(string Channel, string StringValue, int IntValue);
}

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
}

/// <summary>
/// Clean up any resources being used.
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.button1 = new System.Windows.Forms.Button();
this.label1 = new System.Windows.Forms.Label();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(16, 16);
this.button1.Name = "button1";
this.button1.TabIndex = 0;
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// label1
//
this.label1.Location = new System.Drawing.Point(16, 48);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(848, 448);
this.label1.TabIndex = 1;
this.label1.Text = "label1";
//
// button2
//
this.button2.Location = new System.Drawing.Point(200, 16);
this.button2.Name = "button2";
this.button2.TabIndex = 2;
this.button2.Text = "button2";
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// Form1
//
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(880, 509);
this.Controls.Add(this.button2);
this.Controls.Add(this.label1);
this.Controls.Add(this.button1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);

}
#endregion

/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void button2_Click(object sender, System.EventArgs e)
{
try
{
IRemoteData proxy = (IRemoteData)XmlRpcProxyGen.Create(typeof(IRemoteData));
SLRPCStruct ret = proxy.llRemoteData("c60fa268-2b55-f247-0da0-53204614ebb8", "Hello World.", 0);
label1.Text = "Return:" + ret.StringValue;
}
catch (XmlRpcFaultException fex)
{
label1.Text = fex.FaultCode + ":" + fex.FaultString;
}
}
}
}


Cheers,
Roger
Roger Wake
Registered User
Join date: 16 Jan 2006
Posts: 5
Actual XML-RPC Request
02-23-2006 20:25
Hi all,

I used a packet sniffer to figure out exactly what I was sending. Does anyone see anything obviously wrong with it?

<?xml version="1.0"?>
<methodCall>
<methodName>llRemoteData</methodName>
<params>
<param>
<value>
<string>c60fa268-2b55-f247-0da0-53204614ebb8</string>
</value>
</param>
<param>
<value>
<string>Hello World.</string>
</value>
</param>
<param>
<value>
<i4>0</i4>
</value>
</param>
</params>
</methodCall>


Cheers,
Roger
Satchmo Prototype
eSheep
Join date: 26 Aug 2004
Posts: 1,323
02-23-2006 22:39
From: Roger Wake
Hi all,

I used a packet sniffer to figure out exactly what I was sending. Does anyone see anything obviously wrong with it?

<?xml version="1.0"?>
<methodCall>
<methodName>llRemoteData</methodName>
<params>
<param>
<value>
<string>c60fa268-2b55-f247-0da0-53204614ebb8</string>
</value>
</param>
<param>
<value>
<string>Hello World.</string>
</value>
</param>
<param>
<value>
<i4>0</i4>
</value>
</param>
</params>
</methodCall>


Cheers,
Roger


The example request from the Wiki shows:

CODE

<?xml version="1.0"?>
<methodCall>
<methodName>llRemoteData</methodName>
<params>
<param>
<value>
<struct>
<member>
<name>Channel</name>
<value><string>4a250e12-c02e-94fb-6d2f-13529cbaad63</string></value>
</member>
<member>
<name>IntValue</name>
<value><int>0</int></value>
</member>
<member>
<name>StringValue</name>
<value><string>test</string></value>
</member>
</struct>
</value>
</param>
</params>
</methodCall>


I notice your request doesn't enclose the variables in the <member> tag. You also don't have the <name> tag. I'm actually thinking the lack of <name> would cause a snafu. Perhaps that's the problem?

I.E.

you have :

CODE
  <param>
<value>
<string>Hello World.</string>
</value>
</param>


Instead of:

CODE

<member>
<name>StringValue</name>
<value><string>test</string></value>
</member>
_____________________

----------------------------------------------------------------------------------------------------------------
The Electric Sheep Company
Satchmo Blogs: The Daily Graze
Satchmo del.icio.us
Roger Wake
Registered User
Join date: 16 Jan 2006
Posts: 5
Xml-rpc.net
02-24-2006 14:35
All,

I have posted a question to the XML-RPC.NET listserv in hopes of finding out if one implementation is behind the other or if there is a workaround. Thanks for your help! I will post what happens in this thread.

Cheers,
Roger
Roger Wake
Registered User
Join date: 16 Jan 2006
Posts: 5
Not conforming to spec?
02-24-2006 19:23
Something interesting I just ran across with respect to the XML-RPC spec at http://www.xmlrpc.com/spec#update3:

Request example

Here's an example of an XML-RPC request:

POST /RPC2 HTTP/1.0
User-Agent: Frontier/5.1.2 (WinNT)
Host: betty.userland.com
Content-Type: text/xml
Content-length: 181

<?xml version="1.0"?> <methodCall> <methodName>examples.getStateName</methodName> <params> <param> <value><i4>41</i4></value> </param> </params> </methodCall>

Notice how the Request follows the pattern produced by my client? This is different than the example which seems to expect a single parameter of a struct. Maybe I will try that.

Cheers,
Roger
Roger Wake
Registered User
Join date: 16 Jan 2006
Posts: 5
idiot
02-24-2006 19:31
All,

I am an idiot. I misread the Wiki entry and confused the XML-RPC Request format with the LSL function since they are named the same thing, llRemoteData! The request requires a struct and the LSL event handler takes actual parameters. Duh.

Cheers,
Roger