Python调用webservice接口

from suds.client import Client
import xml.etree.ElementTree as ET

url = "http://192.168.80.10:6384/ws/r/aws_ttsrv2?wsdl"
client = Client(url)
#print(client)   #可以显示所有能调用的接口名称
#组成XML
xmldata = '\n' \
                  '\n' \
                  '\n'\
                  '\n'\
                  '\n'\
                  '\n'\
                  '\n'\
                  '\n'\
                  '\n'\
                  '\n'\
                  '\n'\
                  '\n'\
                  '\n'\
                  '\n'\
                  ''.format(self.user,self.passwd)

result = client.service.CheckUserAuth(xmldata) #调用指定接口获取返回值

#解析返回值
response = ET.fromstring(result)
Field = response.find("./ResponseContent/Parameter/Record/Field")  #查找指定节点
status = Field.attrib['value']  #获取节点值
print(status)

 

你可能感兴趣的:(python)