简体   繁体   中英

SharePoint web services GetListItems

I'm making a windows form app to retrieve details about lists items. I made the code and its running without error, but its returning 0 items even though there are items in the list Can anyone tell me what the reason could be?

this is the xml response i get:

<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>

here's the code:

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

UPDATE: * The error was that I gave the domain and username in the same field of the credentials. *

I believe this line is wrong :

query.InnerXml = "<Query><Where><Contains><FieldRef Name='Title'/><Value Type='Text'>lol</Value></Contains></Where></Query>"

The node is "Query" itself, so this will ends with this xml :

<Query><Query>
      <Where><Contains><FieldRef Name='Title'/><Value Type='Text'>lol</Value></Contains></Where>
 </Query></Query>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM