Request a Quote

Copy Sharepoint pages from one sharepoint server/site to other

Copy Sharepoint pages from one sharepoint server/site to other

Few months ago , I had requirement of copy sharepoint 2007 pages to sharepoint 2013 site in my migration project.And this application is running out of sharepoint server so i have to use sharepoint services.I have used copy-service for this requirement.It will only copy static content of page not other webparts content.

So first fetch source page fieldinfo and bytearray using copy-service ‘GetItem’ method(add copy service reference and programatically change its url).

 

//give source copy-service url and credentials
CopyWS.Copy copyWS = new CopyWS.Copy();
copyWS.Url = "http://wssdev:7001/_vti_bin/copy.asmx";
copyWS.Credentials = new NetworkCredential("sourcesite-username", "sourcesite-password");

//fetch page fieldinfo and bytearray using copy GetItem method from source page.
CopyWS.FieldInformation[] mossPageFieldInfoArray;
byte[] mossPageByteArray;
uint myGetUint = copyWS.GetItem("http://wssdev:7001/Pages/test1.aspx", out mossPageFieldInfoArray, out mossPageByteArray);

 

Now set copy-service url to destination site and copy the page using ‘CopyIntoItems’ method.Pass source page fieldinfo and bytearray into this method.

 

//give destination copy-service url and credentials
copyWS = new CopyWS.Copy();
copyWS.Url = "http://spe2013dev1:4444/_vti_bin/copy.asmx";
copyWS.Credentials = new NetworkCredential("destinationsite-username", "destinationsite-password");

// create page in destination site using source page info.
CopyWS.CopyResult[] copyResultArray;
string[] copyDest = { "http://spe2013dev1:4444/Pages/test1.aspx" };
uint myCopyUint = copyWS.CopyIntoItems("http://wssdev:7001/Pages/test1.aspx", copyDest, mossPageFieldInfoArray, mossPageByteArray, out copyResultArray);

 

Check CopyResult.ErrorCode , if it is success then your page gets copied successfully else it will show error message.

Additional Information:

Page Field Information Array

p3

Page Byte Array
p2

Page Copy Result

p3

Related link:http://msdn.microsoft.com/en-us/library/copy.copy.copyintoitems%28v=office.12%29.aspx

Leave a Reply

Your email address will not be published. Required fields are marked *

Copyright © 2015 Trimantra Software Solution LLP- Software Outsourcing Company India. All rights reserved.