python之RPC协议脚本开发

1、首先导入jar包:具体见(https://blog.csdn.net/tuntunwang/article/details/51866661

2、具体python代码如下:

#!/usr/bin/env python
# encoding: utf-8
import hprose
from hprose import HproseException


def main():
    try:
        order_id = 1111170144
        fields = "order_id,order_num,order_price"

        #声明一个hprose对象
        ob = hprose.HttpClient("http://apiservice.test.com/order/OrderCenter")
        # getOrderInfoById为服务端方法名
        print(ob.getOrderInfoById(order_id, fields))

    except HproseException as e:
        print(":" , e)

if __name__ == '__main__':
 main()

3、总结

猜你喜欢

转载自blog.csdn.net/qq_19594755/article/details/81311590