# Set namespaces soapBody._setAttr("xmlns:ns2", "http://4psa.com/UserMessages.xsd/" + version) # Set endpoint endpoint = "https://" + str(sys.argv[1]) + "/soap2/user_agent.php" # Set soapaction soapaction = "http://4psa.com/User/" + version + ":getUsersIn" # Set service connection server = SOAPProxy(endpoint, noroot = 1, soapaction = soapaction, header = soapHeader) #run our soap request try: users = server._callWithBody(soapBody) except SOAPpy.Types.faultType, error: # Catch exception, for situations when the users could not be fetched print "Error " + error[0] + ": " + error[1] sys.exit(1) # Get the id of a random user userID = None if len(users) != 0: randUser = users[random.randint(0, len(users) - 1)] if hasattr(randUser, 'ID'): userID = randUser.ID if hasattr(randUser, 'name'): print "Using parent user " + randUser.name + "." else: print "Using parent user with id " + userID + "."
# Set namespaces soapBody._setAttr("xmlns:ns2", "http://4psa.com/OrganizationMessages.xsd/" + version) # Set endpoint endpoint = "https://" + str(sys.argv[1]) + "/soap2/organization_agent.php" # Set soapaction soapaction = "http://4psa.com/Organization/" + version +":getOrganizationsIn" # Set service connection server = SOAPProxy(endpoint, noroot = 1, soapaction = soapaction, header = soapHeader) #run our soap request try: organizations = server._callWithBody(soapBody) except SOAPpy.Types.faultType, error: # Catch exception, for situations when the organizations could not be fetched print "Error " + error[0] + ": " + error[1] sys.exit(1) # Get the id of a random organization organizationID = None if len(organizations) != 0: randOrganization = organizations[random.randint(0, len(organizations) - 1)] if hasattr(randOrganization, 'ID'): organizationID = randOrganization.ID if hasattr(randOrganization, 'name'): print "Using parent organization " + randOrganization.name + "." else: print "Using parent organization with id " + organizationID + "."
# Set namespaces soapBody._setAttr("xmlns:ns2", "http://4psa.com/BillingMessages.xsd/" + version) # Set endpoint endpoint = "https://" + str(sys.argv[1]) + "/soap2/billing_agent.php" # Set soapaction soapaction = "http://4psa.com/Billing/" + version + ":getChargingPlansIn" # Set service connection server = SOAPProxy(endpoint, noroot = 1, soapaction = soapaction, header = soapHeader) #run our soap request try: chargingPlans = server._callWithBody(soapBody) except SOAPpy.Types.faultType, error: # Catch exception, for situations when the charging plans could not be fetched print "Error " + error[0] + ": " + error[1] sys.exit(1) # Get the id of a random charging plan chargingPlanID = None if len(chargingPlans) != 0: randChargingPlan = chargingPlans[random.randint(0, len(chargingPlans) - 1)] if hasattr(randChargingPlan, 'ID'): chargingPlanID = randChargingPlan.ID if hasattr(randChargingPlan, 'name'): print "Using charging plan " + randChargingPlan.name + "." else: print "Using charging plan with id " + chargingPlanID + "."
# Set namespaces soapBody._setAttr("xmlns:ns2", "http://4psa.com/ExtensionMessages.xsd/" + version) # Set endpoint endpoint = "https://" + str(sys.argv[1]) + "/soap2/extension_agent.php" # Set soapaction soapaction = "http://4psa.com/User/" + version + ":getExtensionsIn" # Set service connection server = SOAPProxy(endpoint, noroot = 1, soapaction = soapaction, header = soapHeader) #run our soap request try: extensions = server._callWithBody(soapBody) except SOAPpy.Types.faultType, error: # Catch exception, for situations when the extensions could not be fetched print "Error " + error[0] + ": " + error[1] sys.exit(1) # Get the identifier of a random extension extensionIdentifier = None if len(extensions) != 0: randExtension = extensions[random.randint(0, len(extensions) - 1)] if hasattr(randExtension, 'identifier'): extensionIdentifier = randExtension.identifier if hasattr(randExtension, 'name'): print "Fetching call costs for extension " + randExtension.name + "." else: print "Fetching call costs for extension with identifier " + extensionIdentifier + "."