使用 SOAP 检索共享点列表

Retrieving sharepoint lists using SOAP

我正在尝试使用 VBA 和 SOAP 从共享点列表中提取特定数据点。但是,我对 VBA 和 sharepoint 都很陌生,所以有些事情对我来说没有意义。目前,我正在尝试使用此站点作为参考:

http://depressedpress.com/2014/04/05/accessing-sharepoint-lists-with-visual-basic-for-applications/

我在尝试查找共享点站点上的凭据信息时遇到问题。我应该去哪里才能找到用户名、密码和 SOAP URL?

我在下面 VBA 中编写了简单的 SharePoint 列表 SOAP 查询。我能够在 Excel 中 运行 它并从 SharePoint 中提取数据。 SOAP 不容易使用,因为您需要所有 XML 都正确,否则它会失败。

您可以通过在 SharePoint 服务器上打开 /_vti_bin/Lists.asmx link 来获取带有示例的服务列表,例如, http://yourserver.com/_vti_bin/Lists.asmx 如果您看到空白页面,则表示您的 SharePoint 版本不支持 SOAP Web 服务。

示例:使用 VBA

查询 SharePoint UserInfo 列表中的数据
Sub spListQuery()

    Dim webUrl, wsdl, action, soap, xhr As XMLHTTP60

    itemId = 1
    listName = "UserInfo"
    webUrl = "http://yourserver.com"   'set to SharePoint site url
    wsdl = "/_vti_bin/Lists.asmx"
    action = "http://schemas.microsoft.com/sharepoint/soap/GetListItems"

soap = "<?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>" & listName & "</listName>" & _
        "<query><Query>" & _
            "<Where><Eq><FieldRef Name=""ID""/><Value Type=""Integer"">" & itemId & "</Value></Eq></Where>" & _
            "</Query></query>" & _
            "<viewFields><ViewFields/></viewFields>" & _
        "</GetListItems>" & _
    "</soap:Body>" & _
"</soap:Envelope>"


    Set xhr = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    xhr.Open "POST", webUrl & wsdl, False
    xhr.setRequestHeader "Content-Type", "text/xml; charset=utf-8"
    xhr.setRequestHeader "SOAPAction", action
    xhr.Send soap

    MsgBox xhr.Status & ":" & xhr.statusText & vbCrLf & xhr.responseText


End Sub