Tuesday, April 8, 2014

How to create PerformancePoint dashboard in SharePoint 2013


This is a step by step guide to creating a Performance Point dashboard with an OLAP cube as the data source using the AdventureWorks cube.  It’s a simple example, but demonstrates many of the concepts you’ll use in PerformancePoint.
1.   Create a Business Intelligence Center site.  Click on the Dashboards link in the left menu.
2.   Click on the Performance Point Ribbon, then click the Dashboard Designer button to launch the Dashboard Designer:
ALM Blog Pic 1

3.   In the Dashboard Designer, create a data source by right-clicking on the Data Connections folder in the left column and choose “New Data Source”:

ALM Blog Pic 2
4.   Select a data source template.  I’ll use Analysis Services to connect to my AdventureWorks demo cube:
  
ALM Blog Pic 3
Tip:  I used this TechNet article to setup the AdventureWorks demo data:  http://technet.microsoft.com/en-us/library/jj573016.aspx

5.   For an Analysis Services data source, enter the SQL Server name.  Then use the Database drop down to select an available database and use the Cube drop down to select the cube.
There are several choices for authentication.  I selected the Unattended Service Account for my demo dashboard. 
ALM Blog Pic 4

6.   Test the data source to make sure you can connect.

7.   Rename the data source by right clicking on the name.  Then save your work.

8.   Create a report to display on the dashboard.  Right click on PerformancePoint Content and choose New -> Report: 

9.   Select a report template.  I’m using Analytic Chart:

10.   Select the data source you created and click Finish:

11.   Rename your report:

12.   Select your measures and dimensions for the chart in the Details panel in the right column and drag them to the series and bottom axis sections at the bottom of the report:
13.   Review the results and save your work.  Create another report for your dashboard by repeating this process.
14.   Create a dashboard page to host the report(s).  Right-click on PerformancePoint content and choose New-> Dashboard.  Select a template:

15.   Add the report you created by dragging it from the right column into a zone on the dashboard:

ALM Blog Pic 13

16.   Rename the dashboard and save your work.
17.   Right-click on the dashboard and choose Deploy to SharePoint:

18.   Choose a BI Center site to deploy to and click OK:

19.   When deployment is complete, the new dashboard will open in a browser:

ALM Blog Pic 17

Configure Form Based Authentication in SharePoint 2010

This article explains step by step information on configuring Form Based Authentication (FBA) in SharePoint 2010. This article would be useful for developers/designers/architects and those who want to implement form based authentication (FBA) for their SharePoint 2010 sites as a business requirement.
We cannot use the classic / basic claimed based authentication for all business scenarios. I was recently working on a consumer portal or product selling site where form based authentication is most appropriate. This article resolves authentication issues by configuring a SharePoint 2010 site with form based authentication.

Difference between MOSS 2007 and SharePoint 2010

There is no huge difference in configuring FBA for a MOSS 2007 site and a SharePoint 2010 site. You cannot implement FBA for a SharePoint 2010 class authentication site. FBA can be implemented only for a claims authentication site in SharePoint 2010.
In MOSS 2007, it is required to configure the web.config file of the FBA site and Central Administration site. In SharePoint 2010, it is required to configure the web.config file of the FBA site, Central Administration site, and the Security Token Service (STS) web.config file. STS is one of the next generation Single Sign On services used to store credentials of an application in SharePoint 2010. I have also written article on enabling FBA in a MOSS 2007 site in CodeProject and Blogger and is available here.

Steps to Configure FBA in SharePoint 2010 

Below are the steps required to configure FBA in SharePoint 2010. I will be using MS SQL database as membership store for users. 
A) Setting up ASP.NET Forms Authentication User and Role Data Source
1. Create Database
2. Configure Membership and Role Provider
3. Create User
B) Create Web Application and Site Collections
C) Configure Web.Config file 
1. Configuring FBA web application web.config file
2. Configuring Central Administration web application web.config file
3. Configuring Security Token Service web.config file
D) Adding User Policy to the FBA Web Application
E) Verification Steps

A) Setting up ASP.NET Forms Authentication User and Role Data Source 

This section explains creation of database which is used to store user's information such as credentials and roles which is used for Form Authentication. This section also explains the configuration of Membership and Role providers in the web.config file and creation of users using ASP.Net configuration wizard. This article shows creating a user and which will be used for testing Form Authentication later.

