SharePoint Web 服务 - GetListItems

SharePoint Web Service - GetListItems

我正在尝试使用 SharePoint 2013 Web 服务 (GetListItems)。

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soap="http://schemas.microsoft.com/sharepoint/soap/">
   <soapenv:Header/>
   <soapenv:Body>
      <soap:GetListItems>

         <soap:listName>OnLineFormsList</soap:listName>

         <soap:query>
            <Where>
              <Eq>
                 <FieldRef Name="Item Type" />
                 <Value Type="String">Personal</Value>
              </Eq>
             </Where>
         </soap:query>

         <viewFields>
           <FieldRef Name="Process ID" />
           <FieldRef Name="Title" />
           <FieldRef Name="Description" />
         </viewFields>

         <soap:rowLimit>50</soap:rowLimit>

         <queryOptions xmlns:SOAPSDK9=
              "http://schemas.microsoft.com/sharepoint/soap/" >
           <QueryOptions/>
        </queryOptions>

         <soap:webID></soap:webID>
      </soap:GetListItems>
   </soapenv:Body>
</soapenv:Envelope>

我正在从 SoapUI 中尝试此操作。我收到以下错误消息:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <soap:Fault>
         <faultcode>soap:Server</faultcode>
         <faultstring>Exception of type 'Microsoft.SharePoint.SoapServer.SoapServerException' was thrown.</faultstring>
         <detail>
            <errorstring xmlns="http://schemas.microsoft.com/sharepoint/soap/">Element &lt;Query> of parameter query is missing or invalid.</errorstring>
            <errorcode xmlns="http://schemas.microsoft.com/sharepoint/soap/">0x82000000</errorcode>
         </detail>
      </soap:Fault>
   </soap:Body>
</soap:Envelope>

谁能指出如何正确使用此服务?

列出列:

查看:所有项目(默认一个)

我遵循了关于此 link 的说明:https://msdn.microsoft.com/en-us/library/lists.lists.getlistitems(v=office.12).aspx

我从未使用过 Sharepoint 但是根据错误消息和您提供的 link 问题显然是您的请求未根据架构进行验证。

我认为问题出在请求节点的节点名称和命名空间上。使 http://schemas.microsoft.com/sharepoint/soap/ 成为您请求的默认命名空间,并将一些节点名称大写(在您提供的 link 的示例中,使用 <Query> 而不是 <query><ViewFields> 而不是 <viewField>),您还可以删除 <WebID>,因为它是一个可选元素,在您的情况下它是空的。

可能会出现更多错误,但您可以尝试使用:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns="http://schemas.microsoft.com/sharepoint/soap/">
   <soapenv:Body>
      <GetListItems>
         <ListName>OnLineFormsList</ListName>
         <Query>
            <Where>
              <Eq>
                 <FieldRef Name="Item Type" />
                 <Value Type="String">Personal</Value>
              </Eq>
             </Where>
         </Query>

         <ViewFields>
           <FieldRef Name="Process ID" />
           <FieldRef Name="Title" />
           <FieldRef Name="Description" />
         </ViewFields>

         <RowLimit>50</RowLimit>

         <queryOptions xmlns:SOAPSDK9=
              "http://schemas.microsoft.com/sharepoint/soap/" >
           <QueryOptions/>
         </queryOptions>

      </GetListItems>
   </soapenv:Body>
</soapenv:Envelope>