diff --git a/modules/xmlrpc/doc/xmlrpc.xml b/modules/xmlrpc/doc/xmlrpc.xml index c9751283ed1..1e2dce13e87 100644 --- a/modules/xmlrpc/doc/xmlrpc.xml +++ b/modules/xmlrpc/doc/xmlrpc.xml @@ -31,7 +31,7 @@
Design Goals - + @@ -99,7 +99,7 @@ User-Agent: Radio UserLand/7.1b7 (WinNT) Host: time.xmlrpc.com Content-Type: text/xml Content-length: 131 - + currentTime.getCurrentTime @@ -307,7 +307,7 @@ if (method == "POST" || method == "GET") { dispatch_rpc scans through the list of all exported RPC functions searching for the statistics function of the usrloc module. The - + &kamailio; RPC Module API describes in detail how modules export RPC functions. @@ -367,7 +367,7 @@ Warning: 392 127.0.0.1:5060 "Noisy feedback tells: pid=9975 req_src_ip=127.0.0 HTTP requests from one SIP server to another and use standard SIP routing mechanisms to decide which SIP server should process the request. There is no need to have multiple SIP - servers in simple setups, because one SIP server can both add + servers in simple setups, because one SIP server can both add fake Via header field and process the RPC at the same time. Modified configuration file snipped could then look like this: @@ -659,8 +659,8 @@ Content-Length: 276
Interoperability Problems - Due to a bug in Python xmlrpclib there is an interoperability - problem with basic clients using it: by default an xmlrpclib client + Due to a bug in Python xmlrpclib there is an interoperability + problem with basic clients using it: by default an xmlrpclib client expects the server to immediately close the connection after answering and if the server does not close the connections the xmlrpclib client will wait forever. @@ -671,7 +671,7 @@ Content-Length: 276 make ser close the tcp connection after each request. - The + The examples/xmlrpc_test.py provides a very simple example of using xmlrpclib with a Transport class that works. @@ -683,7 +683,7 @@ Content-Length: 276 set_reply_no_connect() is also recommended (avoid trying to open tcp connection to xmlrpc clients that closed it). Alternatively ending the XMLRPC route with return -1, exit -1 or - drop -1 can also be used, but note that this will not work for + drop -1 can also be used, but note that this will not work for async rpcs (it will close the connection immeidately and not on the async response). @@ -716,37 +716,44 @@ route[XMLRPC]{
Client Examples - + examples/xmlrpc_test.pl (basic perl application that builds and sends an XMLRPC request from its commandline parameters). - + examples/xmlrpc_test.py (basic python application that builds and sends an XMLRPC request from its commandline parameters). + + + examples/xmlrpc_test2.py + (basic python application that builds and sends an + XMLRPC request from its commandline + parameters). + ser_ctl - (complex python application that + (complex python application that uses the XML-RPC interface implemented by the xmlrpc module). @@ -755,7 +762,7 @@ route[XMLRPC]{ serweb (php application that can use - the XML-RPC interface to call ser + the XML-RPC interface to call ser functions). diff --git a/modules/xmlrpc/examples/xmlrpc_test2.py b/modules/xmlrpc/examples/xmlrpc_test2.py index 0fdee1eec87..b6c02fd82ca 100644 --- a/modules/xmlrpc/examples/xmlrpc_test2.py +++ b/modules/xmlrpc/examples/xmlrpc_test2.py @@ -1,10 +1,11 @@ -import xmlrpclib, httplib, sys +import sys +import xmlrpclib # Usage: python xmlrpc_test2.py command [params...] # # python script for sending an xmlrpc command to ser's xmlrpc module. # This script uses python xmlrpclib directly and expects the remote side to -# immediately close the connection after answering (broken xmlrpclib +# immediately close the connection after answering (broken xmlrpclib # behaviour). # There are 2 way to make it work with ser xmlrpc module: define a # better transport class (that's what the xmlrpc_test.py script is doing) or @@ -23,7 +24,15 @@ if len(sys.argv) < 2: - sys.exit("Usage: "+sys.argv[0]+" rpc_command [args...]"); -c=xmlrpclib.ServerProxy("http://" + XMLRPC_SERVER+ ":" + str(XMLRPC_PORT)) -res=getattr(c, sys.argv[1])(*sys.argv[2:]) -print res; + sys.exit("Usage: " + sys.argv[0] + " rpc_command [args...]") + +client = xmlrpclib.ServerProxy( + "http://{0}:{1}".format(XMLRPC_SERVER, XMLRPC_PORT)) +res = getattr(client, sys.argv[1])(*sys.argv[2:]) +print res + +##### +# You can use this simple way. +#client =xmlrpclib.ServerProxy("http://127.0.0.1:5060") +#res = client.htable.listTables() +#print res