1. Create Database 

To create database, Microsoft has provided a tool/ utility called
aspnet_regsql.exe that creates a database for us. This utility can be found in %windir%\Microsoft.Net\Framework64\v2.0.50727 folder. Please see the image below: 
Executing aspnet_regsql.exe file will open ASP.Net SQL Setup wizard that will walk through creating the ASP.Net database. I have added the database name as FBANetDB and configured it for windows authentication. Please see the image below:

Click on Next button. Please see the image below:

Select Configure SQL Server for application services option and click Next button. Please see the image below:

Click Next button. Now the database FBANetDB is created successfully. Please see the image below:



2. Configure Membership and Role Provider 

In the previous section, database is created successfully. Now we need to add a user in to database. Using ASP.NET Configuration Wizard, users can be added the database. This can be achieved by creating web site that will allow us to add the users and roles and also ensure the database connection strings, membership and role providers are correctly configured before we bring SharePoint in to equation.
Below steps explains creating web site and configuring membership and role providers and executing ASP.Net Configuration Wizard.
a) Open Visual Studio 2010 and select File ? New ? Web Site. In the New Web Site dialog, select the ASP.Net Web Site template and enter the location to store the web site files. Please see the image below:

You can choose any location whichever is comfortable for you. web.config file will be added to project automatically.

b) By default, you will see a <connectionStrings/> node within <configuration> node. Specify the connection string to the database which has been created in the previous section. Please see the image below:

 

I have mentioned server as GUNAGA1. This is the server in which SQL Server 2008 is installed. Please mention the respective server name.
Also add the membership provider and role provider within <system.web> tag. See the below image for more information.

 

c) Save web.config file and launch the ASP.Net Configuration Wizard by clicking on Website ? ASP.Net Configuration. Please see the image below:

  

d) Set the authentication type in the above wizard. To do this, click Security link. In the Security tab, under Users section, click Select authentication type link. Select From the internet option and press Done button which is available in the bottom right corner. By selecting this option, which means that site will use form authentication to identify users. Please see the image below:

  


e) To test the membership and role providers, click on Provider tab. In the Provider tab, click on Select a different provider for each feature (advanced) link. Select right / correct membership and role provider and click Test link to ensure that providers are communicating to right database.

At this point, we configured web.config file with connection string and providers information. Also we tested the providers with the database. Next section will explain adding users to database.

3. Create User 

a) To add users, click on Security tab. In Security tab, under Users section, click Create user link. Here I am adding user as testFBA and password as password which will be used for testing form authentication later. Please see the image below:

  


Now we have created a user successfully. Do not worry about creating roles at this time and will be explained later.

B) Create Web Application and Site Collection 

Follow the below steps to create web application and site collection.
a. Go to Central Administration ? Application Management ? Select ‘Manage Web Application’ link present under ‘Web Applications’ section.
b. Click on ‘New’ option in the ribbon.
     1. See the below image for ‘Authentication’ and ‘IIS Web Site’ section.

         

     2. See the below image for ‘Security Configuration’ and ‘Claims Authentication Type’ section.

          

     3. See the below image for configuring ‘Sign In Page URL’ and ‘Public URL’ section.

        

     4. See the below image for configuring ‘Application Pool’ and ‘Database Name and Authentication’ section.

         

     5. Create Site Collection after creating web application. Select the template whichever you want to create site collection.

C) Configure We.Config file

1. Configuring FBA web application web.config file 

Open FBA web application web.config file and add the below entries.
     a. Add Connection String. Connection String has to be added after </SharePoint> and before <system.web> tag. See the below image for more information.

           

     b. Add Membership Provider and Role Provider

         

2. Configuring Central Administration web application web.config file 

Open Central Administration web application web.config file and add the below entries.
     a. Add Connection String. Connection String has to be added after </SharePoint> and before <system.web> tag. See the below image for more information.

           

     b. Add Membership Provider and Role Provider

         

3. Configuring Security Token Service web.config file 

Open Security Token Service web.config file from %Program Files%\Common Files\Microsoft Shared\web server extensions\14\Web Services\SecurityToken location and add the below entries.
a. Add Connection String. Connection String has to be added above <system.web> tag. See the below image for more information.

b. Add Membership Provider and Role Provider

D) Adding User Policy to the FBA Web Application 

