# -*- 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("test.zip", "r") fcontents = f.read() f.close() pack = Types.base64BinaryType(fcontents) packResponse = s._ns(namespace).newPackage(sessId=sessId, package=pack) print packResponse 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"