【IT168技术文档】
MOSS中已经提供的webservice都放在虚拟目录_vti_bin中,对应的物理目录为c:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI。可能你会觉得这个目录_vti_bin名有点怪,这个名字来自该公司Vermeer Technologies Incorporated。这个公司唯一的产品就是FrontPage,该公司在1996年被微软收购。
下面我们就自己实现一个webservice,需要以下几步:
一:建立Webservice项目
1.使用vs2005建立一个webserivce项目来实现我们的webservice,然后我在填加一个类库用于实现webservice的逻辑部分。项目结构如下图:

为MOSSLibrary2类库签名,项目“右键---属性---签名---为程序集签名",不使用密码。Service.cs是现实Webservice逻辑的地方,代码如下:
using System; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; using Microsoft.SharePoint; using Microsoft.SharePoint.Utilities; [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class Service : System.Web.Services.WebService { public Service () { } [WebMethod] public string HelloWorld() { return "Hello World"; } [WebMethod] public string GetSiteListCount() { SPWeb myWeb=SPContext.Current.Web; SPListCollection lists=myWeb.Lists; return (myWeb.Title + " contains " + lists.Count.ToString() + " Web sites."); } }