Write a Service file and create a php file named EmployeeService. php. First, write this sentence and include the necessary support code: require_onceMSAjaxService.php; then define an Employee class. Four attributes are clear at a glance. Needless to say: classEmploye Ajax
Write Service files
Create a php file named EmployeeService. php. First, write this sentence and include the necessary support code:
Require_once 'msajaxservice. php ';
Then define an Employee class. The four attributes are clear at a glance. Needless to say:
Class Employee
{
Public $ Id;
Public $ Name;
Public $ Email;
Public $ Salary;
Function _ construct ($ id, $ name, $ email, $ salary)
{
$ This-> Id = $ id;
$ This-> Name = $ name;
$ This-> Email = $ email;
$ This-> Salary = $ salary;
}
}
Next, the EmployeeService class inherits from the MSAjaxService base class in MSAjaxService. php. Define a method to return an Employee object:
Class EmployeeService extends MSAjaxService
{
Function GetEmployee ()
{
Return new Employee (12345, "Dflying Chen", "Dflying@some.com", 1000 );
}
}
Create an EmployeeService instance and call the ProcessRequest () method of the base class to process the request:
$ TheService = new EmployeeService ();
$ TheService-> ProcessRequest ();
Success!