05-22-2007 05:39
I've found some recommandations to use the XMLRPC .NET library from Cook Computing for XML-RPCs to Second Life. Does anybody have an example how to use it for sending requests to an object in SL?

That's the way I tried it...

using CookComputing.XmlRpc;

public struct SLStructRequest
{
public string channel;
public int intValue;
public string param;
}

[XmlRpcUrl("http://xmlrpc.secondlife.com/cgi-bin/xmlrpc.cgi";)]
public interface ISecondLife : IXmlRpcProxy
{
[XmlRpcMethod("llRemoteData";)]
string llRemoteData(SLStructRequest request);
}


As well as...

using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;

using CookComputing.XmlRpc;

class _
{
static void Main(string[] args)
{
HttpChannel chnl;
chnl = new HttpChannel(null, new XmlRpcClientFormatterSinkProvider(), null);
ChannelServices.RegisterChannel(chnl, false);

ISecondLife svr = XmlRpcProxyGen.Create<ISecondLife>;();

try
{
Console.WriteLine("Send request";);
SLStructRequest s;
s.channel = "1bccec42-bb0c-623f-5af0-5cfe27f5e0be";
s.intValue = 4;
s.param = "How are you?";
string ret = svr.llRemoteData(s);

if (ret != null)
Console.WriteLine("Response: {0}", ret);
else
Console.WriteLine("Response null";);
}
catch (XmlRpcFaultException fex)
{
Console.WriteLine("Fault response: {0} {1} {2}",
fex.FaultCode, fex.FaultString, fex.Message);
}
}
}
}

I always get the following exception:
Fault response: 2 Invalid channel Server returned a fault exception: [2] Invalid channel

I suppose there's something wrong with the protocol, but I don't know how to fix the problem.

greetz,
Leony