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()
3 Réponses :
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. P>
ne pas toot mon propre klaxon, mais: http : //liboxyde.svn.sourceforge.net/viewvc/liboxyde/trunk/oxide.net/rpc/ qui devrait faire le tour ... Note, ce qui précède La bibliothèque est LGPL, qui peut être suffisamment bonne pour vous. P> P>
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);
}
}
}