编写Service文件
新建一个php文件命名为EmployeeServicephp首先写上这一句include必要的支持代码
require_once MSAjaxServicephp;
然后定义一个Employee类四个属性一目了然不用多说
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;
}
}
接下来是EmployeeService类继承与MSAjaxServicephp中的MSAjaxService基类其中定义一个方法用来返回一个Employee对象
class EmployeeService extends MSAjaxService
{
function GetEmployee()
{
return new Employee( Dflying Chen );
}
}
然后新建一个EmployeeService的实例并且调用基类的ProcessRequest()方法处理该请求
$theService = new EmployeeService();
$theService>ProcessRequest();
大功告成!