Inheritance: System.Web.Services.Protocols.SoapHttpClientProtocol
        public static string GetWebPartPropertiesServiceCall(ClientContext clientContext, string storageKey, string pageUrl)
        {
            string webPartXml = string.Empty;

            var service = new WebPartPagesService.WebPartPagesWebService();
            service.Url = clientContext.Web.Url + Constants.WEBPART_SERVICE;

            service.PreAuthenticate = true;

            service.Credentials = clientContext.Credentials;

            // Actual web service call which returns the information in string format
            webPartXml = service.GetWebPart2(pageUrl, storageKey.ToGuid(), Storage.Shared, SPWebServiceBehavior.Version3);

            return webPartXml;
        }
        public static string GetWebPartProperties(string pageUrl, string StorageKey, string webUrl, string outPutDirectory)
        {
            string webPartPropertiesFileName = string.Empty;

            ClientContext clientContext = new ClientContext(webUrl);

            string webPartXml = string.Empty;
            ExceptionCsv.WebUrl = webUrl;
            string exceptionCommentsInfo1 = string.Empty;
            Web web = null;

            try
            {
                string sourceWebPartXmlFilesDir = outPutDirectory + @"\" + Constants.SOURCE_WEBPART_XML_DIR;

                if (!System.IO.Directory.Exists(sourceWebPartXmlFilesDir))
                {
                    System.IO.Directory.CreateDirectory(sourceWebPartXmlFilesDir);
                }

                //Deleted the Web Part Usage File
                DeleteUsageFiles_WebPartHelper(sourceWebPartXmlFilesDir, StorageKey + "_" + Constants.WEBPART_PROPERTIES_FILENAME);

                //Prepare Exception Comments
                exceptionCommentsInfo1 = "Web Url: " + webUrl + ", Page Url: " + pageUrl + ", StorageKey: " + StorageKey;

                using (ClientContext userContext = Helper.CreateAuthenticatedUserContext(Program.AdminDomain, Program.AdminUsername, Program.AdminPassword, webUrl))
                {
                    web = userContext.Web;
                    userContext.Load(web);
                    userContext.ExecuteQuery();
                    clientContext = userContext;

                    Logger.LogInfoMessage("[GetWebPartProperties] Retrieving WebPart Properties for StorageKey: " + StorageKey.ToString() + " in the Page" + pageUrl);

                    var service = new WebPartPagesService.WebPartPagesWebService();
                    service.Url = clientContext.Web.Url + Constants.WEBPART_SERVICE;

                    Logger.LogInfoMessage("[GetWebPartProperties] Service Url used to retrieve WebPart Properties : " + service.Url);

                    service.PreAuthenticate = true;

                    service.Credentials = clientContext.Credentials;

                    //For Publishing Pages, Pass - WebPartID
                    //For SitePage or Team Site, Pass - StorageKey.ToGuid()
                    webPartXml = service.GetWebPart2(pageUrl, StorageKey.ToGuid(), Storage.Shared, SPWebServiceBehavior.Version3);

                    Logger.LogSuccessMessage("[GetWebPartProperties] Successfully retreived Web Part Properties", true);

                    webPartPropertiesFileName = sourceWebPartXmlFilesDir + "\\" + StorageKey + "_" + Constants.WEBPART_PROPERTIES_FILENAME;

                    using (StreamWriter fsWebPartProperties = new StreamWriter(webPartPropertiesFileName))
                    {
                        fsWebPartProperties.WriteLine(webPartXml);
                        fsWebPartProperties.Flush();
                    }

                    Logger.LogSuccessMessage("[GetWebPartProperties] WebPart Properties in xml format is exported to the file " + webPartPropertiesFileName, true);
                }

            }
            catch (Exception ex)
            {
                System.Console.ForegroundColor = System.ConsoleColor.Red;
                Logger.LogErrorMessage("[GetWebPartProperties] Exception Message: " + ex.Message + ", Exception Comment: " + exceptionCommentsInfo1);
                System.Console.ResetColor();
                ExceptionCsv.WriteException(Constants.NotApplicable, Constants.NotApplicable, ExceptionCsv.WebUrl, "WebPartProperties", ex.Message, ex.ToString(), "GetWebPartProperties()", ex.GetType().ToString());
            }

            return webPartPropertiesFileName;
        }