在PHP中使用ASP.NET AJAX - .net语言 -

在PHP中使用ASP.NET AJAX

时间:2013-08-13 12:45:44   来源:   评论:加载中...   点击:加载中...
编写Service文件   新建一个php文件,命名为EmployeeService.php。首先写上这一句,include必要的支持代码: 以下为引用的内容:require_once 'MSAjaxServic...

编写Service文件


  新建一个php文件,命名为EmployeeService.php。首先写上这一句,include必要的支持代码:

以下为引用的内容:
require_once 'MSAjaxService.php';

 

然后定义一个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类,继承与MSAjaxService.php中的MSAjaxService基类。其中定义一个方法,用来返回一个Employee对象:

以下为引用的内容:
class EmployeeService extends MSAjaxService
{
function GetEmployee()
{
return new Employee(12345, "Dflying Chen", "Dflying@some.com", 1000);
}
}

 

然后新建一个EmployeeService的实例,并且调用基类的ProcessRequest()方法,处理该请求:

以下为引用的内容:
$theService = new EmployeeService();
$theService->ProcessRequest();

 

大功告成!

请作者联系本站,及时附注您的姓名。联系邮箱:edu#chinaz.com(把#改为@)。



相关热词搜索:

 
上一篇:解析.Net框架下的XML编程技术
下一篇:.Net中消除Dll中的dependency
收藏 将此文推荐给朋友
分享到: