技术开发 频道

ASP.NET 2.0 AJAX中Webservice调用方法

  WEB服务1:WS1

using System;
  
using System.Web;

  
using System.Collections;

  
using System.Web.Services;

  
using System.Web.Services.Protocols;

  
using Microsoft.Web.Script.Services;

  
using System.Data;

  
/**////

  
/// WS1 的摘要说明

  
///

  [WebService(Namespace
= "http://tempuri.org/")]

  [WebServiceBinding(ConformsTo
= WsiProfiles.BasicProfile1_1)]

  [ScriptService]

  
public class WS1 : System.Web.Services.WebService {

  
public WS1 () {

  
//如果使用设计的组件,请取消注释以下行

  
//InitializeComponent();

  }

  [WebMethod]

  

      
public string ServerTime()
  {

  
return String.Format("now: {0}", DateTime.Now);

  }

  [WebMethod]

  
public DataTable GetDataTable()

  {

  DataTable dt
= new DataTable("Person");

  dt.Columns.Add(
new DataColumn("Name", typeof(string)));

  dt.Columns.Add(
new DataColumn("LastName", typeof(string)));

  dt.Columns.Add(
new DataColumn("Email", typeof(string)));

  dt.Rows.Add(
"kui", "he", "hekui168@163.com");

  dt.Rows.Add(
"ren", "chao", "chaoren888@163.com");

  
return dt;

  }

  }

 

  

0
相关文章