本人会点简单的 python 代码,最近琢磨: python 调用 dubbo,网上找了个例子 看不懂,请知道的帮忙解释一下。
我对 dubbo 不了解,看过官方的文档也看不懂水平有限。java 一点不懂
感谢!
# -*- coding:utf-8 -*-
from pyhessian.client import HessianProxy
from pyhessian import protocol
import json
def InvokeHessian(service, interface, method, req, retcode='000000'):
try:
url = 'http://192.168.0.1:10883/' + service + '.' + interface
print 'URL:\t%s' % url
print 'Method:\t%s' % method
print 'Req:\t%s' % req
res = getattr(HessianProxy(url), method)(req)
print 'Res:\t%s' % json.dumps(res, ensure_ascii=False)
except Exception, e:
print e
if __name__ == '__main__':
service = 'com.service.common.api.service'
interface = 'TestHessianService'
method = 'testHessian'
req = protocol.object_factory('com.service.common.api.service.model.req.TestHessianRequest',
param1='lovesoo', param2=10086)
# model.req是啥意思?
# protocol.object_factory构造的 是个什么参数?
# dubbo 有像 http接口那样的 接口文档吗?
InvokeHessian(service, interface, method, req)