Python call WebService

       A recent new development projects in Python, as a beginner, encountered many problems, the client module to call some company news website, had to use WebService implementation. WebService build I will not say, here mainly talk WebService method call in Python.

        Step 1: To install the suds library, enter easy_install suds at the command line, wait for the program to automatically install, appear to be Finished processing dependencies for suds to install a success!

Step Two: Import package from suds.client import Client, create a class websevice

 1 from suds.client import Client
2
3
4 def websevice():
5 """
6 创建websevice请求
7 """
8 url = settings.WebSeviceUrl
9 client = Client(url)
10 result = client.service
11 return result

 The third step: call WebService

1 #创建websev 
2 websev = websevice()
3 #调用方式websev.方法名(参数)
4 ws = websev.getRealInfo(param)

 

Reproduced in: https: //my.oschina.net/weisenz/blog/200611

Guess you like

Origin blog.csdn.net/weixin_34281537/article/details/91920892