5月 22

python 访问接口获得 WSDL 数据

  需求访问http://192.168.1.100:8080/Service?wsdl,获取统计数字,接口“Count”参数有“user:string,pwd:string”。
  WSDL是Web Service的描述语言,是一种接口定义语言,用于描述Web Service的接口信息等。
  首先,安装SOAPpy
easy_install SOAPpy
代码如下:

def get_service():
    _url = "http://192.168.1.100:8080/Service?wsdl"
    _user = "test"
    _pwd = "test"
    try:
        server = SOAPpy.SOAPProxy(_url)
        get_result = server.Count(_user, _pwd)
    except:
        get_result = "Error!"
    return "%s" % get_result