python 或者 telnet 调用 dubbo 服务

230 阅读1分钟

python 或者 telnet 调用 dubbo 服务

1 dubbo 协议

telnet 127.0.0.1 19101
​
invoke com.xxx.FastDFSAPI.getAliasDetailVoByAliasPath("ddd")

2 hessian 协议

  1. 安装 python-hessian

    pip install python-hessian
    
  2. python 代码

    # coding=utf-8
    from pyhessian.client import HessianProxy
    import json
    ​
    ​
    if __name__ == '__main__':
        url = 'http://172.30.43.220:19001/'  # 接口地址
        interface = 'com.yyigou.ddc.services.dfs.api.FastDFSAPI'  # 接口名
        full_url = url + interface
        params = 'wujp'  # 参数
    ​
        service = HessianProxy(full_url)
        res = service.getAliasDetailVoByAliasPath(params)
        # json_object = json.loads(res.__dict__)
        json_data = json.dumps(res.__dict__, encoding='gbk',ensure_ascii=False, indent=4)
        # formatted_str = json.dumps(json_object, indent=4)
        print(json_data)
    ​