def SetupClient(wurl, auth, toAddToken=True, toImportMsgSrc=True, toImportArrSrc=False): if toImportMsgSrc: # update WSDL (xsd) msgImport = Import('http://api.eyeblaster.com/message') if toImportArrSrc: arrImport = Import( 'http://schemas.microsoft.com/2003/10/Serialization/Arrays' ) doctor = ImportDoctor(msgImport, arrImport) else: doctor = ImportDoctor(msgImport) client = Client(wurl, doctor=doctor, faults=False) else: client = Client(wurl, faults=False) if toAddToken: # update token into SOAP header header = ('ns1', 'http://api.eyeblaster.com/message') element = Element('UserSecurityToken', ns=header).setText(auth.token) client.set_options(soapheaders=element) return client
def _get_creatives_client(self): self.logon(self.username, self.password, 'Publisher') wsdl_url = self.url + '/PublisherCreative.svc?wsdl' schema_url = 'http://affilinet.framework.webservices/Svc' schema_import = Import(schema_url) schema_doctor = ImportDoctor(schema_import) schema_doctor.add(Import('http://affilinet.framework.webservices/types/PublisherCreative')) schema_doctor.add(Import('http://schemas.microsoft.com/2003/10/Serialization/Arrays')) client = SudsClient(url=wsdl_url, doctor=schema_doctor) return client
def create_soap_client(self, url_or_path, alias=None, autoblend=False, timeout='90 seconds'): """Loads a WSDL from the given URL/path and creates a Suds SOAP client. Returns the index of this client instance which can be used later to switch back to it. See `Switch Soap Client` for example. Optional alias is an alias for the client instance and it can be used for switching between clients (just as index can be used). See `Switch Soap Client` for more details. Autoblend ensures that the schema(s) defined within the WSDL import each other. `timeout` sets the timeout for SOAP requests and must be given in Robot Framework's time format (e.g. '1 minute', '2 min 3 s', '4.5'). Examples: | Create Soap Client | http://localhost:8080/ws/Billing.asmx?WSDL | | Create Soap Client | ${CURDIR}/../wsdls/tracking.wsdl | """ url = self._get_url(url_or_path) autoblend = to_bool(autoblend) kwargs = {'autoblend': autoblend} imports = self._imports if imports: self._log_imports() kwargs['doctor'] = ImportDoctor(*imports) client = Client(url, **kwargs) index = self._add_client(client, alias) self._set_soap_timeout(timeout) return index
def request(self, start_date, end_date): imp = Import('http://theaffiliategateway.com/data/schemas') client = Client(self.url, doctor=ImportDoctor(imp), cache=NoCache()) authentication = client.factory.create('AuthenticationType') authentication.username = self.username authentication.apikey = self.password criteria = client.factory.create('CriteriaType') criteria.StartDateTime = start_date.isoformat() + ' 00:00:00' criteria.EndDateTime = end_date.isoformat() + ' ' + '00:00:00' result = client.service.GetSalesData(authentication, criteria) data = [] if result.Transactions: for transaction in result.Transactions.Transaction: entry = dict() for field in transaction: entry[field[0]] = field[1] data.append(entry) output = pandas.DataFrame() if len(data) > 0: output = output.append(data, ignore_index=True) output = output.rename(columns=lambda x: 'ag:' + x) return output
def __init__(self, username, password, wsdl, cucm, cucm_version=10): """ :param username: axl username :param password: axl password :param wsdl: wsdl file location :param cucm: UCM IP address :param cucm_version: UCM version """ self.username = username self.password = password self.wsdl = wsdl self.cucm = cucm self.cucm_version = cucm_version tns = 'http://schemas.cisco.com/ast/soap/' imp = Import('http://schemas.xmlsoap.org/soap/encoding/', 'http://schemas.xmlsoap.org/soap/encoding/') imp.filter.add(tns) t = HttpAuthenticated(username=self.username, password=self.password) t.handler = urllib.request.HTTPBasicAuthHandler(t.pm) ssl_def_context = ssl.create_default_context() ssl_def_context.check_hostname = False ssl_def_context.verify_mode = ssl.CERT_NONE t1 = urllib.request.HTTPSHandler(context=ssl_def_context) t.urlopener = urllib.request.build_opener(t.handler, t1) self.client = Client(self.wsdl, location='https://{0}:8443/axl/'.format(cucm), faults=False, plugins=[ImportDoctor(imp)], transport=t)
def holdseats(): imp = Import('http://www.w3.org/XML/1998/namespace', location='http://*****:*****@xyz.com" contactInfo.Phone = "99877778" contactInfo.Mobile = "09999988988" arrayOfPassenger = client.factory.create('ArrayOfPassenger') passenger = client.factory.create('Passenger') passenger.Name = 'shekhar' passenger.Age = '25' passenger.Gender = 'M' passenger.SeatNo = 'S5' passenger.Fare = '200' passenger.SeatType = 'ac' passenger.IsAcSeat = '1' arrayOfPassenger.Passenger.append(passenger) result = client.service.HoldSeatsForSchedule(authentication, 123, '', 123, contactInfo, arrayOfPassenger) print result.content
def __init__(self): self.url = 'https://swedishspeciesobservation.artdatabankensoa.se/SwedishSpeciesObservationService.svc?singleWsdl' self.usr = '******' self.pw = 'Hack4Swe2' self.appIdent = 'HackForSweden' self.session = '' self.wci = '' self.token = '' imp = Import('http://schemas.xmlsoap.org/soap/encoding/') imp.filter.add('ArtDatabanken.WebService.Data') doctor = ImportDoctor(imp) try: self.client = Client(self.url, doctor=doctor, retxml=True) res = self.client.service.Login(self.usr, self.pw, self.appIdent, 0) if(res): print("*** Logged in successfully. ***") self.session = xmltodict.parse(res) self.wci = self.client.factory.create( 'ns1:WebClientInformation') self.token = self.session['s:Envelope']['s:Body']['LoginResponse']['LoginResult']['a:Token'] self.wci['Token'] = self.token except WebFault as e: print("*** Error loggin in: ", e) exit(1) except Exception as e: print("Error creating client: ", e) exit(1)
def axlinsertSQL(server, name, newval): #get AXL information from GUI info = connectAXL() location = info.get('location') username = info.get('username') password = info.get('password') wsdl = info.get('wsdl') t = HttpAuthenticated(username=username, password=password) t.handler = urllib.request.HTTPBasicAuthHandler(t.pm) ssl_def_context = ssl.create_default_context() ssl_def_context.check_hostname = False ssl_def_context.verify_mode = ssl.CERT_NONE ssl_def_context.set_ciphers('HIGH:!DH:!aNULL') t1 = urllib.request.HTTPSHandler(context=ssl_def_context) t.urlopener = urllib.request.build_opener(t.handler, t1) try: client = Client(wsdl, location=location, plugins=[ImportDoctor(imp)], transport=t) try: sqlStr = "insert into processconfig(paramvalue,paramname,tkservice,tkparam,fkprocessnode) values ('" + newval + "','" + name + "','0','2',(select ProcessNode.pkid from Processnode where ProcessNode.name='" + server + "'))" result = client.service.executeSQLUpdate(sqlStr) logger.info("Successfully inserted " + name + " to '" + newval + "' on " + server) except Exception as e: logger.critical(e) except Exception as e: logger.critical(e)
def selectcmdevice(cucm, username=None, password=None, SelectBy="Name", Class="Any", Status="Any", NodeName="Any"): tns = 'http://schemas.cisco.com/ast/soap/' imp = Import('http://schemas.xmlsoap.org/soap/encoding/', 'http://schemas.xmlsoap.org/soap/encoding/') imp.filter.add(tns) wsdl = "https://%s:8443/realtimeservice/services/RisPort?wsdl" % cucm location = "https://%s:8443/realtimeservice/services/RisPort" % cucm client = Client(wsdl, location=location, username=username, password=password, plugins=[ImportDoctor(imp)]) result = client.service.SelectCmDevice( '', { 'SelectBy': SelectBy, 'Status': Status, 'Class': Class, 'NodeName': NodeName }) return result['SelectCmDeviceResult']['TotalDevicesFound'], result[ 'SelectCmDeviceResult']['CmNodes']
def login(request): if request.method == 'POST': try: user = request.POST['user'].strip() pwd = request.POST['pwd'].strip() except: return HttpResponseBadRequest() from django.contrib.auth import authenticate, login auth = authenticate(username = user , password = pwd) if auth is not None: login(request, auth) return HttpResponse() else: url = 'http://ws.espol.edu.ec/saac/wsandroid.asmx?WSDL' #http://ws.espol.edu.ec/saac/wsandroid.asmx?WSDL imp = Import('http://www.w3.org/2001/XMLSchema') imp.filter.add('http://tempuri.org/') doctor = ImportDoctor(imp) client = Client(url, doctor=doctor) auth = client.service.autenticacion(user,pwd) if auth == True: auth = User.objects.create_user(username=user, password=pwd) auth.save() auth = authenticate(username = user , password = pwd) login(request, auth) return HttpResponse() else: return HttpResponseBadRequest() else: return HttpResponseBadRequest()
def __init__(self, username, password, cucm, cucm_version): """ :param username: ris username :param password: ris password :param cucm: UCM IP address :param cucm_version: UCM version example usage: >>> from ris import RIS >>> ucm = RIS('ris_user', 'ris_pass', '192.168.200.10', '11.5') """ self.username = username self.password = password self.wsdl = 'https://'+cucm+':8443//realtimeservice2/services/RISService70?wsdl' self.cucm = cucm self.cucm_version = cucm_version tns = 'http://schemas.cisco.com/ast/soap/' imp = Import('http://schemas.xmlsoap.org/soap/encoding/', 'http://schemas.xmlsoap.org/soap/encoding/') imp.filter.add(tns) t = HttpAuthenticated(username=self.username, password=self.password) t.handler = urllib.request.HTTPBasicAuthHandler(t.pm) ssl_def_context = ssl.create_default_context() ssl_def_context.check_hostname = False ssl_def_context.verify_mode = ssl.CERT_NONE t1 = urllib.request.HTTPSHandler(context=ssl_def_context) t.urlopener = urllib.request.build_opener(t.handler, t1) self.client = Client(self.wsdl, location='https://{0}:8443/realtimeservice2/services/RISService70'.format(cucm), faults=False, plugins=[ImportDoctor(imp)], transport=t)
def __init__(self, url): #下面的3行为了解决下面的错误 suds.TypeNotFound: Type not found: '(schema, http://www.w3.org/2001/XMLSchema, )' imp = Import('http://www.w3.org/2001/XMLSchema', location='http://www.w3.org/2001/XMLSchema.xsd') imp.filter.add('http://WebXml.com.cn/') doctor = ImportDoctor(imp) self.client = Client(url, doctor=doctor)
def __createWindchillClients(self): """ Initialize windchill PDM Link Webparts and ws soap classes """ if self.windchillWs != None and self.windchillWebparts != None: return # WSDL URLS fullWebpartsUrl = self.windchillUrl + self.WINDCHILL_WEBPARTS_URL fullWsUrl = self.windchillUrl + self.WINDCHILL_WS_URL # Create Client objects imp = Import(self.SOAP_ENCODING_SCHEMA_URL) # Required for suds self.windchillWebparts = Client(fullWebpartsUrl, plugins=[ImportDoctor(imp)], username=self.username, password=self.password) self.windchillWs = Client(fullWsUrl, plugins=[ImportDoctor(imp)], username=self.username, password=self.password)
def adddoctor(self, schema=None, xsd=None, namespace=None): imp = Import(schema, location=xsd) # 指定命名空间 imp.filter.add(namespace) self.doctor = ImportDoctor(imp) self.writer.write(self.writer.row, 7, 'PASS') self.writer.write(self.writer.row, 8, str(self.wsdl))
def getclient(axlver): tns = 'http://schemas.cisco.com/ast/soap/' imp = Import('http://schemas.xmlsoap.org/soap/encoding/', 'http://schemas.xmlsoap.org/soap/encoding/') imp.filter.add(tns) location = 'https://' + ip + ':8443/axl/' # This block checks the path you are in and uses the axlsqltoolkit # under the path of the script location. fileDir = os.path.dirname(os.path.realpath('__file__')) rel_path = 'axlsqltoolkit/schema/' + str(axlver) + '/AXLAPI.wsdl' fullfilepath = os.path.join(fileDir, rel_path) # If it's Windows we need to fix the backslashes to forward slashes. normalizedfilepath = fullfilepath.replace('\\', '/') # Join the file path depending on the system if platform.system() == 'Windows': wsdl = 'file:///' + normalizedfilepath else: wsdl = 'file://' + normalizedfilepath try: client = Client(wsdl, location=location, faults=False, plugins=[ImportDoctor(imp)], username=user, password=pwd) except Exception: print "Error with version or IP address of server. Please try again." sys.exit() return client
def button_testaxl_callback(): info = connectAXL() location = info.get('location') username = info.get('username') password = info.get('password') wsdl = info.get('wsdl') t = HttpAuthenticated(username=username, password=password) t.handler = urllib.request.HTTPBasicAuthHandler(t.pm) ssl_def_context = ssl.create_default_context() ssl_def_context.check_hostname = False ssl_def_context.verify_mode = ssl.CERT_NONE ssl_def_context.set_ciphers('HIGH:!DH:!aNULL') t1 = urllib.request.HTTPSHandler(context=ssl_def_context) t.urlopener = urllib.request.build_opener(t.handler, t1) try: client = Client(wsdl, location=location, plugins=[ImportDoctor(imp)], transport=t) resp = client.service.getCCMVersion() version = resp['return'].componentVersion.version logger.info('Successfully tested to Call Manager : ' + version) except Exception as e: logger.error('Failed to connect to ' + location) logger.critical(e)
def __init__(self, **kwargs): kwargs['_'] = None if hasattr(ssl, '_create_unverified_context'): ssl._create_default_https_context = ssl._create_unverified_context self.server = kwargs.get('server', False) or (input('CUCM address: ')) self.location = 'https://' + self.server + ':8443/axl/' self.username = kwargs.get('username', False) or \ input('AXL Username: '******'password', False) or \ getpass('Password for %s: ' % self.username) self.imp = Import('http://schemas.xmlsoap.org/soap/encoding/', 'http://schemas.xmlsoap.org/soap/encoding/') self.imp.filter.add(TNS) self.readonly = kwargs.get('readonly', True) self.client = Client(WSDL_PATH, location=self.location, faults=False, plugins=[ImportDoctor(self.imp)], username=self.username, password=self.password) # Test Connection try: response = self.client.service.getCCMVersion() validate_axlresp(response) if VER not in str(response[1]['return'].componentVersion.version): logline('WARNING: CUCM version is ' + '%s, this script is using %s AXL schema.' % (response[1]['return'].componentVersion.version, VER)) except Exception as e: logline('%s: %s' % (type(e).__name__, e)) raise
def load_crb_standards(license_num, date): # loads values of standards (aka normativs) which are binding on russian banks # license_num -- int value # date -- string 'yyyy-mm-ddT00:00:00+03:00' # e.g. July, 1 2016 --> '2016-07-01T00:00:00+03:00' # this data is available for the fist days of each month # returns pandas data frame with values of standards for chosen bank & date url = 'http://www.cbr.ru/CreditInfoWebServ/CreditOrgInfo.asmx?WSDL' imp = Import('http://schemas.xmlsoap.org/soap/encoding/') imp.filter.add('http://web.cbr.ru/') imp = Import('http://www.w3.org/2001/XMLSchema', location='http://www.w3.org/2001/XMLSchema.xsd') imp.filter.add('http://web.cbr.ru/') doctor = ImportDoctor(imp) client = Client(url, doctor=doctor) tmp = client.service.Data135FormFull(license_num, date) norms = tmp.diffgram.F135DATA.F135_3 df = pd.DataFrame() for i in range(len(norms)): ind_name = norms[i].C3 try: ind_value = norms[i].V3 except AttributeError: ind_value = None df_tmp = pd.DataFrame({ 'Indicator_name': [ind_name], 'Indicator_value': [ind_value] }) df = df.append(df_tmp, ignore_index=True) return df
def axlSQL(): #get AXL information from GUI info = connectAXL() location = info.get('location') username = info.get('username') password = info.get('password') wsdl = info.get('wsdl') t = HttpAuthenticated(username=username, password=password) t.handler = urllib.request.HTTPBasicAuthHandler(t.pm) ssl_def_context = ssl.create_default_context() ssl_def_context.check_hostname = False ssl_def_context.verify_mode = ssl.CERT_NONE ssl_def_context.set_ciphers('HIGH:!DH:!aNULL') t1 = urllib.request.HTTPSHandler(context=ssl_def_context) t.urlopener = urllib.request.build_opener(t.handler, t1) try: client = Client(wsdl, location=location, plugins=[ImportDoctor(imp)], transport=t) try: result = client.service.executeSQLQuery( "select ProcessNode.name as ProcessNode, ProcessConfig.paramname,ProcessConfig.paramvalue as ProcessConfig from processconfig,processnode where ProcessConfig.fkprocessnode = ProcessNode.pkid" ) car.clearTable() for node in result['return']['row']: car.LoadTable(str(node['processnode']), str(node['paramname']), str(node['processconfig']), '') except Exception as e: logger.critical(e) except Exception as e: logger.critical(e)
def weatherclient(): url = 'http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl' imp = Import('http://www.w3.org/2001/XMLSchema', location='http://www.w3.org/2001/XMLSchema.xsd') imp.filter.add('http://WebXml.com.cn/') client = Client(url, plugins=[ImportDoctor(imp)]) return client
class webs: # add the Import Tag in wsdl imp = Import('http://www.w3.org/2001/XMLSchema', location='http://www.w3.org/2001/XMLSchema.xsd') imp.filter.add("http://WebXml.com.cn/") d = ImportDoctor(imp) # ------------------------------------------------------------ # China weather predict in three days (webservice url) try: web_url = 'http://www.webxml.com.cn/WebServices/WeatherWebService.asmx?wsdl' client = suds.client.Client(web_url, doctor=d) except: print 'url is error' # ---------------------------------------------------------------------------- # set FUNCTION def __init__(self): self.client = client self.method_name = method_name def get_all_methods(self, client): # 查询本webservice所有的方法 return [method for method in client.wsdl.services[0].ports[0].methods] def get_method_args(self, client, method_name): # 查询本webservice所有方法调用的参数 method = client.wsdl.services[0].ports[0].methods[method_name] input_params = method.binding.input return input_params.param_defs(method) interfaces = get_all_methods(self, client) print 'There are interfaces what we got :\n', interfaces print '-------------------------------------------------------------------------------------------' def get_all_method_args(self): # 查询接口所有方法调用的参数 for method_name in interfaces: print get_method_args(client, method_name) cli_ser = client.service # calling interface--------------------------------------------------------------------------------- def ProvinceAre(self): # 查询天气预报支持的所有省份 print cli_ser.getSupportProvince() def CityAre(self): # 查询天气预报支持的国内外的城市 p = raw_input('Please input a ProvinceName in Cinese:\n') byProvinceName = p print cli_ser.getSupportCity(p) def DataSetAre(self): # 查询本天气预报支持的所有数据信息 print cli_ser.getSupportDataSet() def WeatherInfo(self): # 查询未来3天内某城市的天气状况和生活指数 c = raw_input('Please input a CityName in Chinese:\n') theCityName = c # print cli_ser.getWeatherbyCityName(c) output = tuple(cli_ser.getWeatherbyCityName(c)) for i in output: for j, k in enumerate(i[1]): print j, k
def get_client(hostname, wsdl_name, username='******', password='******', cachedir=None, verify=False, timeout=90, port=443): """Returns and instance of suds.client.Client. A separate client is used for each iControl WSDL/Namespace (e.g. "LocalLB.Pool"). This function allows any suds exceptions to propagate up to the caller. @param hostname: The IP address or hostname of the BIGIP. @param wsdl_name: The iControl namespace (e.g. "LocalLB.Pool") @param username: The admin username on the BIGIP. @param password: The admin password on the BIGIP. @param cachedir: The directory to cache wsdls in. None indicates that caching should be disabled. @param verify: When True, performs SSL certificate validation in Python / urllib2 versions that support it (v2.7.9 and newer) @param timeout: The time to wait (in seconds) before timing out the connection to the URL """ url = 'https://%s:%s/iControl/iControlPortal.cgi?WSDL=%s' % ( hostname, port, wsdl_name) imp = Import('http://schemas.xmlsoap.org/soap/encoding/') imp.filter.add('urn:iControl') if cachedir is not None: cachedir = ObjectCache(location=os.path.expanduser(cachedir), days=1) doctor = ImportDoctor(imp) if verify: client = Client(url, doctor=doctor, username=username, password=password, cache=cachedir, timeout=timeout) else: transport = HTTPSTransportNoVerify(username=username, password=password, timeout=timeout) client = Client(url, doctor=doctor, username=username, password=password, cache=cachedir, transport=transport, timeout=timeout) # Without this, subsequent requests will use the actual hostname of the # BIGIP, which is often times invalid. client.set_options(location=url.split('?')[0]) client.factory.separator('_') return client
def adddoctor(self, s=None, x=None, n=None): imp = Import(s, location=x) # 指定命名空间 imp.filter.add(n) self.doctor = ImportDoctor(imp) self.writer.write(self.writer.row, 7, 'PASS') self.writer.write(self.writer.row, 8, '') return True
def web_interfa(url, interface): imp = Import('http://www.w3.org/2001/XMLSchema', location='http://www.w3.org/2001/XMLSchema.xsd') imp.filter.add("http://WebXml.com.cn/") d = ImportDoctor(imp) page1 = Client("%s?wsdl" % url, autoblend=True, doctor=d) resul = page1.service.getAreaDataSet() return resul
def __init__(self, user, password, api_url=None): self.user = user self.password = password self.api_url = api_url if api_url else 'https://ideone.com/api/1/service.wsdl' self._import = Import('http://schemas.xmlsoap.org/soap/encoding/') self._doctor = ImportDoctor(self._import) self.client = Client(self.api_url, doctor=self._doctor) self._language_dict = None
def buildclient(): imp = Import("http://www.w3.org/2001/XMLSchema", location="http://www.w3.org/2001/XMLSchema.xsd") imp.filter.add("http://WebXml.com.cn/") doctor = ImportDoctor(imp) url = "http://ws.webxml.com.cn/WebServices/WeatherWS.asmx?wsdl" client = Client(url, doctor=doctor) return client.service
def axl_request(): phone_list = [] #Disable HTTPS certificate validation check - not recommended for production if hasattr(ssl, '_create_unverified_context'): ssl._create_default_https_context = ssl._create_unverified_context tns = 'http://schemas.cisco.com/ast/soap/' imp = Import('http://schemas.xmlsoap.org/soap/encoding/') imp.filter.add(tns) # adding the ip address provided onto the url link for the API call url = 'https://' + user_env.CUCM_LOCATION + '/axl/' # connecting to CUCM device using axl axl = Client( "file:///Users/jbanegas/Repos/cisco_cucm_AXL_phone_inventory_flask_sample/app/schema/AXLAPI.wsdl", location=url, faults=False, plugins=[ImportDoctor(imp)], username=user_env.CUCM_USER, password=user_env.CUCM_PASSWORD) list_of_devices = [] # axl api call being made and filter name with any devices that start with SEP (all phones) # refer to AXL documentation to see the more phone info you can receive with returnedTags res = axl.service.listPhone({'name': "SEP%"}, returnedTags={ 'name': '', 'description': '', 'model': '', 'networkLocation': '', 'product': '', 'class': '', 'protocol': '', 'protocolSide': '', 'callingSearchSpaceName': '', 'devicePoolName': '', 'commonDeviceConfigName': '', 'commonPhoneConfigName': '', 'networkLocation': '', 'locationName': '' }) # verifying if the response was successful if (res[0] == 200): if res[1]['return']: phones = res[1]['return']['phone'] for phone in list(phones): phone_list.append(phone) else: ("Response Error from AXL API Call") return phone_list
def rev_aff_aw(start_date, end_date, aw_pw): # api_key = '18809dd6e20dffe282ce7616ac94c8ce' imp = Import('http://schemas.xmlsoap.org/soap/encoding/') d = ImportDoctor(imp) url = 'http://api.affiliatewindow.com/v6/AffiliateService?wsdl' client = Client(url, doctor=d) auth = client.factory.create('UserAuthentication') auth.iId = '215843' auth.sPassword = aw_pw auth.sType = 'affiliate' client.set_options(soapheaders=auth) # json = client.service.getTransactionList(dStartDate = start_date.isoformat(), \ dEndDate = end_date.isoformat(), sDateType = 'transaction') # json mapping w = pd.DataFrame() for Transaction in json.getTransactionListReturn[0]: x = [] x = [ Transaction.sStatus[0],\ Transaction.sClickref[0],\ Transaction.iMerchantId[0],\ Transaction.dClickDate[0],\ Transaction.dTransactionDate[0],\ Transaction.mCommissionAmount[0].dAmount[0],\ Transaction.mSaleAmount[0].dAmount[0]] v = pd.DataFrame(data=[x]) w = w.append(v) col = [ 'status',\ 'customID',\ 'merchantID',\ 'clickTime',\ 'date',\ 'commissionValue',\ 'orderValue'] w.columns = col w.insert(0, 'affiliateNetwork', 'affiliateWindow', allow_duplicates=True) # convert string date w = w.reset_index(drop=True) for i in range(len(w['clickTime'])): try: w.loc[i, 'clickTime'] = dateutil.parser.parse( w['clickTime'][i]).strftime('%d/%m/%Y') except: pass try: w.loc[i, 'date'] = dateutil.parser.parse( w['date'][i]).strftime('%d/%m/%Y') except: pass aw = w # add merchant name aw_merchant = pd.read_csv('./data/merchant_name/aw_merchantName.csv', dtype=object) aw = aw.merge(aw_merchant, how='left', left_on='merchantID', right_on='id') aw.drop('id', axis=1, inplace=True) return aw
def connection(self): """establish a connection with MailCertificado""" namespace = 'urn:MailcertificadoWS/types/' imp = Import('http://schemas.xmlsoap.org/soap/encoding/') imp.filter.add(namespace) doctor = ImportDoctor(imp) return Client(self.url, location=self.location, doctor=doctor)
def adddoctor(self, s='', n=''): # 使用suds.client创建一个客户端,用来请求webservice服务器 imp = Import('http://www.w3.org/2001/XMLSchema', location=s) imp.filter.add(n) self.doctor = ImportDoctor(imp) self.writer.write(self.writer.row, self.writer.clo, "PASS") self.writer.write(self.writer.row, self.writer.clo + 1, str(self.doctor))
def __init__(self): imp = Import('http://www.w3.org/2001/XMLSchema', location='http://www.w3.org/2001/XMLSchema.xsd') imp.filter.add('http://schemas.microsoft.com/2003/10/Serialization/') imp.filter.add('http://schemas.microsoft.com/2003/10/Serialization/Arrays') imp.filter.add('http://schemas.datacontract.org/2004/07/LKQIntegrationService.Core.Entities') imp.filter.add('http://schemas.datacontract.org/2004/07/LKQIntegrationService.Core.Ordering.Entities') imp.filter.add('LKQCorp.LKQIntegrationService') doctor = ImportDoctor(imp) self.client = Client('https://lkqintegration.ekeyconnect.com/Ordering.svc?singleWsdl', doctor=doctor)