7
votes

Comment communiquer entre Python et C # en utilisant XML-RPC?

Supposez que j'ai un simple service XML-RPC implémenté avec Python:

from SimpleXMLRPCServer import SimpleXMLRPCServer  # Python 2

def getTest():
    return 'test message'

if __name__ == '__main__' :
    server = SimpleXMLRPCServer(('localhost', 8888))
    server.register_function(getTest)
    server.serve_forever()


0 commentaires

3 Réponses :


2
votes

Pour appeler la méthode GetTest à partir de C #, vous aurez besoin d'une bibliothèque client XML-RPC. XML-RPC est un exemple d'une telle bibliothèque.


0 commentaires

3
votes

ne pas toot mon propre klaxon, mais: http : //liboxyde.svn.sourceforge.net/viewvc/liboxyde/trunk/oxide.net/rpc/ xxx

qui devrait faire le tour ... Note, ce qui précède La bibliothèque est LGPL, qui peut être suffisamment bonne pour vous.


0 commentaires

3
votes

Merci de réponse, j'essaie une bibliothèque XML-RPC de Darin Link. Je peux appeler GetTest fonction avec le code suivant

using CookComputing.XmlRpc;
...

    namespace Hello
    {
        /* proxy interface */
        [XmlRpcUrl("http://localhost:8888")]
        public interface IStateName : IXmlRpcProxy
        {
            [XmlRpcMethod("getTest")]
            string getTest();
        }

        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            private void button1_Click(object sender, EventArgs e)
            {
                /* implement section */
                IStateName proxy = (IStateName)XmlRpcProxyGen.Create(typeof(IStateName));
                string message = proxy.getTest();
                MessageBox.Show(message);
            }
        }
    }


0 commentaires