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" />
與我所嘗試的一切我得到相同的錯誤消息。有誰知道我可能會錯過什麼?