XmlRpc with Mono (.NET)
|
Apotheus Silverman
I write code.
Join date: 17 Nov 2003
Posts: 416
|
06-25-2004 18:26
Hey all,
I have been working fairly extensively with XmlRpc.NET from cookcomputing.com and have found that, while it works great on windows it kinda stinks under Mono. It randomly doesn't do anything and/or throws exceptions that make no sense, etc.
In the old scripting forum (grumble) someone posted a link to an alternative XmlRpc project for .NET, but I don't remember what it was and cannot find it in any searches. Does anyone remember what it is?
Failing that I can always just write my own SL-specific library, but having a premade one is just one less thing to worry about.
Thanks for any info.
|
Grim Lupis
Dark Wolf
Join date: 11 Jul 2003
Posts: 762
|
06-25-2004 18:44
Go to http://www.xmlrpc.com/ and look for the implementations page. There's one other implementation there labelled "Microsoft .Net" that may port over to Mono. There's also som C/C++ implementations that may be portable to C# with a little work. Sorry, I don't have the link to the other one from the old forum. Since it was in the forum, it never occured to me that I may need to bookmark it. :-/
_____________________
Grim
"God only made a few perfect heads, the rest of them he put hair on." -- Unknown
|
Grim Lupis
Dark Wolf
Join date: 11 Jul 2003
Posts: 762
|
06-25-2004 18:50
I was able to find a another implementation that isn't linked from xmlrpc.com. This one may work for you. It's supposedly pure framework, no IIS piggybacking. http://www.c-sharpcorner.com/Code/2003/Feb/XmlRPC.asp
_____________________
Grim
"God only made a few perfect heads, the rest of them he put hair on." -- Unknown
|
Apotheus Silverman
I write code.
Join date: 17 Nov 2003
Posts: 416
|
06-25-2004 18:55
Awesome, thanks. I'll give it a try tomorrow and report back. I believe the problem with XmlRpc.NET from CookComputing is that the library piggybacks very heavily on System.Web.Services, which is labelled as "99% complete" on the Mono status page. As most programmers know, 99% usually means closer to about 50-70% due to unforseen bugs. 
|
Grim Lupis
Dark Wolf
Join date: 11 Jul 2003
Posts: 762
|
06-25-2004 18:57
This implementation says "It's pure C#, using .Net for networking and XML functionality."
So, if those two namespaces are working in Mono (should be, it's not like they're obscure) then this might be the perfect solution for you.
_____________________
Grim
"God only made a few perfect heads, the rest of them he put hair on." -- Unknown
|
Tcoz Bach
Tyrell Victim
Join date: 10 Dec 2002
Posts: 973
|
06-25-2004 22:56
Why would you try to run .Net under mono, and try to get it to do anything meaninful? Believe me, just use Java.
I know .Net. It is built to run on Windows 2k+. Yeah yeah, CTS, CLR, and all the rest of it. Fact is, the libraries are built to run on Windows. A huge majority of the objects just mask win32 calls. Even internally, MS knows that .Net multiplatform is nothing more than "hope" for the non-monopoly masses. Anything else is pirate radio, and you can expect the same fidelity.
Start an EnterpriseSErvices call, and watch your app get installed under COM+. The IO libraries...all meant to understand Windows flavors of files systems. The drawing libraries...all win32 under the hood, even the UI objects. The web classes, all require IIS. The message queue libraries, all MSMQ friendly. The CLR itself speaks to the registry, and is tuned to put out Intel-centric native code (well ok so Linux runs on Intel).
Maybe some day. But not today, tomorrow, or day after. You may as well take the FreeBSD reference implementation (the most mature alt-plat .Net) and try that...and crash. In the end, somebody will pull it off. But it won't be .Net. It will be the CTS, with a paralell library structure (which I gotta hand .Net credit for, it's elegant) implemented entirely differently, somewhere else.
I'm a big .Net advocate, and have been working with it for years, but not a big Microsoft advocate, which is a hard place to be. I've tried and tried...but if you're not running Windows, you ain't runnin' .Net. Not productively and in a stable fashion anyway. Purely academic, sure, why not. MS is trying to crack into the "when they teach OOP they teach Java" market. But don't try to run a business on it (Mono FreeBSD etc.) I'll tell ya that.
_____________________
** ...you want to do WHAT with that cube? **
|
Grim Lupis
Dark Wolf
Join date: 11 Jul 2003
Posts: 762
|
06-26-2004 07:40
From: someone Originally posted by Tcoz Bach I'm a big .Net advocate, and have been working with it for years, but not a big Microsoft advocate, which is a hard place to be. I've tried and tried...but if you're not running Windows, you ain't runnin' .Net. Not productively and in a stable fashion anyway. Purely academic, sure, why not. MS is trying to crack into the "when they teach OOP they teach Java" market. But don't try to run a business on it (Mono FreeBSD etc.) I'll tell ya that. I have to agree with you on this one, Tcoz. There's a lot of software that Microsoft puts out that I'm a big fan of, especially their development platforms/tools. But their business and security practices leave a lot to be desired. It's really quite a quandry. :-/
_____________________
Grim
"God only made a few perfect heads, the rest of them he put hair on." -- Unknown
|
Apotheus Silverman
I write code.
Join date: 17 Nov 2003
Posts: 416
|
06-27-2004 14:15
Okay after reviewing the choices, I decided to go with XmlRpcCS. It is post-version-1.0, and there is a link to mono-specific build instructions on the homepage (in case you want to build under mono, but that's not absolutely necessary). I found that I like this library a lot better than the one from Cook Computing. It's easier to use and more straight-forward as well. It looks to be pretty rock-solid under Mono so far. Regarding Tcoz's rant, I am well aware of all that. However, the latest builds of Mono are fairly stable when running on Linux (I managed to get it working/crashing on FreeBSD, but that was easier said than done). Remember, Novell has a team of developers all working on the Mono project, and I have to say I'm very impressed with what they've managed to do with it in such a short time. I decided to go with linux and Mono because #1) they're free and Windows isn't, #2) I'd have had to spend a lot more money on hardware just to run a windows server and #2) .NET is what I code in all day, every day. Below I have posted the class I am using to easily make XmlRpc requests to SL via XmlRpcCS. Note that there is more here than the bare minimum because I structure classes according to the .NET class design guidelines and make full use of Intellisense comments. using System; using System.Collections; using Nwc.XmlRpc;
namespace Sample { /// <summary> /// Abstracts XmlRpc calls to the Second Life XmlRpc server. /// </summary> public class SLXmlRpcRequest { // Fields private string channelValue; private int intValueValue; private string stringValueValue; private const string channelDefault = ""; private const int intValueDefault = 0; private const string stringValueDefault = "";
// Properties #region Channel property /// <summary> /// Request or response channel /// </summary> public string Channel { get { return(channelValue); } set { channelValue = value; } } #endregion
#region IntValue property /// <summary> /// Request or response integer value /// </summary> public int IntValue { get { return(intValueValue); } set { intValueValue = value; } } #endregion
#region StringValue property /// <summary> /// Request or response string value /// </summary> public string StringValue { get { return(stringValueValue); } set { stringValueValue = value; } } #endregion
// Methods #region Equals() method /// <summary> /// Overrides Object.Equals() to compare this data type by value /// instead of by reference. /// </summary> /// <param name="obj">The item you wish to compare to the current instance</param> /// <returns></returns> public override bool Equals(Object obj) { //Check for null and compare run-time types. if (obj == null || GetType() != obj.GetType()) { return(false); } SLXmlRpcRequest mySLXmlRpcRequest = (SLXmlRpcRequest)obj; return(this.Channel == mySLXmlRpcRequest.Channel && this.IntValue == mySLXmlRpcRequest.IntValue && this.StringValue == mySLXmlRpcRequest.StringValue); } #endregion
#region GetHashCode() method /// <summary> /// Returns a HashCode for the current instance /// </summary> /// <returns></returns> public override int GetHashCode() { return(this.Channel.GetHashCode() ^ this.IntValue.GetHashCode() ^ this.StringValue.GetHashCode()); } #endregion
#region Invoke() method /// <summary> /// Sends the request to the Second Life XmlRpc server and returns the result. /// </summary> /// <returns></returns> public SLXmlRpcRequest Invoke() { // Set up data to send Hashtable mySLXmlRpcData = new Hashtable(); mySLXmlRpcData["Channel"] = this.Channel; mySLXmlRpcData["IntValue"] = this.IntValue; mySLXmlRpcData["StringValue"] = this.StringValue; XmlRpcRequest client = new XmlRpcRequest(); client.MethodName = "llRemoteData"; client.Params.Clear(); client.Params.Add(mySLXmlRpcData); mySLXmlRpcData = (Hashtable)client.Invoke("http://xmlrpc.secondlife.com/cgi-bin/xmlrpc.cgi"); return(new SLXmlRpcRequest(mySLXmlRpcData["Channel"].ToString(), System.Convert.ToInt32(mySLXmlRpcData["IntValue"]), mySLXmlRpcData["StringValue"].ToString())); } #endregion
#region constructor method (overloaded) public SLXmlRpcRequest() : this(channelDefault, intValueDefault, stringValueDefault) {} public SLXmlRpcRequest(string channel) : this(channel, intValueDefault, stringValueDefault) {} public SLXmlRpcRequest(string channel, int intValue) : this(channel, intValue, stringValueDefault) {} public SLXmlRpcRequest(string channel, int intValue, string stringValue) { // Set properties this.Channel = channel; this.IntValue = intValue; this.StringValue = stringValue; } #endregion } }
and here is sample usage: SLXmlRpcRequest mySLXmlRpcRequest = new SLXmlRpcRequest("79b14e93-90b4-bd18-e8dd-0afe928f2adc", 0, "test string"); SLXmlRpcRequest mySLXmlRpcResponse = mySLXmlRpcRequest.Invoke();
Edit: made the sample usage slightly less confusing.
|
Amandir Beckenbauer
Registered User
Join date: 22 Feb 2004
Posts: 18
|
06-29-2004 20:47
Why? I would think that the simplicity of the task in c# versus java would be a sufficient reason. Take a look at the example xml-rpc java solution. How many classes were there? I use java for quite a few solutions because of its cross platform capability. But let's face it; to create a working xml-rpc solution in java takes much more code (and classes) than it should. I shouldn't be feeding the trolls, but come on. That's akin to asking why I would ever want to run SL on my linux computer when I have a variety of other entertainment choices such as tux racer. I'm no fan of MS and their practices, but linux is about freedom of choice. It would make sense then to allow people the freedom to choose which language they would like to code in. /rant From: someone Originally posted by Tcoz Bach Why would you try to run .Net under mono, and try to get it to do anything meaninful? Believe me, just use Java.
I know .Net. It is built to run on Windows 2k+. Yeah yeah, CTS, CLR, and all the rest of it. Fact is, the libraries are built to run on Windows. A huge majority of the objects just mask win32 calls. Even internally, MS knows that .Net multiplatform is nothing more than "hope" for the non-monopoly masses. Anything else is pirate radio, and you can expect the same fidelity.
Start an EnterpriseSErvices call, and watch your app get installed under COM+. The IO libraries...all meant to understand Windows flavors of files systems. The drawing libraries...all win32 under the hood, even the UI objects. The web classes, all require IIS. The message queue libraries, all MSMQ friendly. The CLR itself speaks to the registry, and is tuned to put out Intel-centric native code (well ok so Linux runs on Intel).
Maybe some day. But not today, tomorrow, or day after. You may as well take the FreeBSD reference implementation (the most mature alt-plat .Net) and try that...and crash. In the end, somebody will pull it off. But it won't be .Net. It will be the CTS, with a paralell library structure (which I gotta hand .Net credit for, it's elegant) implemented entirely differently, somewhere else.
I'm a big .Net advocate, and have been working with it for years, but not a big Microsoft advocate, which is a hard place to be. I've tried and tried...but if you're not running Windows, you ain't runnin' .Net. Not productively and in a stable fashion anyway. Purely academic, sure, why not. MS is trying to crack into the "when they teach OOP they teach Java" market. But don't try to run a business on it (Mono FreeBSD etc.) I'll tell ya that.
|
Tcoz Bach
Tyrell Victim
Join date: 10 Dec 2002
Posts: 973
|
06-30-2004 08:24
My point is that .Net is not implemented on par on Linux in any fashion. However there is no arguing with religious notions about liberty or choice, which tends to be the bastion of the Linux advocate when they run out of technical steam. Also, we are talking about maturity and stability of available .Net environments, not language.
And regarding your insulting comment of feeding trolls, I'm one of the oldest residents in SL, and have been coding hard in LSL likely since long before you ever heard of the game, noob.
_____________________
** ...you want to do WHAT with that cube? **
|
Eddy Stryker
libsecondlife Developer
Join date: 6 Jun 2004
Posts: 353
|
07-01-2004 15:31
From: someone Originally posted by Tcoz Bach And regarding your insulting comment of feeding trolls, I'm one of the oldest residents in SL, and have been coding hard in LSL likely since long before you ever heard of the game, noob. YEAH! SUCK IT! *phew* that's gotta be an adrenaline rush, flaming people on the Internet about how you've been playing a game longer than they have.
|
Kelly Linden
Linden Developer
Join date: 29 Mar 2004
Posts: 896
|
07-01-2004 16:17
Your solution in C# does not look considerably less complicated than a Java implementation. In fact your C# implementation looks incredibly similar to my Java implementation. Christopher Omega created a much fuller implementation that did more error checking and handled both asynchronous as well as synchronous requests. I have not had extensive use in C# so its possible that I am missing something. Since my code was lost (*sniff*) in the forum change....This is free to use. Use: llXmlRpc myClient = new llXmlRpc(/* enter channel here*/); Hashtable result = myClient.call("GetStuff!",5); // From Apache: http://ws.apache.org/xmlrpc/ import org.apache.xmlrpc.*;
import java.util.*;
/* * This class manages an XML-RPC connection to an LSL script * Sorry, no real comments, perhaps I will add them later and repost. * * Example use: * * llXmlRpc myClient = new llXmlRpc("7f8c3305-d1ea-01a3-5192-9c7e29f7fe4d"); * Hashtable result = myClient.call("This will be sent to my LSL script",5); * System.out.println("Received : [" + result.get("IntValue") + "]\n" + * result.get("StringValue")); */ public class llXmlRpc { private XmlRpcClientLite myClient;
private Vector params; private Hashtable struct;
llXmlRpc(java.lang.String newChannel) { this(); setChannel(newChannel); }
llXmlRpc() { params = new Vector(); struct = new Hashtable(); params.add(struct);
try { myClient = new XmlRpcClientLite( "http://xmlrpc.colo.lindenlab.com/cgi-bin/xmlrpc.cgi"); } catch(Exception e) { System.err.println("Exception caught: " + e.getClass() + " :: " + e.getMessage()); } }
public void setChannel(java.lang.String newChannel) { struct.put("Channel",newChannel); }
public Hashtable call(String StringValue, int IntValue) { Hashtable ret = null; if (struct.get("Channel") != null) { try { struct.put("IntValue",new Integer(IntValue)); struct.put("StringValue",StringValue);
ret = (Hashtable)myClient.execute("llRemoteData",params); } catch(Exception e) { System.err.println("Exception caught (call): " + e.getClass() + " :: " + e.getMessage()); } } else { System.err.println("No channel defined, call not made."); }
return ret; } }
|
Tcoz Bach
Tyrell Victim
Join date: 10 Dec 2002
Posts: 973
|
07-06-2004 20:08
Lol Eddy. Just a game huh. Noob.
Since you clearly don't get it, you are dismissed.
Your prattle shall be...
IGNORED!!!
/ignore
_____________________
** ...you want to do WHAT with that cube? **
|