Export (0) Print
Expand All
Expand Minimize

ImportXml Message (CrmService)

banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Works for all deployment typesWorks online only

Import the specified set of entity customizations from an XML file.

The relevant classes are specified in the following table.

TypeClass
RequestImportXmlRequest
ResponseImportXmlResponse

Remarks

To use this message, pass an instance of the ImportXmlRequest class as the request parameter in the Execute method.

For a list of required privileges, see ImportXml Privileges.

Example

The Import All XML Request requires an ImportExportXml file for import. For this example, we will export this file from CRM and then import it back into Microsoft Dynamics CRM.

[C#]
// 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://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the request.
ExportXmlRequest exportRequest = new ExportXmlRequest();

// Define the entities to retrieve, in this case accounts
// The XML format must match this and the empty "nodes" node is required.
exportRequest.ParameterXml = @"<importexportxml>
<entities>
   <entity>account</entity>
</entities>
<nodes>  
   <node>templates</node> 
</nodes>
<securityroles/>
<settings/>
<workflows/>
</importexportxml>";

// Execute the request.
ExportXmlResponse entities = (ExportXmlResponse)service.Execute(exportRequest);

// Create the import request.
ImportXmlRequest importRequest = new ImportXmlRequest();
   
// Tell the request where the temporary XML file is located.
importRequest.CustomizationXml = entities.ExportXml;
   
// Tell the request that the account entity is being imported.
importRequest.ParameterXml = @"<importexportxml>
<entities>
   <entity>account</entity>
</entities>
<nodes>  
   <node>templates</node> 
</nodes>
<securityroles/>
<settings/>
<workflows/>
</importexportxml>";
   
// Execute the import.
ImportXmlResponse importResponse = (ImportXmlResponse)service.Execute((Request)importRequest);
[Visual Basic .NET]
' Set up the CRM service.
Dim token As 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";
 
Dim service As New CrmService()
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials


' Create the request.
Dim exportRequest As New ExportXmlRequest()

' Define the entities to retrieve, in this case accounts.
' The XML format must match this and the empty "nodes" node is required.
exportRequest.ParameterXml = _
"<importexportxml>" + _
   "<entities>" + _
    "<entity>account</entity>" + _
   "</entities>" + _
   "<nodes>" + _  
      "<node>templates</node>" + _ 
   "</nodes>" + _
   "<securityroles/>" + _              
   "<settings/>" + _
   "<workflows/>" + _
"</importexportxml>"

' Execute the request.
Dim exportResponse As ExportXmlResponse = CType(service.Execute(exportRequest), ExportXmlResponse)

' Create the import request.
Dim importRequest As New ImportXmlRequest()

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

' Tell the request that the account entity is being imported.
importRequest.ParameterXml = _
"<importexportxml>" + _
"<entities>" + _
   "<entity>account</entity>" + _
"</entities>" + _
   "<nodes>" + _  
      "<node>templates</node>" + _ 
   "</nodes>" + _
   "<securityroles/>" + _       
   "<settings/>" + _
   "<workflows/>" + _
"</importexportxml>"

' Execute the import.
Dim importResponse As ImportXmlResponse = CType(service.Execute(CType(importRequest, Request)), ImportXmlResponse)

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show:
© 2014 Microsoft