我正在尝试学习SharePoint中CAML查询的基础知识。由于各种非技术原因,我目前仅限于使用VBSCRIPT将我的请求发送到我想查询的网站。我能够连接到网站并检索数据,但目标列表中的 所有 行和 所有 列正在返回所要求的具体数据。关于我做错了什么以及如何解决这个问题的任何想法都将不胜感激。这是代码:
dim soapEnv
dim oHttp
dim URL
set oHttp = CreateObject("Microsoft.XmlHttp")
URL = "https://[MyCorporateSite]/_vti_bin/Lists.asmx?op=GetListItems"
soapEnv = "<?xml version='1.0' encoding='utf-8'?>" _
& "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" _
& "<soap:Body>" _
& "<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" _
& "<listName>{3C786148-E3E1-425B-84BE-6E44335D5645}</listName>" _
& "<Query>" _
& "<Where>" _
& "<Eq>" _
& "<FieldRef Name='ApplicationID' />" _
& "<Value Type='Text'>5Z4PWS</Value>" _
& "</Eq>" _
& "</Where>" _
& "</Query>" _
& "<ViewFields xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" _
& "<FieldRef Name='ApplicationID' />" _
& "<FieldRef Name='ApplicationName' />" _
& "</ViewFields>" _
& "<RowLimit>1</RowLimit>" _
& "</GetListItems>" _
& "</soap:Body>" _
& "</soap:Envelope>"
oHttp.Open "POST", URL, False, [MySiteUID], [MySitePWD]
oHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
oHttp.send soapEnv
WScript.Echo oHttp.responseText
我知道我应该最终将结果分配给XML文档而不是回显返回文本,但是我想在查询演示文稿之前让查询正常工作。
此外,由于公司限制,无法下载CAML创建/格式化工具。
答案 0 :(得分:0)
找到它。这是修改后的代码:
dim soapEnv
dim oHttp
dim URL
set oHttp = CreateObject("Microsoft.XmlHttp")
URL = "https://[MyCorporateSite]/_vti_bin/Lists.asmx?op=GetListItems"
soapEnv = "<?xml version='1.0' encoding='utf-8'?>" _
& "<soap:Envelope xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xsd='http://www.w3.org/2001/XMLSchema' xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>" _
& "<soap:Body>" _
& "<GetListItems xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" _
& "<listName>{3C786148-E3E1-425B-84BE-6E44335D5645}</listName>" _
& "<query>" _
& "<Query>" _
& "<Where>" _
& "<Eq>" _
& "<FieldRef Name='ApplicationID' />" _
& "<Value Type='Text'>5Z4PWS</Value>" _
& "</Eq>" _
& "</Where>" _
& "</Query>" _
& "</query>" _
& "<ViewFields>" _
& "<ViewFields xmlns='http://schemas.microsoft.com/sharepoint/soap/'>" _
& "<FieldRef Name='ApplicationID' />" _
& "<FieldRef Name='ApplicationName' />" _
& "</ViewFields>" _
& "</ViewFields>" _
& "</GetListItems>" _
& "</soap:Body>" _
& "</soap:Envelope>"
oHttp.Open "POST", URL, False, [MySiteUID], [MySitePWD]
oHttp.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
oHttp.send soapEnv
WScript.Echo oHttp.responseText
请注意其他Query和ViewFields标记。