第七篇:suds.TypeNotFound: Type not found: '(string, http://schemas.xmlsoap.org/soap/encoding/, )'

想要用Python的suds模塊調用webservice地址作自動測試,可是找了不少方法都失敗了,最終找到另一個模塊能夠做爲客戶端訪問服務器地址。html

1.針對非安全的httppython

from zeep import Client
url = "http://***?wsdl"
from zeep import Client
client = Client(url)
result = client.service.getCircuit('11111') # getCircuit 爲服務端提供的接口服務,能夠調用,括號中傳相應的參數
print(result)

打印結果:web

{
'_value_1': '{"errorMsg":"沒有找到路由信息!"}',
'id': None,
'href': None,
'_attr_1': {
}
}安全

2.針對安全的https服務器

from requests import Session
from zeep import Client
from zeep.transports import Transport
url = "https://***?wsdl"
session = Session()    # 這裏是由於url是https,否則不須要transport
session.verify = False
transport = Transport(session=session)
client = Client(url)
result = client.service.getCircuit('11111') # getCircuit 爲服務端提供的接口服務,能夠調用,括號中傳相應的參數
print(result)

 關於zeep可參考:https://python-zeep.readthedocs.io/en/master/index.htmlsession

本文參考:https://blog.csdn.net/Ohmyberry/article/details/80430944?utm_source=blogxgwz4測試

相關文章
相關標籤/搜索