import org.apache.xmlrpc.*;
XmlRpcClientLite c =
new XmlRpcClientLite
("http://dfa.imn.htwk-leipzig.de/cgi-bin/simple_server");
Object s = c.execute("examples.add",
new Vector<Integer>
(Arrays.asList (new Integer[] { 3, 4 })));
(vgl. http://ws.apache.org/xmlrpc/xmlrpc2/)
netcat -l -p 9876 auf lokalem Rechner
class Numbers {
public int add (int x, int y)
{ return x+y; }
}
// Eine Server-Klasse mit main:
WebServer w = new WebServer(9876);
w.addHandler("Numbers", new Numbers());
w.start ();
(benötigt xmlrpc-2.0.jar, commons-codec-1.3.jar)
import Network.XmlRpc.Server
add :: Int -> Int -> IO Int
add x y = return (x + y)
main = cgiXmlRpcServer [("Numbers.add", fun add)]
// see http://www.xml-rpc.net/faq/xmlrpcnetfaq.html
using CookComputing.XmlRpc;
[XmlRpcUrl("http://XXX.imn.htwk-leipzig.de:9876")]
interface IAdd
{
[XmlRpcMethod("Numbers.add")]
int Add(int x, int y);
}
class _ {
public static void Main () {
IAdd proxy = (IAdd)XmlRpcProxyGen.Create(typeof(IAdd));
int result = proxy.Add(2, 3);
System.Console.WriteLine (result);
}
}
Compilation etwa so:
mcs -r:/home/waldmann/mono-1.1.15/lib/mono/gac/CookComputing.XmlRpc/0.9.2.1__a7d6e17aa302004d/CookComputing.XmlRpc.dll Simple_Client.cs