2
我想从一个asp.net应用程序调用GetListItems。使用SharePoint Web服务进行身份验证
System.Net.NetworkCredential userDefined = new System.Net.NetworkCredential("username","password","domain");
XmlDocument xmlDoc = new System.Xml.XmlDocument();
XmlNode ndQuery = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
XmlNode ndViewFields = xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "");
XmlNode ndQueryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
ndQueryOptions.InnerXml = "";
ndViewFields.InnerXml = "";
WebReference.Lists lists = new WebReference.Lists();
lists.Credentials = userDefined;
XmlNode responseNode = lists.GetListItems("My List Name", null, ndQuery, ndViewFields, null, ndQueryOptions, null);
我得到一个错误:
the request failed with http status 401 unauthorized
我有这么搜查,试了一下,我发现:
WebReference.UseDefaultCredentials = true;
而且
WebReference.Credentials = System.Net.CredentialCache.DefaultCredentials;
而且
<identity impersonate="true" userName="mydomain\username" password="password" />
与我所尝试的一切我得到相同的错误消息。有谁知道我可能会错过什么?