我正在使用 VB.net 设计一个 Windows 窗体应用程序。我试图让应用程序返回特定 SharePoint 列表中的行数。当 II 删除 ndQuery.InnerXml 代码时,一切正常;但是,我想在获得计数之前过滤列表。我要过滤的两列是“Assigned Employee”和“status”。我在 Stack 上查看了许多不同的帖子(SharePoint SoapServerException 调用 GetListItems Web 服务),但我的异常与查询有关。soapserverException 的详细信息是:“一个或多个字段类型未正确安装。转到列表设置页面删除这些字段:0x81020014。”
我尝试转到关系页面,但无法浏览到它:
(url)/Relationships%20List/allitems.aspx
任何人都可以看到查询代码有问题吗?
Imports System
Imports System.IO
Imports System.Net
Imports System.Xml
Imports <xmlns="rs">
Public Class Form1
Dim i As Integer
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim listService As New getListItems.Lists
listService.Credentials = CredentialCache.DefaultCredentials
listService.Url = "http://(servername)/_vti_bin/Lists.asmx"
Dim xmlDoc = New System.Xml.XmlDocument()
Dim ndQuery As XmlNode =
xmlDoc.CreateNode(XmlNodeType.Element, "Query", "")
Dim ndViewFields As XmlNode =
xmlDoc.CreateNode(XmlNodeType.Element, "ViewFields", "")
Dim ndQueryOptions As XmlNode =
xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "")
ndQueryOptions.InnerXml =
"<IncludeMandatoryColumns>FALSE</IncludeMandatoryColumns>"
ndViewFields.InnerXml = "<FieldRef Name='Assigned Employee'/><FieldRef Name='Status'/>"
ndQuery.InnerXml = "<Where><And><Contains><FieldRef Name ='Assigned Employee'/><Value Type='Text'>Engineer</Value></Contains><Contains><FieldRef Name='Status'/><Value Type='Text'>New</Value></Contains></And></Where>"
Try
Dim ndListItems As XmlNode =
listService.GetListItems("Requests", Nothing, ndQuery, _
ndViewFields, Nothing, ndQueryOptions, Nothing)
Dim n1 As XmlNode = ndListItems.Item("rs:data")
Dim a As String = n1.Attributes("ItemCount").InnerText
'Attempted For each loop, but not needed:
'Dim listItemCount As String
'Dim innerXML = New System.Xml.XmlDocument
'innerXML.LoadXml(ndListItems.InnerXml)
'Dim rows As XmlNodeList = innerXML.GetElementsByTagName("rs:data")
'For Each (XmlNode Attribute In rows)
'Next
Label1.Text = a
Catch ex As System.Web.Services.Protocols.SoapException
Label1.Text = ("Message:" + ControlChars.Lf + ex.Message +
ControlChars.Lf +
"Detail:" + ControlChars.Lf + ex.Detail.InnerText +
ControlChars.Lf +
"StackTrace:" + ControlChars.Lf + ex.StackTrace)
End Try
End Sub
End Class