您好,登錄后才能下訂單哦!
不懂Python3 webservice接口測試方法是什么?其實想解決這個問題也不難,下面讓小編帶著大家一起學習怎么去解決,希望大家閱讀完這篇文章后大所收獲。
一、使用python3做webervice接口測試的第三方庫選擇suds-jurko庫,可以直接pip命令直接下載,也可以在pypi官網下載壓縮包進行手動安裝
二、安裝好后,導入Client:from suds.client import Client。發送一條請求
from suds.client import Client url = 'http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl' client = Client(url) # 打印所有webservice接口信息 print(client)
但是會出現錯誤:
Traceback (most recent call last): File "E:/PycharmProjects/lianxiUItestSelenium/***.py", line 53, in <module> client = Client('http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl') File "E:\PycharmProjects\lianxiUItestSelenium\venv\lib\site-packages\suds\client.py", line 115, in __init__ self.wsdl = reader.open(url) File "E:\PycharmProjects\lianxiUItestSelenium\venv\lib\site-packages\suds\reader.py", line 150, in open d = self.fn(url, self.options) File "E:\PycharmProjects\lianxiUItestSelenium\venv\lib\site-packages\suds\wsdl.py", line 159, in __init__ self.build_schema() File "E:\PycharmProjects\lianxiUItestSelenium\venv\lib\site-packages\suds\wsdl.py", line 220, in build_schema self.schema = container.load(self.options) File "E:\PycharmProjects\lianxiUItestSelenium\venv\lib\site-packages\suds\xsd\schema.py", line 94, in load child.dereference() File "E:\PycharmProjects\lianxiUItestSelenium\venv\lib\site-packages\suds\xsd\schema.py", line 319, in dereference midx, deps = x.dependencies() File "E:\PycharmProjects\lianxiUItestSelenium\venv\lib\site-packages\suds\xsd\sxbasic.py", line 437, in dependencies e = self.__deref() File "E:\PycharmProjects\lianxiUItestSelenium\venv\lib\site-packages\suds\xsd\sxbasic.py", line 483, in __deref raise TypeNotFound(self.ref) suds.TypeNotFound: Type not found: '(schema, http://www.w3.org/2001/XMLSchema, )'
三、只需要過濾掉一下地址就可以了。導入ImportDoctor和Import就可以
from suds.client import Client from suds.xsd.doctor import ImportDoctor, Import imp = Import('http://www.w3.org/2001/XMLSchema',location='http://www.w3.org/2001/XMLSchema.xsd') imp.filter.add('http://WebXml.com.cn/') doctor = ImportDoctor(imp) client = Client('http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl',doctor=doctor) print(client)
輸出結果:
(WeatherWebServiceSoap) Methods (5): getSupportCity(xs:string byProvinceName) getSupportDataSet() getSupportProvince() getWeatherbyCityName(xs:string theCityName) getWeatherbyCityNamePro(xs:string theCityName, xs:string theUserID)
感謝你能夠認真閱讀完這篇文章,希望小編分享Python3 webservice接口測試方法是什么內容對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,遇到問題就找億速云,詳細的解決方法等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。