Code Samples - UpdateStudentInfo
|
Prerequisite: The Authentication Web service must be installed. For more information, see Security and Authentication. |
UpdateStudentInfoRequest
This method is responsible for creating the request.
Precondition
User must reference a valid Web service “StudentWebService”.
Postcondition – Success
A request object is created successfully.
Code Example
// Initialize Request and get token
Student.UpdateStudentInfoRequest request = new Student.UpdateStudentInfoRequest();
request.TokenId = _tokenId;
UpdateStudentInMsg
This method instantiates a new message to update a Student.
Precondition
User must reference a valid Web service “StudentWebService”.
Postcondition – Success
UpdateStudentInMsg created successfully.
Code Example
// Create a new UpdateStudentInMsg
Student.UpdateStudentInMsg inMsg = new Student.UpdateStudentInMsg();
inMsg.CorrelationId = _correlationId;
inMsg.StudentId = int.Parse(txtStudentId.Text); //Student Id entered in test field
// Send updated Student data
inMsg.Address = “My Address”;
//inMsg.<Pass ALL other parameters>…
// Bind UpdateStudentInMsg to the request
request.Students = new Student.UpdateStudentInMsg[1];
request.Students[0] = inMsg;
SSN Validation
The Social Security Number (SSN) is validated for the input message of the API request using a regular expression at runtime based on the prerequisite that the SyCountry.SSNMask is in a string containing ‘#’ and ‘–‘ characters. If there is no SSNMask for the student Country or student Country is not populated on SyStudent, then the API expects the SSN to be in USA format, that is, ###-##-####.
Pseudo Code:
If (Student.SyCounty is NULL OR Student.Sycountry.SSNMask is NULL / Blank)
{
Validate input.SSN against USA format i.e., ###-##-#####.
}
Else // compare input SSN and SyCountry.SSNMask
{
If (input.SSN.Length not equals to SyCountry.SSNMask.Length)
Throw validation with expected format.
If(Input.SSN.Contains(‘-‘) && SyCountry.SSNMask.Contains(‘-’) is false ) //and vice versa
Throw validation for improper format.
}
Else
Pass the validation.
For more information, see Error Types.
UpdateStudentInfoResponse
The update Student functionality retrieves student allows student data to be modified using the Campus API. The service will process the request and return the response message with the new student information.
Preconditions
- The request provided is valid.
- The Admissions Web service is configured correctly.
- Database connection strings are valid.
- Service consumer authenticates and is authorized to use the service.
- User must reference a valid Web service “StudentWebService”.
Postcondition – Success
If the service is able to parse the parameters and execute the request successfully, the service will return a student record.
Postconditions – Failure
There are several possible causes for failure:
-
Invalid Parameters: If the parameters specified do not match reference values in the current database, the service will return an error in the response message stating the invalid field name.
-
Missing Parameters: If the required parameters are missing, the service will return an error in the transaction result for the message stating the missing field name.
-
Invalid Service Configuration: If there is an invalid configuration for the Web service, the client will receive a generic internal exception message.
Code Example
//Send the request through the Web service and get response
Student.UpdateStudentInfoResponse response = service.UpdateStudentInfo(request);
Custom Validation for Postal Codes
In Anthology Student 17.1 and later, the logic that validates postal codes is changed as follows:
-
The validation code is removed from the soa.businessprocess.master.config file located in the following path: \campuslink\cmc.campuslink.soa\common\configuration\cmc.campuslink.soa.businessprocess.master.config
<!--<field name="PostalCode" type="System.String" operator="ZIP" />--> -
The PostalCode format is added in the <appSettings> section of the web.config file located in the following path: \campuslink\webservices\cmc.campuslink.webservices\web.config.
To validate the postal codes associated with a student/lead, the database entry of SyCountry.Code of the supplied Country Code or ID is compared to the value after <add key="CountryCode_".
Users need to edit the web.config file to provide their Country Code after the "_" (underscore) in the key and their desired format for the API to perform the validations.
-
If the Country Code = "CAN" and the entry "<add key="CountryCode_CAN">, the postal code is validated as a Canadian Code [e.g., A2H 4Z5] OR any other Country Code value to its supplied format (see below for examples).
-
If no Country Code is supplied, all postal codes are validated as "US" or "USA", meaning the #####-#### format.
The SkipSemanticValidation flag in the in-message is still used and is set to "False" by default.
-
If SkipSemanticValidation is set "True", postal code validations are ignored.
-
If SkipSemanticValidations is "False", all postal codes are validated against the provided SyCountryID or SyCountryCode.
-
If no Country Code or ID is provided, the default USA format is used, validating the #####-#### or ##### format value.
Users can add entries into the web.config that will allow them to validate postal codes of any other countries that they do business with and in.
Legend:
* =letter# =number? =letter or number
Example entries to the web.config are:
<add key="CountryCode_USA" value="#####-####, #####" /> // 33411-1234, 33431
<add key="CountryCode_CANADA" value="*#* #*#" /> // A2H 4Z5
<add key="CountryCode_KEN" value="# ####" /> // 8 1234
<add key="CountryCode_ZIM" value="*?####" /> //A21212 or AB1134
<add key="CountryCode_IN" value="######" /> //457891
<add key="CountryCode_UGL" value="*** ###, ##**??" /> //ABC 123, 55AB1B
For more information, see https://en.wikipedia.org/wiki/List_of_postal_codes
After editing and saving the web.config file, be sure to reset IIS.