# -*- coding: utf-8 from SOAPpy import SOAPProxy from SOAPpy import Types from SOAPpy import Config import re import sys import cElementTree import random #url = "http://opah.htk.tlu.ee:8080/WaramuWeb/waramuService" url = "http://opah:8080/waramuService/waramu" #url = "http://localhost:8080/WaramuWeb/waramuService" namespace= "http://wssoap.waramu.htk.tlu.ee/" username='admin' password='adminadmin' #username='vahur' #password='parool' c = Config c.debug = 0 s = SOAPProxy(url, config=c) # ======= Login in sessIdresponse = s._ns(namespace).newSession(uid=username, pwd=password) respCode = int(re.search('(.*?)', sessIdresponse).group(1)) if respCode: # not 0 msg = re.search('(.*?)', sessIdresponse).group(1) print msg sys.exit(); sessId = re.search('(.*?)', sessIdresponse).group(1) print "Session id:", sessId #f = open("questions.zip", "r") f = open("kala", "r") fcontents = f.read() f.close() pack = Types.base64BinaryType(fcontents) for x in range(1,3): print "== adding resource", x packResponse = s._ns(namespace).addAttachment(sessId=sessId, resourceId='b913f7ff8389b8e0a1fafdeab7529163a5dec8ec', attachment=pack, filename='questions.zip') print packResponse for x in range(4, 8): print "== deleting resource", x delResponse = s._ns(namespace).removeAttachment(sessId=sessId, resourceId='b913f7ff8389b8e0a1fafdeab7529163a5dec8ec', attachmentId=str(x)) print delResponse atts = s._ns(namespace).listAttachments(sessId=sessId, resourceId='b913f7ff8389b8e0a1fafdeab7529163a5dec8ec') print atts print "\nEnd. Bye-bye." logoutResponse = s._ns(namespace).closeSession(sessId=sessId) respCode = int(re.search('(.*?)', logoutResponse).group(1)) if respCode: msg = re.search('(.*?)', logoutResponse).group(1) print "Logout failed. Reason:", msg else: print "Logout successful"