function _SOAP_SentRemoteCommand($SOAPUser, $SOAPPassword, $RealmID, $COMMAND) { $SOAP = new SOAP(array("soap_user" => "" . $SOAPUser . "", "soap_pass" => "" . $SOAPPassword . "", "soap_port" => "" . _SOAPPSwitch($RealmID) . "", "addr" => "" . _SOAPHSwitch($RealmID) . "", "uri" => "" . _SOAPURISwitch($RealmID) . "")); $SOAP->fetch($COMMAND); //echo "<br/>". $SOAP->fetch("". $COMMAND ."") ."<br/>"; unset($SOAP); }
public function getStudentById($id, $term) { // Sanity checking on the Banner ID $id = trim($id); if (!isset($id) || empty($id) || $id == '') { throw new InvalidArgumentException('Missing Banner id. Please enter a valid Banner ID (nine digits).'); } if (strlen($id) > 9 || strlen($id) < 9 || !preg_match("/^[0-9]{9}\$/", $id)) { throw new InvalidArgumentException('That was not a valid Banner ID. Please enter a valid Banner ID (nine digits).'); } $student = new Student(); $soap = SOAP::getInstance(UserStatus::getUsername(), UserStatus::isAdmin() ? SOAP::ADMIN_USER : SOAP::STUDENT_USER); $soapData = $soap->getStudentProfile($id, $term); if ($soapData->error_num == 1101 && $soapData->error_desc == 'LookupStudentID') { PHPWS_Core::initModClass('hms', 'exception/StudentNotFoundException.php'); throw new StudentNotFoundException('No matching student found.'); } elseif (isset($soapData->error_num) && $soapData->error_num > 0) { //test($soapData,1); throw new SOAPException("Error while accessing SOAP interface: {$soapData->error_desc} ({$soapData->error_num})", $soapData->error_num, 'getStudentProfile', array($id, $term)); } SOAPDataProvider::plugSOAPData($student, $soapData); //SOAPDataProvider::applyExceptions($student); require_once PHPWS_SOURCE_DIR . SOAP_DATA_OVERRIDE_PATH; $dataOverride = new SOAPDataOverride(); $dataOverride->applyExceptions($student); $student->setDataSource(get_class($this)); return $student; }
/** * Get an instance of the singleton. * * @param string $username User name of the currently logged in user * @param enum $userType Type of user, as set in defines * @return SOAP - Instance of the SOAP class. */ public static function getInstance($username, $userType) { if (!isset($username) || is_null($username)) { throw new InvalidArgumentException('Missing Username.'); } if (!isset($userType) || is_null($userType)) { throw new InvalidArgumentException('Missing user type.'); } if (empty(self::$instance)) { if (SOAP_INFO_TEST_FLAG) { PHPWS_Core::initModClass('hms', SOAP_OVERRIDE_FILE); self::$instance = new TestSOAP($username, $userType); } else { PHPWS_Core::initModClass('hms', 'PhpSOAP.php'); self::$instance = new PhpSOAP($username, $userType); } } return self::$instance; }
public function execute(CommandContext $context) { if (!Current_User::allow('hms', 'lottery_admin')) { PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); throw new PermissionException('You do not have permission to administer re-application features.'); } PHPWS_Core::initModClass('hms', 'HMS_Eligibility_Waiver.php'); PHPWS_Core::initModClass('hms', 'SOAP.php'); $usernames = explode("\n", $context->get('usernames')); $term = PHPWS_Settings::get('hms', 'lottery_term'); $soap = SOAP::getInstance(UserStatus::getUsername(), UserStatus::isAdmin() ? SOAP::ADMIN_USER : SOAP::STUDENT_USER); $error = false; foreach ($usernames as $user) { $trimmed = trim($user); // Check for blank lines and skip them if ($trimmed == '') { continue; } // Remove everything after '@'. $splode = explode('@', $trimmed); $user = trim($splode[0]); # Username is at [0] if ($user == '') { continue; } if (!$soap->isValidStudent($user, $term)) { NQ::simple('hms', hms\NotificationView::ERROR, "Invalid username: {$user}"); $error = true; } else { $waiver = new HMS_Eligibility_Waiver($user, $term); $result = $waiver->save(); if (!$result) { NQ::simple('hms', hms\NotificationView::ERROR, 'Error creating waiver for: ' . $user); $error = true; } } } if (!$error) { NQ::simple('hms', hms\NotificationView::SUCCESS, 'Waivers created successfully.'); } $cmd = CommandFactory::getCommand('ShowLotteryEligibilityWaiver'); $cmd->redirect(); }
protected function processTransaction(SOAP $sSOAPClient, $szMessageXMLPath, $szGatewayOutputXMLPath, $szTransactionMessageXMLPath, SimpleXMLElement &$sxXmlDocument = null, GatewayOutput &$goGatewayOutput = null, GatewayEntryPointList &$lgepGatewayEntryPoints = null) { $boTransactionSubmitted = false; $nOverallRetryCount = 0; $nOverallGatewayEntryPointCount = 0; $nGatewayEntryPointCount = 0; $nErrorMessageCount = 0; $rgepCurrentGatewayEntryPoint; $nStatusCode; $szMessage = null; $lszErrorMessages; $szString; $sbXMLString; $szXMLFormatString; $nCount = 0; $szEntryPointURL; $nMetric; $nTempValue = 0; $gepGatewayEntryPoint = null; $boAuthorisationAttempted = null; $boTempValue; $szPassOutData = null; //$szPreviousCrossReference = null; $nPreviousStatusCode = null; $szPreviousMessage = null; $ptdPreviousTransactionResult = null; $ResponseDocument = null; $ResponseMethod = null; $lgepGatewayEntryPoints = null; $goGatewayOutput = null; if ($sSOAPClient == null) { return false; } // populate the merchant details if ($this->m_mdMerchantAuthentication != null) { if (!SharedFunctions::isStringNullOrEmpty($this->m_mdMerchantAuthentication->getMerchantID())) { $sSOAPClient->addParamAttribute($szMessageXMLPath . '.MerchantAuthentication', 'MerchantID', $this->m_mdMerchantAuthentication->getMerchantID()); } if (!SharedFunctions::isStringNullOrEmpty($this->m_mdMerchantAuthentication->getPassword())) { $sSOAPClient->addParamAttribute($szMessageXMLPath . '.MerchantAuthentication', 'Password', $this->m_mdMerchantAuthentication->getPassword()); } } // populate the passout data if (!SharedFunctions::isStringNullOrEmpty($this->m_szPassOutData)) { $sSOAPClient->addParam($szMessageXMLPath . '.PassOutData', $this->m_szPassOutData, null); } // first need to sort the gateway entry points into the correct usage order $number = $this->m_lrgepRequestGatewayEntryPoints->sort('GatewayTransaction', 'Compare'); // loop over the overall number of transaction attempts while (!$boTransactionSubmitted && $nOverallRetryCount < $this->m_nRetryAttempts) { $nOverallGatewayEntryPointCount = 0; // loop over the number of gateway entry points in the list while (!$boTransactionSubmitted && $nOverallGatewayEntryPointCount < $this->m_lrgepRequestGatewayEntryPoints->getCount()) { $rgepCurrentGatewayEntryPoint = $this->m_lrgepRequestGatewayEntryPoints->getAt($nOverallGatewayEntryPointCount); // ignore if the metric is "-1" this indicates that the entry point is offline if ($rgepCurrentGatewayEntryPoint->getMetric() >= 0) { $nGatewayEntryPointCount = 0; $sSOAPClient->setURL($rgepCurrentGatewayEntryPoint->getEntryPointURL()); // loop over the number of times to try this specific entry point while (!$boTransactionSubmitted && $nGatewayEntryPointCount < $rgepCurrentGatewayEntryPoint->getRetryAttempts()) { if ($sSOAPClient->sendRequest($ResponseDocument, $ResponseMethod)) { //getting the valid transaction type document format $sxXmlDocument = $ResponseDocument->{$ResponseMethod}; $lszErrorMessages = new StringList(); $nStatusCode = (int) current($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->StatusCode[0]); // a status code of 50 means that this entry point is not to be used if ($nStatusCode != 50) { // the transaction was submitted $boTransactionSubmitted = true; if ($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->Message) { $szMessage = current($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->Message[0]); } if ($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->ErrorMessages) { foreach ($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->ErrorMessages->MessageDetail as $key => $value) { $lszErrorMessages->add(current($value->Detail)); } } if ($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->attributes()) { foreach ($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->attributes() as $key => $value) { $boAuthorisationAttempted = current($value); if (strtolower($boAuthorisationAttempted) == 'false') { $boAuthorisationAttempted = new NullableBool(false); } elseif (strtolower($boAuthorisationAttempted) == 'true') { $boAuthorisationAttempted = new NullableBool(true); } else { throw new Exception('Return value must be true or false'); } } } if ($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->PassOutData) { $szPassOutData = current($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->PassOutData[0]); } else { $szPassOutData = null; } //check to see if there is any previous transaction data if ($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->PreviousTransactionResult->StatusCode) { $nPreviousStatusCode = new NullableInt(current($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->PreviousTransactionResult->StatusCode[0])); } else { $nPreviousStatusCode = null; } if ($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->PreviousTransactionResult->Message) { $szPreviousMessage = current($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->PreviousTransactionResult->Message[0]); } if ($nPreviousStatusCode != null && !SharedFunctions::isStringNullOrEmpty($szPreviousMessage)) { $ptdPreviousTransactionResult = new PreviousTransactionResult($nPreviousStatusCode, $szPreviousMessage); } $goGatewayOutput = new GatewayOutput($nStatusCode, $szMessage, $szPassOutData, $boAuthorisationAttempted, $ptdPreviousTransactionResult, $lszErrorMessages); // look to see if there are any gateway entry points $nCount = 0; //$szXMLFormatString = $ResponseDocument->$ResponseMethod->$szTransactionMessageXMLPath->GatewayEntryPoints->GatewayEntryPoint; $nMetric = -1; if ($ResponseDocument->{$ResponseMethod}->{$szTransactionMessageXMLPath}->GatewayEntryPoints) { if ($ResponseDocument->{$ResponseMethod}->{$szTransactionMessageXMLPath}->GatewayEntryPoints->GatewayEntryPoint) { $szXMLFormatString = $ResponseDocument->{$ResponseMethod}->{$szTransactionMessageXMLPath}->GatewayEntryPoints->GatewayEntryPoint; foreach ($szXMLFormatString->attributes() as $key => $value) { if (is_numeric(current($value))) { $nMetric = current($value); } else { $szEntryPointURL = current($value); } } //$gepGatewayEntryPoint = new GatewayEntryPoint($szEntryPointURL, $nMetric); if ($lgepGatewayEntryPoints == null) { $lgepGatewayEntryPoints = new GatewayEntryPointList(); } $lgepGatewayEntryPoints->add($szEntryPointURL, $nMetric); //$lgepGatewayEntryPoints->add($gepGatewayEntryPoint); } } $nCount++; } } $nGatewayEntryPointCount++; } } $nOverallGatewayEntryPointCount++; } $nOverallRetryCount++; } $this->m_szLastRequest = $sSOAPClient->getSOAPPacket(); $this->m_szLastResponse = $sSOAPClient->getLastResponse(); $this->m_eLastException = $sSOAPClient->getLastException(); return $boTransactionSubmitted; }
/** * @param array $options */ public function __construct(array $options) { $this->soap = SOAP::Client(Service_Yandex_Direct::option('wsdl'), array_merge($options, array('features' => SOAP_SINGLE_ELEMENT_ARRAYS, 'trace' => 1))); if (empty($options['local_cert']) && !empty($options['login']) && !empty($options['token']) && !empty($options['application_id'])) { $headers = array(); $headers[] = new SoapHeader(Service_Yandex_Direct::option('wsdl'), 'login', $options['login']); $headers[] = new SoapHeader(Service_Yandex_Direct::option('wsdl'), 'token', $options['token']); $headers[] = new SoapHeader(Service_Yandex_Direct::option('wsdl'), 'application_id', $options['application_id']); $this->soap->__setSoapHeaders($headers); } }
/** * Processes a queued item. This can be something actually queued, * or an immediate processing because the queue is disabled. */ public function process() { PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'SOAP.php'); $soap = SOAP::getInstance(UserStatus::getUsername(), UserStatus::isAdmin() ? SOAP::ADMIN_USER : SOAP::STUDENT_USER); $result = null; switch ($this->type) { case BANNER_QUEUE_ASSIGNMENT: $result = $soap->reportRoomAssignment($this->asu_username, $this->term, $this->building_code, $this->bed_code, 'HOME', $this->meal_code); if ($result === TRUE) { HMS_Activity_Log::log_activity($this->asu_username, ACTIVITY_ASSIGNMENT_REPORTED, Current_User::getUsername(), $this->term . ' ' . $this->building_code . ' ' . $this->bed_code . ' ' . 'HOME' . ' ' . $this->meal_code); } break; case BANNER_QUEUE_REMOVAL: // Get the Banner ID from the user name // TODO fix this to use BannerID directly $bannerId = $soap->getBannerId($this->asu_username); $result = $soap->removeRoomAssignment($bannerId, $this->term, $this->building_code, $this->bed_code, $this->percent_refund); if ($result === TRUE) { HMS_Activity_Log::log_activity($this->asu_username, ACTIVITY_REMOVAL_REPORTED, Current_User::getUsername(), $this->term . ' ' . $this->building_code . ' ' . $this->bed_code . ' '); } break; } return $result; }
public function clearHousingWaiver($bannerId, $term) { $params = array('User' => $this->currentUser, 'BannerID' => $bannerId, 'TermCode' => $term); try { $response = $this->client->ClearHousingWaiver($params); } catch (SoapFault $e) { throw new SOAPException($e->getMessage(), $e->getCode(), 'clearHousingWaiver', $params); } if ($response->ClearHousingWaiverResult != "0") { throw new BannerException('Error while clearing waiver flag in Banner.', $response->ClearHousingWaiverResult, 'clearHousingWaiver', $params); } SOAP::logSoap('clearHousingWaiver', 'success', $params); return true; }
/** * Does all the checks necessary to assign a student and makes the assignment * * The $room_id and $bed_id fields are optional, but one or the other must be specificed * * @param Student $student * @param Integer $term * @param Integer $room_id * @param Integer $bed_id * @param Integer $meal_plan * @param String $notes * @param boolean $lottery * @param string $reason * @throws InvalidArgumentException * @throws AssignmentException * @throws DatabaseException * @throws Exception */ public static function assignStudent(Student $student, $term, $room_id = NULL, $bed_id = NULL, $meal_plan, $notes = "", $lottery = FALSE, $reason) { /** * Can't check permissions here because there are some student-facing commands that needs to make assignments (e.g. * the lottery/re-application code) * * if(!UserStatus::isAdmin() || !Current_User::allow('hms', 'assignment_maintenance')) { * PHPWS_Core::initModClass('hms', 'exception/PermissionException.php'); * throw new PermissionException('You are not allowed to edit student assignments.'); * } */ PHPWS_Core::initModClass('hms', 'HMS_Residence_Hall.php'); PHPWS_Core::initModClass('hms', 'HMS_Floor.php'); PHPWS_Core::initModClass('hms', 'HMS_Room.php'); PHPWS_Core::initModClass('hms', 'HMS_Bed.php'); PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); PHPWS_Core::initModClass('hms', 'BannerQueue.php'); PHPWS_Core::initModClass('hms', 'AssignmentHistory.php'); PHPWS_Core::initModClass('hms', 'exception/AssignmentException.php'); $username = $student->getUsername(); // Make sure a username was entered if (!isset($username) || $username == '') { throw new InvalidArgumentException('Bad username.'); } $username = strtolower($username); if ($student->getType() == TYPE_WITHDRAWN) { throw new AssignmentException('Invalid student type. Student is withdrawn.'); } if (HMS_Assignment::checkForAssignment($username, $term)) { throw new AssignmentException('The student is already assigned.'); } if (isset($bed_id)) { // A bed_id was given, so create that bed object $vacant_bed = new HMS_Bed($bed_id); if (!$vacant_bed) { throw new AssignmentException('Null bed object.'); } // Get the room that this bed is in $room = $vacant_bed->get_parent(); } else { if (isset($room_id)) { // A room_id was given, so create that room object $room = new HMS_Room($room_id); // And find a vacant bed in that room $beds = $room->getBedsWithVacancies(); $vacant_bed = $beds[0]; } else { // Both the bed and room IDs were null, so return an error throw new AssignmentException('No room nor bed specified.'); } } if (!$room) { throw new AssignmentException('Null room object.'); } // Make sure the room has a vacancy if (!$room->has_vacancy()) { throw new AssignmentException('The room is full.'); } // Make sure the room is not offline if ($room->offline) { throw new AssignmentException('The room is offline'); } // Double check that the bed is in the same term as we're being requested to assign for if ($vacant_bed->getTerm() != $term) { throw new AssignmentException('The bed\'s term and the assignment term do not match.'); } // Double check that the resulting bed is empty if ($vacant_bed->get_number_of_assignees() > 0) { throw new AssignmentException('The bed is not empty.'); } // Issue a warning if the bed was reserved for room change //TODO Move this to the room change view /* if ($vacant_bed->room_change_reserved != 0) { NQ::simple('hms', hms\NotificationView::WARNING, 'Room was reserved for room change'); } */ // Check that the room's gender and the student's gender match $student_gender = $student->getGender(); if (is_null($student_gender)) { throw new AssignmentException('Student gender is null.'); } // Genders must match unless the room is COED if ($room->getGender() != $student_gender && $room->getGender() != COED) { throw new AssignmentException('Room gender does not match the student\'s gender.'); } // We probably shouldn't check permissions inside this method, since sometimes this can be // called from student-facing interfaces.. But, since I want to be really careful with co-ed rooms, // I'm going to take the extra step of making sure no students are putting themselves in co-ed rooms. if ($room->getGender() == COED && !Current_User::allow('hms', 'coed_assignment')) { throw new AssignmentException('You do not have permission to make assignments for Co-ed rooms.'); } // Create the floor object $floor = $room->get_parent(); if (!$floor) { throw new AssignmentException('Null floor object.'); } // Create the hall object $hall = $floor->get_parent(); if (!$hall) { throw new AssignmentException('Null hall object.'); } if ($meal_plan == BANNER_MEAL_NONE) { $meal_plan = NULL; } // Determine which meal plan to use // If this is a freshmen student and they've somehow selected none or low, give them standard if ($student->getType() == TYPE_FRESHMEN && ($meal_plan == BANNER_MEAL_NONE || $meal_plan == BANNER_MEAL_LOW)) { $meal_plan = BANNER_MEAL_STD; // If a student is living in a dorm which requires a meal plan and they've selected none, give them low } else { if ($hall->meal_plan_required == 1 && $meal_plan == BANNER_MEAL_NONE) { $meal_plan = BANNER_MEAL_LOW; } } /** * *************************** * Temporary Assignment HACK * * *************************** */ // Check for an assignment in the temp assignment table $db = new PHPWS_DB('hms_temp_assignment'); $db->addWhere('banner_id', $student->getBannerId()); $result = $db->select(); if (PHPWS_Error::logIfError($result)) { throw new DatabaseException($result->toString()); } if (sizeof($result) > 0) { // Queue an unassign for this student $soap = SOAP::getInstance(UserStatus::getUsername(), UserStatus::isAdmin() ? SOAP::ADMIN_USER : SOAP::STUDENT_USER); try { $soap->removeRoomAssignment($student->getBannerId(), $term, 'TMPR', $result[0]['room_number'], 100); // Hard-code to 100% refund } catch (Exception $e) { throw $e; } $db = new PHPWS_DB('hms_temp_assignment'); $db->addValue('banner_id', null); $db->addWhere('room_number', $result[0]['room_number']); $db->update(); if (PHPWS_Error::logIfError($result)) { throw new DatabaseException($result->toString()); } NQ::simple('hms', hms\NotificationView::WARNING, 'Temporary assignment was removed.'); } // Send this off to the queue for assignment in banner $banner_success = BannerQueue::queueAssignment($student, $term, $hall, $vacant_bed, 'HOME', $meal_plan); if ($banner_success !== TRUE) { throw new AssignmentException('Error while adding the assignment to the Banner queue.'); } // Make the assignment in HMS $assignment = new HMS_Assignment(); $assignment->setBannerId($student->getBannerId()); $assignment->asu_username = $username; $assignment->bed_id = $vacant_bed->id; $assignment->term = $term; $assignment->letter_printed = 0; $assignment->email_sent = 0; $assignment->meal_option = $meal_plan; $assignment->reason = $reason; $assignment->application_term = $student->getApplicationTerm(); $assignment->class = $student->getComputedClass($term); // If this was a lottery assignment, flag it as such if ($lottery) { $assignment->lottery = 1; if (!isset($reason)) { // Automatically tag reason as lottery $assignment->reason = ASSIGN_LOTTERY; } } else { $assignment->lottery = 0; } $result = $assignment->save(); if (!$result || PHPWS_Error::logIfError($result)) { throw new DatabaseException($result->toString()); } // Log the assignment HMS_Activity_Log::log_activity($username, ACTIVITY_ASSIGNED, UserStatus::getUsername(), $term . ' ' . $hall->hall_name . ' ' . $room->room_number . ' ' . $notes); // Insert assignment into History table AssignmentHistory::makeAssignmentHistory($assignment); // Look for roommates and flag their assignments as needing a new letter $room_id = $assignment->get_room_id(); $room = new HMS_Room($room_id); // Go to the room level to get all the roommates $assignees = $room->get_assignees(); // get an array of student objects for those assigned to this room if (sizeof($assignees) > 1) { foreach ($assignees as $roommate) { // Skip this student if ($roommate->getUsername() == $username) { continue; } $roommate_assign = HMS_Assignment::getAssignment($roommate->getUsername(), $term); $roommate_assign->letter_printed = 0; $roommate_assign->email_sent = 0; $roommate_assign->save(); } } // Return Sucess return true; }
protected function processTransactionBase(SOAP $sSOAPClient, $szMessageXMLPath, $szGatewayOutputXMLPath, $szTransactionMessageXMLPath, SimpleXMLElement &$sxXmlDocument = null, GatewayOutput &$goGatewayOutput = null, GatewayEntryPointList &$lgepGatewayEntryPoints = null) { $boTransactionSubmitted = false; $nOverallRetryCount = 0; $nOverallGatewayEntryPointCount = 0; $nGatewayEntryPointCount = 0; $nErrorMessageCount = 0; $rgepCurrentGatewayEntryPoint; $nStatusCode; $szMessage = null; $lszErrorMessages; $szString; $sbXMLString; $szXMLFormatString; $nCount = 0; $szEntryPointURL; $nMetric; $gepGatewayEntryPoint = null; $ResponseDocument = null; $ResponseMethod = null; $lgepGatewayEntryPoints = null; $goGatewayOutput = null; $this->m_szEntryPointUsed = null; if ($sSOAPClient == null) { return false; } // populate the merchant details if ($this->m_maMerchantAuthentication != null) { if (!SharedFunctions::isStringNullOrEmpty($this->m_maMerchantAuthentication->getMerchantID())) { $sSOAPClient->addParamAttribute($szMessageXMLPath . '.MerchantAuthentication', 'MerchantID', $this->m_maMerchantAuthentication->getMerchantID()); } if (!SharedFunctions::isStringNullOrEmpty($this->m_maMerchantAuthentication->getPassword())) { $sSOAPClient->addParamAttribute($szMessageXMLPath . '.MerchantAuthentication', 'Password', $this->m_maMerchantAuthentication->getPassword()); } } // first need to sort the gateway entry points into the correct usage order $number = $this->m_lrgepRequestGatewayEntryPoints->sort('GatewayTransaction', 'Compare'); // loop over the overall number of transaction attempts while (!$boTransactionSubmitted && $nOverallRetryCount < $this->m_nRetryAttempts) { $nOverallGatewayEntryPointCount = 0; // loop over the number of gateway entry points in the list while (!$boTransactionSubmitted && $nOverallGatewayEntryPointCount < $this->m_lrgepRequestGatewayEntryPoints->getCount()) { $rgepCurrentGatewayEntryPoint = $this->m_lrgepRequestGatewayEntryPoints->getAt($nOverallGatewayEntryPointCount); // ignore if the metric is "-1" this indicates that the entry point is offline if ($rgepCurrentGatewayEntryPoint->getMetric() >= 0) { $nGatewayEntryPointCount = 0; $sSOAPClient->setURL($rgepCurrentGatewayEntryPoint->getEntryPointURL()); // loop over the number of times to try this specific entry point while (!$boTransactionSubmitted && $nGatewayEntryPointCount < $rgepCurrentGatewayEntryPoint->getRetryAttempts()) { if ($sSOAPClient->sendRequest($ResponseDocument, $ResponseMethod)) { //getting the valid transaction type document format $sxXmlDocument = $ResponseDocument->{$ResponseMethod}; $lszErrorMessages = new StringList(); $nStatusCode = (int) current($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->StatusCode[0]); // a status code of 50 means that this entry point is not to be used if ($nStatusCode != 50) { $this->m_szEntryPointUsed = $rgepCurrentGatewayEntryPoint->getEntryPointURL(); // the transaction was submitted $boTransactionSubmitted = true; if ($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->Message) { $szMessage = current($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->Message[0]); } if ($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->ErrorMessages) { foreach ($ResponseDocument->{$ResponseMethod}->{$szGatewayOutputXMLPath}->ErrorMessages->MessageDetail as $key => $value) { $lszErrorMessages->add(current($value->Detail)); } } $goGatewayOutput = new GatewayOutput($nStatusCode, $szMessage, $lszErrorMessages); // look to see if there are any gateway entry points $nCount = 0; $nMetric = -1; if ($ResponseDocument->{$ResponseMethod}->{$szTransactionMessageXMLPath}->GatewayEntryPoints) { if ($ResponseDocument->{$ResponseMethod}->{$szTransactionMessageXMLPath}->GatewayEntryPoints->GatewayEntryPoint) { $szXMLFormatString = $ResponseDocument->{$ResponseMethod}->{$szTransactionMessageXMLPath}->GatewayEntryPoints->GatewayEntryPoint; foreach ($szXMLFormatString->attributes() as $key => $value) { if (is_numeric(current($value))) { $nMetric = current($value); } else { $szEntryPointURL = current($value); } } //$gepGatewayEntryPoint = new GatewayEntryPoint($szEntryPointURL, $nMetric); if ($lgepGatewayEntryPoints == null) { $lgepGatewayEntryPoints = new GatewayEntryPointList(); } $lgepGatewayEntryPoints->add($szEntryPointURL, $nMetric); //$lgepGatewayEntryPoints->add($gepGatewayEntryPoint); } } $nCount++; } } else { error_log("send failed" . "\n", 3, SITE_PATH . "plugins/Payment_Sense/paymentSense.log"); } $nGatewayEntryPointCount++; } } $nOverallGatewayEntryPointCount++; } $nOverallRetryCount++; } $this->m_szLastRequest = $sSOAPClient->getSOAPPacket(); $this->m_szLastResponse = $sSOAPClient->getLastResponse(); $this->m_eLastException = $sSOAPClient->getLastException(); return $boTransactionSubmitted; }
function RemoteCommandWithSOAP($SOAPUser, $SOAPPassword, $SOAPPort, $SOAPHost, $URI, $COMMAND) { $SOAP = new SOAP(array("soap_user" => "" . $SOAPUser . "", "soap_pass" => "" . $SOAPPassword . "", "soap_port" => "" . $SOAPPort . "", "addr" => "" . $SOAPHost . "", "uri" => "" . $URI . "")); $SOAP->fetch($COMMAND); //echo "<br>". $SOAP->fetch("". $COMMAND ."") ."<br>"; unset($SOAP); }
public function GetPortugalGoalkeepersName() { $this->client['soccer'] = new \SoapClient(self::$URL_SOCCER); print_r($this->client['soccer']->AllGoalKeepers(array('sCountryName' => 'Portugal'))); } public function GetAllCountries() { $this->client['countries'] = new \SoapClient(self::$URL_COUNTRIES); $result = $this->client['countries']->getIANAInfo(); foreach ($result as $key => $value) { $this->countries[$value[0]] = $value[1]; } } public function GetCountryInfo($ianaCode = null) { if (!is_array($this->client['countries'])) { $this->GetAllCountries(); } if (!is_null($ianaCode) && array_key_exists($ianaCode, $this->countries)) { return $this->client['countries']->countryInfoByIana($ianaCode); } else { print_r("This '" . $ianaCode . "' is not a valid ianacode.\n"); } } } $client = new SOAP(); $client->GetPortugalGoalkeepersName(); $client->GetAllCountries(); print_r($client->GetCountryInfo('pt')); print_r($client->GetCountryInfo('en')); print_r($client->GetCountryInfo('uk'));
<?php $config['no_session'] = true; //force session "last active" update to be skipped require_once 'config.php'; require_once 'class.SOAP.php'; $serv = new SOAP('process', xhtmlGetUrl('soap_server.php')); $serv->message('fetchAndConvert', array('username' => 'string', 'password' => 'string', 'uri' => 'string', 'callback' => 'string', 'watermark' => 'string', 'response' => 'integer')); $serv->output();
/** * Reports 'this' application to Banner */ public function reportToBanner() { PHPWS_Core::initModClass('hms', 'SOAP.php'); try { $soap = SOAP::getInstance(UserStatus::getUsername(), UserStatus::isAdmin() ? SOAP::ADMIN_USER : SOAP::STUDENT_USER); $soap->createHousingApp($this->getBannerId(), $this->getTerm()); } catch (Exception $e) { // Send an email notification PHPWS_Core::initCoreClass('Mail.php'); $send_to = array(); $send_to[] = '*****@*****.**'; $mail = new PHPWS_Mail(); $mail->addSendTo($send_to); $mail->setFrom(FROM_ADDRESS); $mail->setSubject('HMS Application Error!'); $body = "Username: {$this->getUsername()}\n"; $mail->setMessageBody($body); $mail->send(); throw $e; // rethrow the exception it } // Log the fact that the application was sent to banner PHPWS_Core::initModClass('hms', 'HMS_Activity_Log.php'); HMS_Activity_Log::log_activity($this->getUsername(), ACTIVITY_APPLICATION_REPORTED, UserStatus::getUsername()); }