Example of writing Python call Dubbo Interface Hessian protocol

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.