PublishingService.ImportObjects Method
Use this Web service to import pages that participate in variations into the PublishingWeb object.
Namespace: Microsoft.SharePoint.Publishing.WebServices
Assembly: Microsoft.SharePoint.Publishing (in Microsoft.SharePoint.Publishing.dll)
Syntax
'Declaration
<WebMethodAttribute> _
Public Function ImportObjects ( _
siteUrl As String, _
fileContent As Byte() _
) As Boolean
'Usage
Dim instance As PublishingService
Dim siteUrl As String
Dim fileContent As Byte()
Dim returnValue As Boolean
returnValue = instance.ImportObjects(siteUrl, _
fileContent)
[WebMethodAttribute]
public bool ImportObjects(
string siteUrl,
byte[] fileContent
)
Parameters
siteUrl
Type: System.StringAbsolute URL of the PublishingWeb object into which you want to import the compressed file.
fileContent
Type: []Content of the compressed file that contains data about the pages that are exported using the ExportObjects() method.
Return Value
Type: System.Boolean
True if the import succeeds. Otherwise, set to false.
Remarks
The compressed file content passed as a parameter to this method contains data that is imported into the site specified by the siteUrl parameter. To use this method, you must be a site collection administrator.
Examples
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 "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. 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 = "https://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.
}
...