python suds访问webservice服务实现

(编辑:jimmy 日期: 2024/9/23 浏览:2)

安装suds

  在Python3环境下如果使用:pip install suds,应该会报ImportError: No module named client,这里推荐安装suds-py3。

使用

1.获取所有方法

webservice中的方法,跟http中的get、post这种类似。

from suds.client import Client

url = 'http://******************"text-align: center">python suds访问webservice服务实现

2.调用方法

首先调用一个不带参数的方法。

from suds.client import Client

url = 'http://************************"htmlcode">
from suds.client import Client
from suds.sax.date import DateTime
from datetime import datetime, timedelta

url = 'http://***************************"%Y-%m-%d 00:00:00") # 返回字符串形式的日期
date_time = DateTime(yesterday) # DateTime既可以直接传入字符串也可以直接传入datetime对象,我这里传入的字符串

response = client.service.getHistoryDataList(date_time, date_time, "address", "corpCode") # 返回列表,列表每一项是一个realtimeVo对象
for i in response:
 # 使用Client的dict方法,将realtimeVo对象转换为dict
 print(Client.dict(i))

3.其他

其他方法,比如:

client.set_options() # 设置头信息

目前本人没用到过。