Follow the below steps to add user policy to the web application.
a. Go to Central Administration ? Manage Web Applications ? Select the FBA web application and click on ‘User Policy’ option in the ribbon.

b. Click on ‘Add Users’ link and select ‘Default’ as the zone and click on ‘Next’ button.


c. Type the user name created in ‘Create User’ section in the ‘Users’ textbox and click on people picker icon. You should see the user name get underlined in the ‘Users’ textbox.

d. Follow the verification steps to test form based authentication.

E) Verification Steps 

1. Go to FBA SharePoint site and select ‘Forms Authentication’ option.

2. Enter User Name and Password and select ‘Sign In’ button.

3. You should be redirected to home page.


How to create Sharepoint-Hosted App in 2013




I want to create a SharePoint-Hosted App in 2013 using Visual Studio.
I have created a SharePoint 2013 machine with all required software.
Just as a best practice, even if you are creating a standalone server, enable Active Directory Domain Services.
SharePoint 2013 works better when the system is in a Domain, rather than in a workgroup.

So, I have installed Windows server 2012, enabled all required features. Installed Office 2013, SharePoint 2013, Visual Studio 2012 and Developer tools for SharePoint 2013.

We will create an "App for SharePoint" and try to understand the scaffold code and try to deploy it and see what can happen.

Step 1: Open Visual studio and select "App for SharePoint".

Provide required data. While selecting the hosting option, remember to select the hosting option as "SharePoint-Hosted". You can select Auto-Hosted if you want to deploy your App to Windows Azure. Provider-Hosted if you want to deploy the App to any other hosting Providers.


Step 2: Default "App" code is created and lets have a look at its content.
Project is created with a Default.aspx page and few script files and configuration files. First thing we need to know is about "Default.aspx" page. We already read that every SP-Hosted App we Install/Deploy will be created as a Subweb under SP Web application. That Subweb will be defaulted to this specific page. When user click on the App, he will be navigated to this page first. So better not to mess with the name of the file.
Lets see the content of the file now.

Step 3: I have attached the snapshot of the "Default.aspx" file and see what is the significance of each part.

The first highlighted box refers to the Framework provided JavaScript libraries. As we will be using Client Side Object Model(CSOM), these Jscript libraries will provide the necessary support while execution of our custom code.

Second highlighted box refers to the local script file pertaining to this specific app. We will see in detail about this in next step.

Third one is the sample code I added. We will not be doing extensive coding right now. The objective is to see if there are any hurdles in deploying an App.

Step 4: Open App.js file under scripts. This file content is responsible for Loading the Context and Web information in which the App is running. Look at the code and its almost self explanatory.


Step 5: Now I tried to deploy the App.
Oops, got an error.

" Error occurred in deployment step 'Install app for SharePoint': Failed to install app for SharePoint. Please see the output window for details."

Ok, looked at Output window found another reason.

 " ErrorDetail: Apps are disabled on this site. "

Now we need to remember what we learned in prior post.  Any SharePoint-Hosted App will try to create a Subweb which will be executed in a separate AppDomain apart from SharePoint Farm.
Currently SharePoint dint have any clue on where to Host this app code and what to do with it.

Step 6: We need to create a new App Domain, and register it with SharePoint. So next time when you deploy an App, it know where to host it.
I created my machine on a Domain "Sharepoint13.com". So I would like to create an App Domain "Sharepoint13Apps.com" for hosting purpose. For that go to
Administrative Tools > DNS > following window will b opened showing the Machine Name and the current App Domain in which SharePoint farm is executing.

Right click on Forward Lookup Zone and Click on
"New Zone" > "Next" > "Next" > "Next" > following window will open.

Now the new AppDomain is created, Now we will create a wildcard Alias (CNAME) record to allow apps to create unique domain names within our app domain, Sharepoint13Apps.com. Right-click Sharepoint13Apps.com and select Refresh. Then right-click Sharepoint13Apps.com and select New Alias (CNAME)…
Give the values as I have shown and Click OK.

Now App Domain is created, lets test it now. Open CMD window and try pinging to "abc.Sharepoint13Apps.com". . . Successfully done.

Step 7: We need to register this newly created app domain with SharePoint. Go to Central admin, click on Apps on right menu.
it will give you a message saying

"The Subscription Settings service and corresponding application and proxy needs to be running in order to make changes to these settings. "

