SSIS 2008 - 使用脚本组件连接到CRM 2011 Web Service

时间:2011-07-27 18:32:43

标签: crm ssis dynamics-crm-2011

我正在尝试从SSIS 2008脚本组件连接到CRM 2011 Web服务端点,该组件无法使用.Net 4程序集。这排除了.Net 4 SDK,所以我一直在尝试创建一个代理类来直接使用2011 WS。我已经通过将代理类放入它自己的程序集中来获得代码,但它依赖于从app.config(方法1)读取WSIS包无法使用的WS地址(这些用户可配置的属性需要是存储在SSIS变量中,以便客户可以修改它们以在其环境中工作。)

我想弄清楚如何从SSIS包中读取app.config数据......

或者我需要得到类似方法2的工作,但我不确定为什么服务器会抛出错误。凭证是正确的。 OrganizationServiceClient方法有几个重载,我尝试过但没有一个有效。这是我最接近它的工作方式。谁能告诉我我做错了什么?

            //Method 1:  This code works but relies on pulling the endpoint address from the app.config  (SSIS can’t use this method)
        //OrganizationServiceClient serviceClient = new OrganizationServiceClient("CustomBinding_IOrganizationService");
        //serviceClient.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential() { Domain="MyDomain", UserName="administrator", Password="*****" };

//Method 2:  This method throws this error:
//Could not connect to https:// MYSERVER/XrmServices/2011/Organization.svc. TCP error code 10061: No connection could be made because the target machine actively refused it.
        string url = "https:// MYSERVER/XrmServices/2011/Organization.svc";
        BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.Transport);
        binding.MaxReceivedMessageSize = 2147483647;
        OrganizationServiceClient serviceClient = new OrganizationServiceClient(binding, new EndpointAddress(url));
        serviceClient.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential() { Domain=" MyDomain ", UserName="administrator", Password="******" };

            //this code is common between the two techniques above
        KeyValuePairOfstringanyType[] attributes = new KeyValuePairOfstringanyType[1];
        attributes[0] = new KeyValuePairOfstringanyType();
        attributes[0].key = "name";
        attributes[0].value = "MyTestAccount";

        Entity newAccount = new Entity();
        newAccount.LogicalName = "account";
        newAccount.Attributes = attributes;
        serviceClient.Create(newAccount);

以下app.config的一部分(由上面的方法1使用):

    <client>
        <endpoint address="http://MYSERVER/XRMServices/2011/Organization.svc"
            binding="customBinding" bindingConfiguration="CustomBinding_IOrganizationService"
            contract="IOrganizationService" name="CustomBinding_IOrganizationService">
            <identity>
                <userPrincipalName value="*******" />
            </identity>
        </endpoint>
    </client>

1 个答案:

答案 0 :(得分:2)

您是否考虑在SSIS中使用类似此方法的内容来读取App.config文件并解析XML文档以在SSIS包中设置变量?

http://www.sqlservercentral.com/articles/Integration+Services+(SSIS)/69550/