2012-05-09 37 views
0

假設我在SharePoint 2010網站中有三個版本的同一文檔。我將如何檢索使用Web服務的第二個版本的元數據?使用SharePoint的Lists.GetListItems網絡服務方法檢索特定的文檔版本

我知道,我可以用下面的SOAP請求

<?xml version="1.0" ?> 
<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"> 
<S:Body> 
    <GetListItems xmlns="http://schemas.microsoft.com/sharepoint/soap/"> 
     <listName>Shared Documents</listName> 
     <viewName></viewName> 
     <query> 
      <Query><Where><Eq><FieldRef Name="FileRef"/> 
      <Value Type="Text">https://mysite.com/sites/DocLib026/Shared Documents/_mytest5.doc</Value></Eq></Where></Query> 
     </query> 
     <rowLimit>200</rowLimit> 
    </GetListItems> 
</S:Body></S:Envelope> 

檢索最新的版本如何修改,這樣我可以檢索任何現有版本?

回答

0

使用SharePoint對象模型,一旦我使用的代碼中發現here

using (SPSite site = new SPSite(「http://SharePointSite」)) 
{ 
using (SPWeb web = site.OpenWeb()) 
{ 
SPList docs = web.Lists["Mydocumentlib"]; 
    foreach (SPFile file in docs.RootFolder.Files) 
{ 
    Console.WriteLine(「File {0} has next version {1}. Version History:」, file.Url,   file.UIVersionLabel); 
    foreach (SPFileVersion v in file.Versions.Cast().Reverse()) 
    { 
    Console.WriteLine(」 Version {0} checked in at {1} with this comment: ‘{2}’」, v.VersionLabel, v.Created, v.CheckInComment); 
    } 
} 
}} 

只是調整的foreach方法,做你的神奇的東西在那裏。

+0

我需要一個Web服務解決方案。我實際上使用Java來進行SOAP Web服務調用。不過謝謝。 – duvo

+0

很抱歉聽到Duvo讓我看看我的服務器,也許我們可以找出一種方法來在列表視圖中顯示這些項目,然後對該視圖進行caml查詢......您是否可以訪問列表設置? – ricardordz

+0

是的,我被授予網站管理員。我雖然關於CAML,但沒有看到我可以查詢的任何屬性。我試過_UIV​​ersionString屬性,它只返回匹配版本號的文檔。例如_UIVersionString = 4.0將返回具有4個版本的文檔。真的很感謝幫助 – duvo

相關問題