類庫安裝
直接使用命令行:pip install suds
報錯:Traceback (most recent call last):
File "setup.py", line 20, in <module>
import suds
File "/root/python-suds-0.4.1/suds/__init__.py", line 154, in <module>
import client
ImportError: No module named client
后來從網上看到了解決方案,說官網已經用另外一個庫替代了這個庫
pip install suds-jurko
此庫是為了解決python訪問webservice的
調用代碼:
1 import suds 2 3 from suds.client import Client 4 5 url = "http://192.168.1.235:12581/ServiceYuYue.svc?wsdl" 6 client = suds.client.Client(url) 7 8 #getHealthyHeBei是webService提供的方法 9 result = client.service.getHealthyHeBei(18210409689) 10 11 #打印出結果 12 print(result)
使用開源的東西就有一點不好,兼容性做不好的時候需要自己去不斷摸索,而沒有太多的現成的解決方案可供參考。