2009-10-17 17 views
5

私のサーバーでは、私はPython(余分なHello Worldメソッド付き)の標準例を使用しています。クライアント側では、C#でXML-RPC.NETライブラリを使用しています。 。 しかし、クライアントを実行するたびに、そのメソッドが見つからないという例外があります。どのようにそれを修正する任意のアイデア。XML-RPC C#とPython RPCサーバー

ありがとうございました!

のPython:あなたはこれに宣言を変更した場合

from SimpleXMLRPCServer import SimpleXMLRPCServer 
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler 

# Restrict to a particular path. 
class RequestHandler(SimpleXMLRPCRequestHandler): 
    rpc_paths = ('/RPC2',) 

# Create server 
server = SimpleXMLRPCServer(("", 8000), 
          requestHandler=RequestHandler) 
server.register_introspection_functions() 

# Register pow() function; this will use the value of 
# pow.__name__ as the name, which is just 'pow'. 
server.register_function(pow) 

# Register a function under a different name 
def adder_function(x,y): 
    return x + y 
server.register_function(adder_function, 'add') 

def HelloWorld(): 
     return "Hello Henrik" 

server.register_function(HelloWorld,'HelloWorld') 

# Register an instance; all the methods of the instance are 
# published as XML-RPC methods (in this case, just 'div'). 
class MyFuncs: 
    def div(self, x, y): 
     return x // y 

server.register_instance(MyFuncs()) 

# Run the server's main loop 
server.serve_forever() 

C#

namespace XMLRPC_Test 
{ 
    [XmlRpcUrl("http://188.40.xxx.xxx:8000")] 
    public interface HelloWorld : IXmlRpcProxy 
    { 
     [XmlRpcMethod] 
     String HelloWorld(); 
    } 
    [XmlRpcUrl("http://188.40.xxx.xxx:8000")] 
    public interface add : IXmlRpcProxy 
    { 
     [XmlRpcMethod] 
     int add(int x, int y); 
    } 
    [XmlRpcUrl("http://188.40.xxx.xxx:8000")] 
    public interface listMethods : IXmlRpcProxy 
    { 
     [XmlRpcMethod("system.listMethods")] 
     String listMethods(); 
    } 

    class Program 
    { 
     static void Main(string[] args) 
     { 
      listMethods proxy = XmlRpcProxyGen.Create<listMethods>(); 
      Console.WriteLine(proxy.listMethods()); 
      Console.ReadLine(); 
     } 
    } 
} 
+0

stacktraceを含む例外を投稿すると、おそらく参考になる可能性があります。 –

答えて

5

それは動作しますか? Python docsから

[XmlRpcUrl("http://188.40.xxx.xxx:8000/RPC2")] 

SimpleXMLRPCRequestHandler.rpc_paths

XML-RPCリクエストを受信するためのURLの有効なパス部分をリストタプルでなければならない属性値。他のパスに投稿されたリクエストは、404ページの「そのようなページはありません」HTTPエラーになります。このタプルが空の場合、すべてのパスが有効とみなされます。デフォルト値は( '/'、 '/ RPC2')です。

+0

great。できます! –

関連する問題