[Opensim-users] NWC-RPC Methods Giving Odd Results

David Lloyd lloy0076 at adam.com.au
Fri Nov 28 23:00:41 UTC 2014


Hi There,

TL;DR I can’t get NWC-RPC to encode .NET object such as OpenMetaverse’s UUID or System.Net.IEndpoint - anyone know how to do this?

I am trying to get the NWC-RPC .NET module to communicate with my money server. The money server registers XML RPC calls with the grid like this:

m_httpServer.AddXmlRPCHandler("CancelTransfer", handleCancelTransfer)

The handleCanceTransfer’s signature looks like this:

 public XmlRpcResponse handleCancelTransfer(XmlRpcRequest request, IPEndPoint remoteClient)

My code looks like this (and it’s a copy/paste with a few tweaks from here):

using System;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using Nwc.XmlRpc;
using OpenMetaverse;
namespace Call_With_NWC
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            System.Net.ServicePointManager.CertificatePolicy = new ITrustAllCertificates();
            Hashtable ht = new Hashtable();
            ht["remoteClient"] = new IPEndPoint(IPAddress.Parse("192.168.0.1"), 80);
            ht["secureCode"] = "code";
            ht["transactionID"] = UUID.Random(); // UUID Line
            Console.WriteLine("New GUID: " + ht["transactionID"]);
            List<Hashtable> parameters = new List<Hashtable> { ht };
            XmlRpcRequest request = new XmlRpcRequest("CancelTransaction", parameters);
            Hashtable response;
            try {
//                response = (Hashtable)request.Invoke("https://192.168.0.164:8008");
                response = (Hashtable)request.Invoke("http://192.168.0.1:9000");
                Console.WriteLine("It seems to have worked...");
                foreach (var key in response.Keys)
                {
                    Console.WriteLine("Key: " + key + " => " + response[key]);
                }
            } catch (Exception ex) {
                Console.WriteLine("Got an exception:\n" + ex.ToString());
            }
        }
    }
}

The money server consistently complains that the secureCode and UUID are empty - when in fact…they are…because I wrote up a little “Dump the request” server and get:

Message of length 348 was defined but not a blessed scalar.
<?xml version="1.0" encoding="utf-8"?>
<methodCall>
	<methodName>
		CancelTransaction
	</methodName>
	<params>
		<param>
			<value>
				<struct>
					<member>
						<name>
							transactionID
						</name>
						<value/>
					</member>
					<member>
						<name>
							remoteClient
						</name>
						<value/>
					</member>
					<member>
						<name>
							secureCode
						</name>
						<value>
							<string>
								code
							</string>
						</value>
					</member>
				</struct>
			</value>
		</param>
	</params>
</methodCall>

In fact, the NWC-XML-RPC is behaving as though it doesn’t know how to encode anything but plain strings. The transactionID should be the type OpenMetavers.UUID (which seems to be a wrapper around GUUID) and remoteClient should be an IEndPoint from System.Net.

Obviously I’m missing something but I’m not sure what.

How does one encode OpenMetaverse and other .NET objects so that the XML-RPC client on the other end is able to decode them?

DSL
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://opensimulator.org/pipermail/opensim-users/attachments/20141129/13e426b5/attachment.html>


More information about the Opensim-users mailing list