In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-08 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
It is believed that many inexperienced people have no idea about how to implement Python+telnet command to automate testing dubbo protocol interface. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.
1. The python language can also call and test the dubbo interface, either using the combination of python+hessian or python+telnet to simulate the command line mode to test the dubbo interface.
Second, there are many blogs about python+hessian protocol on the Internet. I tried it, but I didn't pass the test on this computer, so I chose: the method of python+telnet implements the test of Python source code calling dubbo interface in the compiler.
3. The specific source code is as follows:
1. Line 20 of the code explanation:
Num20 line: "invoke {0} {1} ()" .format (service_name,method_name)
(1) invoke is the name of the command that calls the dubbo interface
(2) {0} is the first parameter that needs to be followed by the invoke command, and its value will be replaced by the passed-in service_name, which is usually the passed-in service name. It is written here only to occupy a space.
(3) {1} is the second parameter to be followed by the invoke command, and its value will be replaced by the passed-in method_name, usually passing in the name of the called method, which is written here only to occupy a space.
(4), () is the third parameter to be followed by the invoke command. The example here shows that the method called by the dubbo service can be successfully called without passing parameters. Although no parameters are required, it must be written in ().
(5) question: what if the method of the called dubbo service needs to pass in the corresponding parameters?
Answer: the num20 line code is rewritten as "invoke {0} {1} ({2})" .format (service_name,method_name,param_data). You need to add a placeholder at the third parameter, and pass in the corresponding parameter when calling the method, which is usually the parameter in key:value format, that is, the data in dictionary format in python.
2. line 28 of the code explanation:
Conn = Dubbo ('serviceIp', port)
(1) serviceIp: the IP address to which the called service belongs
(2) port: the accessible externally exposed port corresponding to the called service
Note: if the port number is an internal port, an error will be reported when called in this way.
After reading the above, have you mastered how the Python+telnet command automates the testing of the dubbo protocol interface? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 274
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.