我正在创建一个Windows窗体应用程序来检索有关列表项的详细信息。 我使代码及其运行没有错误,但即使列表中有项目,它返回0项 谁能告诉我原因是什么?
这是我得到的xml响应:
<listitems xmlns:s="uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882" xmlns:dt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882" xmlns:rs="urn:schemas-microsoft-com:rowset" xmlns:z="#RowsetSchema" xmlns="http://schemas.microsoft.com/sharepoint/soap/">
<rs:data ItemCount="0">
</rs:data>
</listitems>
这是代码:
Dim listService As New Lists()
listService.Credentials = System.Net.CredentialCache.DefaultCredentials
listService.Url = "http://sitename/_vti_bin/lists.asmx"
Dim xmlDoc As New System.Xml.XmlDocument()
Dim listName As String = "{83FEDC7E-1DDA-4A36-910A-D5140E51F0ED}"
Dim viewName As String = "{77A23176-5CD4-46E9-BE57-AEB4D4279AD4}"
Dim rowLimit As String = "150"
Dim query As System.Xml.XmlNode = xmlDoc.CreateElement("Query")
Dim viewFields As System.Xml.XmlNode = xmlDoc.CreateElement("ViewFields")
Dim queryOptions As System.Xml.XmlNode = xmlDoc.CreateElement("QueryOptions")
query.InnerXml = "<Query><Where><Contains><FieldRef Name='Title'/><Value Type='Text'>lol</Value></Contains></Where></Query>"
viewFields.InnerXml = ""
queryOptions.InnerXml = "<ViewAttributes Scope='Recursive' />"
Dim nodeListItems As XmlNode
nodeListItems = listService.GetListItems(listName, viewName, query, viewFields, rowLimit, queryOptions, Nothing)
TextBox1.Text += nodeListItems.OuterXml
更新 * 错误是我在凭据的相同字段中提供了域名和用户名。 *
答案 0 :(得分:1)
我认为这一行是错误的:
query.InnerXml = "<Query><Where><Contains><FieldRef Name='Title'/><Value Type='Text'>lol</Value></Contains></Where></Query>"
节点本身就是“查询”,因此这将以此xml:
结束<Query><Query>
<Where><Contains><FieldRef Name='Title'/><Value Type='Text'>lol</Value></Contains></Where>
</Query></Query>