Dynamics crm 使用MetadataService或CrmService导入工作流

Dynamics crm 使用MetadataService或CrmService导入工作流,dynamics-crm,dynamics-crm-4,Dynamics Crm,Dynamics Crm 4,我已经能够使用ImportXmlRequest将实体从XML文件导入到我的Dynamics实例中,如下所示: <importexportxml> <entities/> <nodes/> <securityroles/> <settings/> <workflows> <workflow>{97db1a25-af1c-4534-9805-c867d6585c

我已经能够使用ImportXmlRequest将实体从XML文件导入到我的Dynamics实例中,如下所示:

<importexportxml>
    <entities/>
    <nodes/>
    <securityroles/>
    <settings/>
    <workflows>
        <workflow>{97db1a25-af1c-4534-9805-c867d6585c8a}</workflow>
    </workflows>
</importexportxml>"
//创建导入请求

ImportXmlRequest importRequest=新建 ImportXmlRequest{
参数xml=@“MyFirstEntitySysCondenty” };

字符串自定义路径= “entityCustomizations.xml”

//使用将自定义XML流传递给导入请求

(StreamReader sr=新 StreamReader(自定义路径)) {
字符串自定义XML= sr.ReadToEnd();
importRequest.CustomizationXml= 定制XML; }

//导入自定义项 myCrmService.Execute(importRequest)

那很好

我还需要将工作流从XML文件导入到我的Dynamics实例中。我尝试使用相同的方法,但不断出现以下错误:“0x80040216无法识别的格式”

通过将包含工作流的XML文件添加到ZIP文件,然后使用ImportCompressedAllXmlRequest导入ZIP文件,我可以让它正常工作

ImportCompressedAllXmlRequest是导入工作流的唯一方法,还是我在ImportXmlRequest中遗漏了一些明显的东西

谢谢


David

实际上我的代码中有一个愚蠢的错误。我可以使用ImportXmlRequest导入工作流,方法是设置ImportXmlRequest的参数XML,如下所示:

<importexportxml>
    <entities/>
    <nodes/>
    <securityroles/>
    <settings/>
    <workflows>
        <workflow>{97db1a25-af1c-4534-9805-c867d6585c8a}</workflow>
    </workflows>
</importexportxml>"

{97db1a25-af1c-4534-9805-c867d6585c8a}
"