技术开发 频道

ASP.NET 2.0 AJAX中Webservice调用方法

  WEB服务2:WS

using System;
  
using System.Web;

  
using System.Collections;

  
using System.Web.Services;

  
using System.Web.Services.Protocols;

  
using Microsoft.Web.Script.Services;

  
/**////

  
/// WS 的摘要说明

  
///

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

  [WebServiceBinding(ConformsTo
= WsiProfiles.BasicProfile1_1)]

  [ScriptService]

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

  
public WS () {

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

  
//InitializeComponent();

  }

  [WebMethod]

  [ScriptMethod(UseHttpGet
= true)]

        
public string HelloWorld(String query)
  {

  
string inputString = Server.HtmlEncode(query);

  
if (!String.IsNullOrEmpty(inputString))

  {

  
return String.Format("hello, {0}. ", inputString);

  }

  
else

  {

  
return "query string is null or empty";

  }

  }

  }

 

   

0
相关文章