这个问题可能比较少的人碰到, 因为大多数MOSS项目都是基于Windows认证的, 如果是Form认证的话,那么调用moss 的web service将出现
“http status 403 Forbidden errors"的错误。
解决方法:
1. Add Web Reference:
http://localhost/_vti_bin/Lists.asmx (命名SPWebLists)
http://localhost/_vti_bin/Authentication.asmx (命名SPWebAuthentication)
引用下面代码放在需要访问Web service的页面中


public void LoginAuthentication()
{
var userName = "mossAdmin";
var password = "123456";
var listService = new SPWebLists.Lists();
var authService = new SPWebAuthentication.Authentication();
try
{
if (ConfigurationSettings.AppSettings["SPWebUserName"] != null)
userName = ConfigurationSettings.AppSettings["SPWebUserName"].ToString();
if (ConfigurationSettings.AppSettings["SPWebPassword"] != null)
password = ConfigurationSettings.AppSettings["SPWebPassword"].ToString();
if (ConfigurationSettings.AppSettings["SPWebListUrl"] != null)
listService.Url = ConfigurationSettings.AppSettings["SPWebListUrl"].ToString();
if (ConfigurationSettings.AppSettings["SPWebAuthUrl"] != null)
authService.Url = ConfigurationSettings.AppSettings["SPWebAuthUrl"].ToString();
// LoginAuthentication(user, password);
authService.CookieContainer = new CookieContainer();
authService.AllowAutoRedirect = true;
SPWebAuthentication.LoginResult loginResult = authService.Login(user, password);
if (loginResult.ErrorCode == SPWebAuthentication.LoginErrorCode.NoError)
{
listService.CookieContainer = authService.CookieContainer;
}
}
catch { }
}