SoapServerException when calling GetListItems

戏子无情 提交于 2019-12-23 05:44:33

问题


I am trying to call GetListItems in a specific calendar in sharepoint site. However everytime I try to call GetListItems I get an error saying:

Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException'

My calendar is in a sharepoint site whose URL is:

https://myteam.company.com/sites/TeamSite/Lists/Calendar

My url for my lists service is:

https://myteam.company.com/sites/TeamSite//_vti_bin/Lists.asmx

And I call getlistitems as follows:

appSettings = ConfigurationManager.AppSettings;
credentials = new NetworkCredential(appSettings["Username"], appSettings["Password"]);
var doclist = new Lists() { Credentials = credentials, CookieContainer = new CookieContainer() };
var xmlDoc = new XmlDocument();
XmlElement query = xmlDoc.CreateElement("Query");
XmlElement viewFields = xmlDoc.CreateElement("ViewFields");
XmlElement queryOptions = xmlDoc.CreateElement("QueryOptions");
queryOptions.InnerXml = "<ViewAttributes Scope='Recursive'/>";
XmlNode doc = doclist.GetListItems("Lists", string.Empty, query, viewFields, "0", queryOptions, null);

I always get an error when calling the getlistitems method. Is there anything wrong with my code? Thanks.


回答1:


ah now i know what's wrong ;-) you aren't targeting the calendar! since the calendar exists under

https://myteam.company.com/sites/TeamSite/Lists/Calendar

you need to call the GetListItems method as followed:

XmlNode doc = doclist.GetListItems("Calendar", string.Empty, query, viewFields, "0", queryOptions, null);


来源:https://stackoverflow.com/questions/7852907/soapserverexception-when-calling-getlistitems

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!