Search

ImportAllXml Message

Import all customizations from an XML file.

 
//# This request requires an ImportExportXml file for import. This example exports this file from CRM and then imports it back into Microsoft Dynamics CRM.

// Set up the CRM service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0;
token.OrganizationName = "AdventureWorksCycle";

CrmService service = new CrmService();
service.Url = "http://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// This is a potentially long running operation. The default 90-second
// time-out might be too short. Set the time-out to be 5 minutes.
// This property takes milliseconds.
service.Timeout = 300 * 1000;

// Create the request.
ExportAllXmlRequest request = new ExportAllXmlRequest();

// Execute the request.
ExportAllXmlResponse exportResponse = (ExportAllXmlResponse)service.Execute((Request)request);

// Create the request.
ImportAllXmlRequest importRequest = new ImportAllXmlRequest();

// Tell the request where the temporary XML file is located.
importRequest.CustomizationXml = exportResponse.ExportXml;

// Execute the import.
ImportAllXmlResponse importResponse = (ImportAllXmlResponse)service.Execute(importRequest);