Home | Trees | Indices | Help |
---|
|
1 from suds.client import Client 2 import urllib2 3 46 """ 7 Helper class to contruct and send SOAP requests 8 """ 9 10 client = None #: client object for making calls and receiving responses 11 api_wsdl = "" #: WSDL file url / location to define calls 12 logger = None #: logger to send loggin information to. Logger comes from pytest test definitions 1344 45 46 # # #create logger 47 # logger = logging.getLogger('test') 48 # logger.setLevel(logging.DEBUG) 49 50 # # create console handler and set level to debug 51 # ch = logging.StreamHandler() 52 # ch.setLevel(logging.DEBUG) 53 54 # # create formatter 55 # formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s') 56 57 # # add formatter to ch 58 # ch.setFormatter(formatter) 59 60 # #add ch to logger 61 # logger.addHandler(ch) 62 # logging.basicConfig(level=logging.INFO) 63 # logging.getLogger('suds.client').setLevel(logging.DEBUG) 64 # logging.getLogger('suds.transport').setLevel(logging.DEBUG) 65 # logging.getLogger('suds.xsd.schema').setLevel(logging.DEBUG) 66 # logging.getLogger('suds.wsdl').setLevel(logging.DEBUG) 67 68 #wsdl = "http://mtljiraqcprod01.ad.ypg.com/SpiraTeam/Services/v4_0/ImportExport.svc?wsdl" 69 # wsdl = "http://localhost/GetAccountsWithMerchants.WSDL" 70 # my_soap = SoapRequestor(logger,wsdl) 71 72 73 # #resp = my_soap.client.set_options(service='YPG_spcGet_spcAccounts_spcWith_spcMerchants',port='GetAccounts') 74 # #print my_soap.client 75 76 # methods = my_soap.getMethods() 77 # print methods 78 79 # for method in my_soap.client.wsdl.services[0].ports[0].methods.values(): 80 # print '%s(%s)' % (method.name, ', '.join('%s: %s' % (part.type, part.name) for part in method.soap.input.body.parts)) 81 82 83 #print methods[0] 84 #services = my_soap.client.service 85 #myAccount = my_soap.client.factory.create(u'xsdLocal0:Account') 86 #myAccount.AccountNum="3333333" 87 #print myAccount 88 89 90 #print my_soap.client.wsdl.services[0].ports[0].methods.values()[0].soap.input.body.parts 91 #print services.GetAccounts("Y","","","","4164662766","") 92 # try : 93 94 # resp = my_soap.client.service.GetAccounts("Y","","","","4164662766","") 95 96 # except suds.WebFault, e: 97 # print str(e) 98 99 # print my_soap.client.last_sent() 100 #print resp 10115 """ 16 Constructor for class 17 18 Args : 19 logger : (logger) instance of a logging object configured in testing project 20 wsdl : (str) URL to the location of the wsdl file 21 doctor : (ImportDoctor) instance of the suds.xsd.doctor.ImportDoctor class for fixing broken schemas 22 23 """ 24 25 self.logger = logger 26 self.api_wsdl = wsdl 27 28 try: 29 30 self.client = Client(self.api_wsdl, doctor=doctor) 31 except urllib2.URLError, e: 32 print str(e)3335 """ 36 Fetches a list of method objects from the wsdl and returns them in a list 37 38 Returns: (list) of suds Method objects containing all information on calling method and handling the response. 39 40 """ 41 methods = self.client.wsdl.services[0].ports[0].methods.values() 42 43 return methods
Home | Trees | Indices | Help |
---|
Generated by Epydoc 3.0.1 on Tue Nov 05 17:17:49 2013 | http://epydoc.sourceforge.net |