[英]Write XML-RPC in C# and using it from Python
我有一個C#XML-RPC代碼,我想從Python使用它,是否有實現的能力?
這是我在C#1- dll文件中的代碼
public class Search:MarshalByRefObject
{
public string GetAllFiles()
{
return ("hhhhhhiiiiiiiiiii");
}
}
2-注冊方法
private void button1_Click(object sender, EventArgs e)
{
ChannelServices.RegisterChannel(new TcpChannel(6600));
RemotingConfiguration.RegisterWellKnownServiceType(
Type.GetType("Search,Search"), "MySearchServer", WellKnownObjectMode.SingleCall);
}
在python中
s = ServerProxy('http://localhost:6600')
print(s.GetAllFiles())
當我執行它時,出現以下錯誤
追溯(最近一次通話):
偵聽打印中的文件“ D:\\ RemotingF \\ rpc1.py”,行17(s.GetAllFiles()) 調用返回self中的文件“ C:\\ Python27 \\ lib \\ xmlrpclib.py”,行1224。_send ( 。自 _name,參數)文件“C:\\ Python27 \\ lib中\\ xmlrpclib.py”,線1570,在請求 _ 冗長=自我。 _verbose文件“ C:\\ Python27 \\ lib \\ xmlrpclib.py”,行1264,在請求返回self.single_request(主機,處理程序,request_body,詳細)文件“ C:\\ Python27 \\ lib \\ xmlrpclib.py”,行1297,在single_request中返回self.parse_response(response)文件“ C:\\ Python27 \\ lib \\ xmlrpclib.py”,行1462,在parse_response p.feed(data)文件“ C:\\ Python27 \\ lib \\ xmlrpclib.py”,行557 ,供稿中self._parser.Parse(data,0)xml.parsers.expat.ExpatError:格式不正確(無效令牌):第1行,第4列
有人幫我謝謝
您確定您的C#代碼確實是XML-RPC服務器,而不是遠程處理嗎? 從Python錯誤看來,服務器的響應似乎不是有效的XML。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.