Sharepoint Webservice 401错误 [英] Sharepoint Webservice 401 error
问题描述
我正在尝试在C#控制台应用程序中调用sharepoint Web服务.当我将本地系统的WSS用作目标应用程序,但不能与其他可通过Web访问的服务器一起使用时,代码可以正常工作.以下是我的代码.
I'm trying to call sharepoint webservices in C# console application. The code works fine when I use my local system's WSS as target application but don't work with another server accessible over the web. Following is my code.
Webs service = new Webs();
service.PreAuthenticate = true;
service.Credentials = new System.Net.NetworkCredential(login, password);
//service.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;
service.Url = url + @"/_vti_bin/webs.asmx";
XmlNode sites = null;
try
{
sites = service.GetWebCollection();
}
catch (Exception ex)
{
return;
}
注意事项: 1.它既不能与DefaultNetworkCredentials一起使用,也不能与我的域用户凭据一起使用. 2.如果将Web服务端点粘贴到浏览器中,则会成功列出Web服务方法. 3.在所有情况下(访问远程服务器),我都会收到401未经授权的错误.
Points to note: 1. It neither work with DefaultNetworkCredentials nor with my domain user credentials. 2. The webservice end point if pasted in a browser successfully list the web service methods. 3. I get 401 unauthorized error in all cases(accessing the remote server).
我想念什么吗?
推荐答案
使用Fiddler之类的工具捕获控制台应用程序和SharePoint之间的http通信.这将有助于调试问题所在.
Use a tool like Fiddler to capture the http traffic between console app and SharePoint. That will help debug what your problem is.
这篇关于Sharepoint Webservice 401错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!