标签:
python调用SOA服务,运用suds模块
#! /usr/bin/python # coding:gbk import suds,time,sys reload(sys) sys.setdefaultencoding( "utf-8" ) LOG_PATH = r".\TestLog"+time.strftime(r‘%Y-%m-%d‘, time.localtime(time.time()))+".txt" def TestService(): url=‘服务的WSDL链接地址‘ client = suds.client.Client(url) param1=dict(X=‘123‘) result1=client.service.METHODNAME1(param1) writeLog(‘METHODNAME1‘,result1)
def writeLog(methodname,result): ‘‘‘写日志‘‘‘ with open(LOG_PATH,"a") as testLog: content = time.strftime(r‘%X‘, time.localtime(time.time())) + "\t|" +methodname + "\n" for item in result: content=content+‘\t|‘+str(item) testLog.writelines(‘+‘*60+"\n") testLog.writelines(content) testLog.write("\n") testLog.close() if __name__=="__main__": TestService()
标签:
原文地址:http://www.cnblogs.com/hito/p/4630610.html