易百教程

41、编写一个示例来演示 Web Services提供者的工作方式。

以下是 Web Services提供者的示例:

using System;  
using System.Web.Services;  
using System.Xml.Serialization;  

[WebService(Namespace="http://localhost/MyWebServices/")]  
public class FirstService : WebService{  
   [WebMethod]  
   public int Add(int a, int b) {  
      return a + b;  
   }  

   [WebMethod]  
   public String SayHello() {  
      return "Hello World";  
   }  
}