Freigeben über


Exporting Variations

MOSS 2007 had an OOB capability of exporting a publishing page to a .cmp file to enable offline translations scenarios. In case your translation team does an offline translation of the WCM site, the exported .cmp contained the required xmls for translation and you could import the translated xmls back to the destination variation. This was done through the “Export Variation” – “Import Variation” option under Site content and Structure.

From my initial analysis I did not find the same UI in SharePoint Server 2010 to export variations, however this can be achieved by using the following web service.

https://msdn.microsoft.com/en-us/library/microsoft.sharepoint.publishing.webservices.publishingservice.exportobjects%28v=office.14%29.aspx

Code extract from MSDN.

 using System;
 using System.IO;
 using System.Collections.Generic;
 using System.Text;
 using System.Net;
 //Replace macro with "(your assembly name).(name of your Web reference)"
 using PublishingServiceClient = Microsoft.SDK.SharePoint.Server.Samples.PublishingServiceClient;
  
 namespace Microsoft.SDK.SharePoint.Server.Samples
 {
     class Program
     {
         static void Main(string[] args)
         {        
             // Create a Web reference (named "PublishingServiceClient" here)which generates a SOAP Client class of the same name.
             // URL to the Web service is given by "https://servername/site/_vti_bin/PublishingService.asmx" 
             // Access the Web service methods using objects of this class.
             PublishingServiceClient.PublishingService publishingServiceClient = new PublishingServiceClient.PublishingService();
  
             //Create credentials for the user accessing the Web service. The export requires site administrator privileges.
             //Use default credentials if the user running client has required rights at the server.
             //Otherwise, explicitly create Credentials using new System.Net.Credentials("username","passwd", "domain").
             publishingServiceClient.Credentials = System.Net.CredentialCache.DefaultCredentials;
  
             //Replace webUrl with the url of the site you want to export.
             string webUrl = "https://servername/Variation Home/Variation Site";
  
             if (!string.IsNullOrEmpty(webUrl))
             {
                 //Invoke the SOAP Client Method.
                 byte[] compressedFileContent = publishingServiceClient.ExportObjects(webUrl);
                 File.WriteAllBytes(Path.GetTempFileName(), compressedFileContent);
                 //Uncompress the file for translation.
             }            
         ...