def get_tracking_client(): path = os.path.join(os.path.dirname(os.path.abspath(__file__))) wsdl_file = 'Tracking_API_V1.2.wsdl' client = getClient('file://' + path + '/schemas/' + wsdl_file, key, cert) #Calc Variables tt = datetime.now() create_date = time.strftime('%Y-%m-%dT%H:%M:%SZ', tt.timetuple()) trans_id = str(random.randint(0, 9999999999)) #Set vals integrationHeader #work_app_id #sandbox_app_id indetification = { 'applicationId': work_app_id, 'transactionId': trans_id, } header = { 'dateTime': create_date, 'version': '1.0', 'identification': indetification, } return client, header
def get_my_client(sandbox=True): # WARNING -don't forget path wsse file !!!! #print path #print os.getcwd() #Variables user_name = '*****@*****.**' password = '******' #Init client if sandbox: wsdl_file = 'sandbox_ShippingAPI_V2_0_8.wsdl' application_id = sandbox_app_id else: wsdl_file = 'ShippingAPI_V2_0_8.wsdl' application_id = work_app_id client = getClient('file://' + path + '/schemas/' + wsdl_file, key, cert) #Calc Variables tt = datetime.now() create_date = time.strftime('%Y-%m-%dT%H:%M:%SZ', tt.timetuple()) nonce = str(random.randint(0, 9999999999)) hashedpassword = sha.new(password).digest() digest = sha.new(nonce + create_date + hashedpassword).digest() pass_digi = base64.b64encode(digest) code_nonce = base64.b64encode(nonce) trans_id = str(random.randint(0, 9999999999)) #Print debug info #print 'Nonce = ', nonce #print 'pass_digi= ', pass_digi #print 'code_nonce= ', code_nonce #print 'create_date= ', create_date #print 'trans id= ', trans_id #Set Security Header security = Security() token = UsernameToken(user_name, pass_digi) token.setnonce(code_nonce) token.setcreated(create_date) security.tokens.append(token) client.set_options(wsse=security) #Set vals integrationHeader indetification = { 'applicationId': application_id, 'transactionId': trans_id, } header = { 'dateTime': create_date, 'version': '2', 'identification': indetification, } return client, header
def get_my_client(sandbox=True): # WARNING -don't forget path wsse file !!!! #print path #print os.getcwd() #Variables user_name='*****@*****.**' password = '******' #Init client if sandbox: wsdl_file='sandbox_ShippingAPI_V2_0_8.wsdl' application_id=sandbox_app_id else: wsdl_file='ShippingAPI_V2_0_8.wsdl' application_id=work_app_id client= getClient('file://'+path+'/schemas/'+wsdl_file, key, cert) #Calc Variables tt=datetime.now() create_date = time.strftime('%Y-%m-%dT%H:%M:%SZ', tt.timetuple()) nonce = str(random.randint(0,9999999999)) hashedpassword = sha.new(password).digest() digest = sha.new(nonce + create_date + hashedpassword).digest() pass_digi = base64.b64encode(digest) code_nonce = base64.b64encode(nonce) trans_id= str(random.randint(0,9999999999)) #Print debug info #print 'Nonce = ', nonce #print 'pass_digi= ', pass_digi #print 'code_nonce= ', code_nonce #print 'create_date= ', create_date #print 'trans id= ', trans_id #Set Security Header security = Security() token = UsernameToken(user_name, pass_digi) token.setnonce(code_nonce) token.setcreated(create_date) security.tokens.append(token) client.set_options(wsse=security) #Set vals integrationHeader indetification={ 'applicationId': application_id, 'transactionId':trans_id, } header={ 'dateTime': create_date, 'version': '2', 'identification':indetification, } return client, header
def get_tracking_client(): path = os.path.join(os.path.dirname(os.path.abspath(__file__))) wsdl_file='Tracking_API_V1.2.wsdl' client= getClient('file://'+path+'/schemas/'+wsdl_file, key, cert) #Calc Variables tt=datetime.now() create_date = time.strftime('%Y-%m-%dT%H:%M:%SZ', tt.timetuple()) trans_id= str(random.randint(0,9999999999)) #Set vals integrationHeader #work_app_id #sandbox_app_id indetification={'applicationId': work_app_id, 'transactionId':trans_id, } header={ 'dateTime': create_date, 'version': '1.0', 'identification':indetification, } return client, header
import sha import binascii import base64 import time import random user_name='*****@*****.**' password = '******' key=os.getcwd()+'/certs/mykey.pem' cert=os.getcwd()+'/certs/mycert.pem' application_id='0127229000' client= getClient('file://'+os.getcwd()+'/schemas/ShippingAPI_V2_0_8.wsdl', key, cert) tt=datetime.now() create_date = time.strftime('%Y-%m-%dT%H:%M:%S', tt.timetuple()) create_date2 = time.strftime('%Y-%m-%dT%H:%M:%SZ', tt.timetuple()) #or #create_date = str(DateTime(tt)) nonce = str(random.randint(0,9999999999)) hashedpassword = sha.new(password).digest() digest = sha.new(nonce + create_date2 + hashedpassword).digest() pass_digi = base64.b64encode(digest) code_nonce = base64.b64encode(nonce) trans_id= str(random.randint(0,9999999999))