PublishingService.ImportObjects Method
SharePoint 2010
Use this Web service to import pages that participate in variations into the PublishingWeb object.
Assembly: Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)
Parameters
- siteUrl
- Type: System.String
Absolute URL of the PublishingWeb object into which you want to import the compressed file.
- fileContent
- Type: System.Byte[]
Content of the compressed file that contains data about the pages that are exported using the ExportObjects() method.
using System; using System.IO; using System.Collections.Generic; using System.Text; using System.Net; //Replace macro value 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. Export requires site administrator privileges. //Use default credentials if the user running client has required rights to the server. //Otherwise explicitly create Credentials using new System.Net.Credentials("username","passwd", "domain") publishingServiceClient.Credentials = System.Net.CredentialCache.DefaultCredentials; //Replace siteUrl with the site collection URL that you import into. string siteUrl = "http://servername"; //Replace compressedFileName with the complete path of the compressed file you need to import. string compressedFileName = "translatedContent.cab"; byte[] fileContent = File.ReadAllBytes(compressedFileName); if (!string.IsNullOrEmpty(siteUrl)) { //Invoke the SOAP Client Method. publishingServiceClient.ImportObjects(siteUrl, fileContent); //Returns a true or false value depending on whether import was a success. } ...