Intro
Today, a small partner asked how to use Python to invoke the Dubbo interface method, just write an article. In fact, Dubbo interface can be used LoadRunner, jmeter and so on, preferably familiar with the Java language, then write up a lot of silk slip oh
Then using Python to invoke is actually very simple, not as you want to be so complex, basic 3, 4 steps can be done, do not hurry, to see how to achieve
Interface description
Since do interface test, that interface of the description is necessary, ask to develop GG to, do not ask where to come from .... Roughly include the following:
Interface Address
Http://192.168.133.129:20880/com.unj.dubbotest.provider.DemoService
Interface Name
Com.unj.dubbotest.provider.DemoService
Method
Sayhello,getusers
Parameters
Name
Python Invoke Environment
1, let development GG put the project Dubbo plus Hessian Way, green pollution-free
2, download Python-hessian-master, address: Https://github.com/theatlantic/python-hessian
3, install, unzip into the directory, run Python setup.py install
In this case, our Python call environment is OK.
Writing code
You can write the code when you're done with it.
#引入相关包from pyhessian.client Import hessianproxyurl = ' http://192.168.133.129:20880/' #接口地址interface = ' Com.unj.dubbotest.provider.DemoService ' #接口名full_url =url+interfaceparams= ' xiaoqiang ' #参数service = Hessianproxy ( Full_url) res = Service.sayhello (params) #sayHello是接口里的方法print (res)
Example of writing Python call Dubbo Interface Hessian protocol