1)引入suds库,代码如下:
from suds.client import Client
2)创建一个 webservice 对象,来调用 webservice 里面的各类接口
webservice 访问地址
user_url = "http://127.0.0.1:8081/PosMerchant/ZfMposPort"
client = Client(user_url) # Client里面直接放访问的URL,可以生成一个 webservice 对象
3)打印出这个 wsdl 地址里面的所有接口信息:# 打印出 webservice 里面的所有接口方法名称,结果如下截图所示:
print(client)
4)利用 soapui(软件工具) 来看看 webservice 某个接口的组成和参数,其中一个注册接口,如下所示:
'<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mpos="http://mpos.zf/">'\
'<soapenv:Header/>'\
'<soapenv:Body>'\
'<mpos:withdrawCash>'\
'<arg0>'+str(t['merCode'])+'</arg0>'\
'<arg1>'+str(t['tranAmt'])+'</arg1>'\
'<arg2>'+str(t['md5Str'])+'</arg2>'\
'<arg3>'+str(t['termID'