This means a new service application running in its own app pool needs to be created and up and running.
Lets create a Managed account with Machine admin credentials. Mine is
"Sharepoint13\Administrator".
Open the PowerShell window and execute below script.

add-pssnapin "Microsoft.Sharepoint.Powershell"

$account = Get-SPManagedAccount sharepoint13\administrator

Remove-SPServiceApplicationPool -Identity SettingsServiceAppPool

$appPoolSubSvc = New-SPServiceApplicationPool -Name SettingsServiceAppPool -Account $account

$appSubSvc = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPoolSubSvc -Name SettingsServiceApp -DatabaseName SettingsServiceDB

$proxySubSvc = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $appSubSvc


It may prompt you once, say Yes.
Some times the above script may give error

"Access denied. Only machine administrators are allowed to create administration service job definitions"
Go to "C:\Program Files\Common Files\microsoft shared\Web Server Extensions\15\CONFIG\POWERSHELL\Registration" and execute SharePoint.ps1 as Administrator.
Issue will be resolved.

Once this script is successfully executed. We have created a new service Application, and its proxy which will run under its own Service App Pool. To verify this go to
Central Admin > Service Applications > Manage Service Applications > you can see below Svc application created , up and running.
Step 8: Now go to Central Admin > Apps > Configure App URLs

You can see that the new App Domain we created automatically populated here, just mention app prefix as "Apps" and say OK.

We are all set to deploy our SharePoint-Hosted App. Right click on Solution and say "Deploy" 

Once App is deployed successfully, go to SharePoint Application and click on "Site Actions" the little gear symbol on top right and click on Site Content. You can see your App there.

Monday, December 30, 2013

How to Migrate Documents from MOSS 2007 to SharePoint 2010


In this blog I wanted to describe how documents can be migrated from MOSS 2007 to SharePoint 2010 environment by building a custom utility. I have used Web Services provided by SharePoint to copy number of documents from MOSS 2007 Document Library to SharePoint 2010 Document Library using SharePoint web services.
Blog SP 1

SharePoint web services

