使用SOAP检索sharepoint列表

时间:2015-05-26 22:15:01

标签: sharepoint soap sharepoint-list

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

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

我在尝试找到在sharepoint网站上找到凭据信息的位置时遇到问题。我将在哪里找到用户名,密码和SOAP URL?

1 个答案:

答案 0 :(得分:2)

张 -

我在VBA下面写了一个简单的SharePoint列表SOAP查询。我能够在Excel中运行它并从SharePoint中提取数据。

然而,几乎没有人使用VBA进行SOAP调用。通常使用JavaScript,C#或Java完成。此外,大多数人已经离开了SOAP,现在正在使用SharePoint中提供的更新的REST服务。如果你的目标是学习,那么REST对你来说可能会更好(也更容易)。以下是一些Microsoft的参考资料,可以帮助您入门:

示例:使用VBA查询SharePoint UserInfo列表中的数据

Sub spListQuery()

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

    itemId = 1
    listName = "UserInfo"
    webUrl = "http://youserver.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