一、Python服务端代码
from jsonrpclib.SimpleJSONRPCServer import SimpleJSONRPCServer
from socketserver import ThreadingMixIn
def fun1(a):
print(a)
return a
class ThreadJSONRPCServer(ThreadingMixIn, SimpleJSONRPCServer):pass
server = ThreadJSONRPCServer(('127.0.0.1', 9091))
server.register_function(fun1)
server.serve_forever()
二、Python客户端代码
import json
import jsonrpclib
if __name__ == '__main__':
print("main:: start.")
a = {
"abandoned-resume-allowed": "false",
"discard-abandoned-after": "60",
"max-no-answer": "5",
"max-wait-time": "1",
"max-wait-time-with-no-agent": "25",
"max-wait-time-with-no-agent-time-reached": "5",
"moh-sound": "$${hold_music}",
"queue": "wang@defaut",
"strategy": "top-down",
"tier-rule-no-agent-no-wait": "false",
"tier-rule-wait-multiply-level": "true",
"tier-rule-wait-second": "300",
"tier-rules-apply": "false",
"time-base-score": "system"
}
a = json.dumps(a)
rpc_client = jsonrpclib.Server("http://127.0.0.1:9091/")
ret = rpc_client.fun1(a)
print("main:: end.")
python作为客户端时用同样的代码就可以调用java的服务端