SharePoint provides us a list of web services for individual operations, we are going to use only two of them:
1. Lists.asmx(Web service reference: http://<site>/_vti_bin/Lists.asmx)
2. Copy.asmx (Web service reference: http://<site>/_vti_bin /Copy.asmx)
Let’s take a deeper look into these web methods of these web services:
From Lists.asmx web service we will use two web methods:
Lists.GetList () web method:
Method Signature:
public XmlNode GetList (string listName): Returns a schema for the specified list.
Lists.GetListItems () web method:
Method Signature:
public XmlNode GetListItems ( string listName, string viewName, XmlNode query, XmlNode viewFields,string rowLimit, XmlNode queryOptions, string webID) : Returns information about items in the list based on the specified CAML query.
From Copy.asmx web service we will also use two web methods:
Copy.GetItem() web method:
Method Signature:
public uint GetItem(string Url, out FieldInformation[] Fields,
out byte[] Stream) : Returns a Byte array representation of a document that can be passed to the CopyIntoItems method to copy the document to a different server.
Copy.CopyIntoItems() web method:
Method Signature:
public uint CopyIntoItems( string SourceUrl, string[] DestinationUrls, FieldInformation[] Fields, byte[] Stream,
out CopyResult[] Results): Copies a document represented by a Byte array to one or more locations on a server.

Programming

We can achieve our goal using any of the project types (Console Application, Windows Application, Web Application, Web services etc.). A Windows application has been created into SharePoint 2010 Development Environment, two web references (Lists.asmx & Copy.asmx) of MOSS 2007 has been added into my project. Finally our programming part given below:
1. An object of each of the proxy classes which were generated after adding the web references has been created.
2. Next the Lists.GetList() web method has been called to get the listId from SP2007 Doc Lib
o Input Parameter: Name of the List (For e.g. “Shared Documents”)
o Output: A xml node from which we can get the ListId and WebId
3. Then the Lists.GetListItem() web method has been called to get the Url of Individual documents from SP2007 List.
o Input Parameters:
- listName: Pass the ListId we got from Lists .GetList() web method.
- viewName: If you want to use any view of SP2007 Doc Lib then specify the view name or pass NULL.
- Query: CAML query that determines which records are returned and in what order.
- viewFields: Specifies which fields to return in the query and in what order (eg. <FieldRef Name=’EncodedAbsUrl’ />).
- rowLimit: specifies the number of items, or rows, to display on a page before paging begins (eg. 50 or 500).
- queryOptions: An XML fragment in the following form that contains separate nodes for the various properties of the SPQuery object.
- webID: Pass the webID we got from Lists .GetList() web method.
o Output: A XML node from which we can get the list of URLs of each documents of SP2007 doc lib.
4. Then the Copy.GetItem() web method has been called to get the individual document from SP2007 Doc lib
o Input Parameters:
- Url : Pass the individual document URL from a list of URLs that we got from Lists .GetListItem() web method
o Output:
- FieldInformation Array: which contains the metadata information of the document that we get from SP2007 doc lib.
- Byte Array : Which contains the entire document as an array of bytes (that is a base-64 representation of the retrieved document’s binary data)
5. Next the web reference URL of the object of Copy.asmx web service has been replaced from Sp2007 to SP2010. Because we are pulling the documents from SP2007 document Library but copying into SP2010 doc lib.
6. Then the Copy.CopyIntoItems() web method has been called to copy the items that we got into byte array into SP2010 document library.
o Input Parameters:
- SourceUrl: Pass the individual document URL from a list of URLs that we got from Lists .GetListItem() web method
- DestinationUrls: Pass the destination URL of SP2010 document library.
- Fields: Pass the FieldInformationArray that we got from Copy.GetItem() web method.
- Stream: Pass the byte array that we got from Copy.GetItem() web method.
o Output:
- Results: Finally we will get a <Success> message if the document moved successfully.

The following Configuration used:

<appSettings>
<add key=”DestUrl” value=”http://xyz-abcd:11111/Shared Documents/Test”/>
<add key=”DestWebservcUrl” value=”http:// xyz-abcd:11111/”/>
<add key=”SrcWebservcUrl” value=”http://xyz-sharepoint/sites/abstract/”/&gt;
<add key=”ListRowLimit” value=”1000″/>
<add key=”SrcRootFolder” value=”XYZ Document Library”/>
<add key=”SP2007user” value=”admin”/>
<add key=”SP2007pwd” value=”admin123#”/>
<add key=”SP2007domain” value=”XYZ-Domain”/>
<add key=”SP2010user” value=”xyzuser”/>
<add key=”SP2010pwd” value=”user456$”/>
<add key=”SP2010domain” value=”ABC-Domain”/>
<add key=”DestRootFolder” value=”Shared Documents”/>
<add key=”DestSubfolder” value=”Test2010″/>
</appSettings>

C# Code snippet Used:

To get the list of URLs from MOSS 2007 Document Library :
public List<string> GetListofUrl()
{
List<string> SiteUrlList = new List<string>();
NetworkCredential custCred = new NetworkCredential(ConfigurationManager.AppSettings["SP2007user"],
ConfigurationManager.AppSettings["SP2007pwd"], ConfigurationManager.AppSettings["SP2007domain"]);
SPListServices2010.Lists listService = new SPListServices2010.Lists();
listService.PreAuthenticate = true;
listService.Credentials = custCred;
listService.Url = ConfigurationManager.AppSettings["SrcWebservcUrl"] + “_vti_bin/Lists.asmx”;
XmlNode list = listService.GetList(ConfigurationManager.AppSettings["SrcRootFolder"]);
System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
string listName = list.Attributes["ID"].Value;
string webID = list.Attributes["WebId"].Value;
string rowLimit = ConfigurationManager.AppSettings["ListRowLimit"];
XmlDocument doc = new XmlDocument();
XmlElement query = doc.CreateElement(“Query”);
XmlElement viewFields = xmlDoc.CreateElement(“ViewFields”);
query.InnerXml =
@”<OrderBy><FieldRef Name=’Title’ Ascending=’False’/></OrderBy> “;
viewFields.InnerXml = “<FieldRef Name=’EncodedAbsUrl’ />”;
XmlNode positionNext = null;
XmlNode queryOptions = doc.CreateElement(“QueryOptions”);
queryOptions.InnerXml = “<IncludeMandatoryColumns>False</IncludeMandatoryColumns>”;
int count = 0;
while (true)
{
count++;
XmlNode results = null;
try
{
results = listService.GetListItems(listName, null, query, viewFields, rowLimit, queryOptions, webID);
}
catch (Exception ex)
{
}
try
{
foreach (System.Xml.XmlNode listItem in results)
{
XmlNodeReader objReader = new System.Xml.XmlNodeReader(listItem);
while (objReader.Read())
{
if (objReader["ows_EncodedAbsUrl"] != null)
{
SiteUrlList.Add(objReader["ows_EncodedAbsUrl"].ToString());
}
}
}
}
catch (Exception ex)
{
}
positionNext = results.SelectSingleNode(“//@ListItemCollectionPositionNext”);
if (positionNext == null)
break;
else
queryOptions.InnerXml = “<Paging ListItemCollectionPositionNext=’” + positionNext.InnerXml + “‘ /><IncludeMandatoryColumns>False</IncludeMandatoryColumns>”;
}
return SiteUrlList;
}
To Copy the documents from MOSS 2007 document library to SharePoint 2010 document library.
public void UploadDoc(string SourceUrl, string DestUrl, string DestFolderName, string DestFileName)
{
NetworkCredential custCred2007 = new NetworkCredential(ConfigurationManager.AppSettings["SP2007user"],
ConfigurationManager.AppSettings["SP2007pwd"]); NetworkCredential custCred2010 = new NetworkCredential(ConfigurationManager.AppSettings["SP2010user"],
ConfigurationManager.AppSettings["SP2010pwd"],ConfigurationManager.AppSettings["SP2010domain"] );
try
{
SPcopyservices2007.Copy WebSvc2007 = new SPcopyservices2007.Copy();
SPcopyservices2010.Copy WebSvc2010 = new SPcopyservices2010.Copy();
WebSvc2007.Credentials =custCred2007;
WebSvc2010.Credentials = System.Net.CredentialCache.DefaultCredentials;
string copySource =HttpUtility.UrlDecode( SourceUrl);
string[] copyDest = {HttpUtility.UrlDecode(string.Format(“{0}/{1}/{2}”, DestUrl,DestFolderName, DestFileName))};
SPcopyservices2010.FieldInformation myfldinfo2010 = new SPcopyservices2010.FieldInformation();
SPcopyservices2010.FieldInformation[] myFieldInfoArray2010 = { myfldinfo2010 };
byte[] myByteArray;
WebSvc2010.Url = ConfigurationManager.AppSettings["SrcWebservcUrl"].ToString() + “_vti_bin/Copy.asmx”;
WebSvc2010.Credentials = custCred2007;
uint myGetUint = WebSvc2010.GetItem(copySource, out myFieldInfoArray2010, out myByteArray);
WebSvc2007.Dispose();
WebSvc2010.Dispose();
SPcopyservices2010.CopyResult myCopyResult1 = new SPcopyservices2010.CopyResult();
SPcopyservices2010.CopyResult myCopyResult2 = new SPcopyservices2010.CopyResult();
SPcopyservices2010.CopyResult[] myCopyResultArray = { myCopyResult1, myCopyResult2 };
try
{
WebSvc2010 = new SPcopyservices2010.Copy();
WebSvc2010.Url = ConfigurationManager.AppSettings["DestWebservcUrl"].ToString() + “_vti_bin/Copy.asmx”;
WebSvc2010.Credentials = custCred2010;
uint myCopyUint = WebSvc2010.CopyIntoItems(copySource, copyDest, myFieldInfoArray2010, myByteArray, out myCopyResultArray);
if (myCopyUint == 0)
{
int idx = 0;
foreach (SPcopyservices2010.CopyResult myCopyResult in myCopyResultArray)
{
string opString = (idx + 1).ToString();
if (myCopyResultArray[idx].ErrorMessage == null)
{
//Successfully moved
}
else
{
//Error occured
}
idx++;
}
}
}
catch (Exception exc)
{
int idx = 0;
foreach (SPcopyservices2010.CopyResult myCopyResult in myCopyResultArray)
{
idx++;
if (myCopyResult.DestinationUrl == null)
{
}
}
}
finally
{
if (WebSvc2010 != null)
WebSvc2010.Dispose();
}
}
catch (Exception ex)
{
}
}

Conclusion:

We can use the above steps, configurations and codes to copy the document to a different server (or from a different server) with the document metadata information. During Migration of documents from an old SharePoint environment to a new SharePoint environment this technique is very helpful. We can also recursively get all the documents from all folders and subfolders of source environment using the appropriate CAML query.