Get Previous versions metadata in Moss 2007 using web service RPC Method
Recently I'm facing a typical issue while get the metadata of previous versions, since I'm using Moss 2007 we don't have much options to get it. So, I'm research what are all the ways to achieve this, initially I go with Versions web service but we get only few properties so skip this approach and after several researches then I come to know that we have 2 ways to achieve this in Moss 2007.
Get Previous versions metadata in Moss 2007 using web service RPC Method :
Index:
1. Description
2. Web Service Methods
3. Source Code
4. Output
5. Conclusion1. Description:
Recently I'm facing a typical issue while get the metadata of previous versions, since I'm using Moss 2007 we don't have much options to get it. So, I'm research what are all the ways to achieve this, initially I go with Versions web service but we get only few properties so skip this approach and after several researches then I come to know that we have 2 ways to achieve this in Moss 2007.
-> WebDav
-> RPC.
So, I'm going with RPC method, in this article I'm described detail explaination how to retrieve previous versions metadata using RPC Protocal.
Method Complexity Scalability Metadata Versions
Copy.asmx 2 4 yes no
WebDav 5 5 yes* yes**
Rpc 10 10 yes yes2. Web Service Methods:
GetListItems: This method help us to get the list or library items from Moss 2007 using Web Service.
Syntax: GetListItems(string listName,string viewName,XmlNode query,XmlNode viewFields, string rowLimit,XmlNode queryOptions, string webID);3. Source Code:
private static DataTable GetPreviousVersions(DataRow drCurr, Uri uri)
{
DataTable dtMetaHis = InnitiateTempFields();
string fileName = Convert.ToString(drCurr["ows_LinkFilename"]);
string fileRef = Convert.ToString(drCurr["ows_FileRef"]);
try
{
#region get metadata of previous versions using RPC method
fileRef = fileRef.Substring(fileRef.IndexOf("#") + 1);
string method = "method=list+versions%3a12.0.0.6219&service_name=%2f&document_name={0}\n";
//format the Url by passing file ref
method = String.Format(method, fileRef);
//get the bytes data of the file
List
data.AddRange(Encoding.UTF8.GetBytes(method));
//open web client
using (WebClient wc = new WebClient())
{
// use default network credentials
wc.UseDefaultCredentials = true;
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
wc.Headers.Add("X-Vermeer-Content-Type", "application/x-www-form-urlencoded");
//pointing the admin dll
string address= "http://site:port/_vti_bin/_vti_adm/admin.dll";
// Get the Post data
string result = Encoding.UTF8.GetString(wc.UploadData(address, "POST", data.ToArray()));
// each version meta_info listed here
if (result.Contains("meta_info"))
{
//format the output as we want
string metadata = string.Format("{0}\nmeta_info", result.Substring(result.IndexOf("meta_info")));
metadata = metadata.Replace("", "").Replace("
", "").Replace("