Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ExportObjects Method

PublishingService.ExportObjects Method

Use this Web service to export current Major or Minor version of the PublishingPages in the PublishingWeb that participates in variations.

Namespace:  Microsoft.SharePoint.Publishing.WebServices
Assembly:  Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)

[WebMethodAttribute]
public byte[] ExportObjects(
	string webUrl
)

Parameters

webUrl
Type: System.String

Absolute URL of the PublishingWeb object for which pages are to be exported.

Return Value

Type: []
Stream of bytes from a compressed .cmp file.

The Web service is provided to export variation pages for translation. Given a PublishingWeb, we extract all pages in the site that participate in variations and export the content of those pages. The returned stream belongs to the compressed file that contains all data related to these pages. Content is translated in the manifest.xml file in the compressed .cmp file. Use the ImportObjects() Web service to reimport the translated pages to the Variation site. To export a PublishingWeb you must be the Web site Administrator and you must have permissions to view page dependencies.

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 "http://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 = "http://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.
            }            
        ...
Show:
© 2015 Microsoft