Changes required when making CRM Service Calls in SSIS Script Component

11 May 2016
Daniel Cai

With our most recent release of SSIS Integration Toolkit on May 5, 2016, we updated our software to work better with SSIS 2016 and 2014. Due to the update, we had to make some changes in order for our software to be fully compatible with the new SSIS capabilities in which you write the package once and use it for any version of SSIS software (mostly 2014, 2016 and potentially any future versions). Such changes will break your existing SSIS packages if you are making CRM service calls in SSIS Script Task or Script Components, you may receive an error such as the following one.

Unable to cast object of type 'System.String' to type 'KingswaySoft.IntegrationToolkit.DynamicsCrm.CrmConnection'

In order to work with the new version, you would need to make one minor change that's illustrated below.

SSIS Script Component

Your original script might be something like this.
var connMgr = this.Connections.CrmConnectionManagerContoso;
var conn = (CrmConnection)connMgr.AcquireConnection(null);
var orgService = (IOrganizationService)conn.GetCrmService(); // SOAP 2011
You would update your script to something as follows.
var connMgr = this.Connections.CrmConnectionManagerContoso;
var connectionString = (string)connMgr.AcquireConnection(null);
var conn = new CrmConnection(connectionString);
var orgService = (IOrganizationService)conn.GetCrmService(); // SOAP 2011
The main change is, the AcquireConnection method call now returns the connection string, instead of the CrmConnection. You would then construct the CrmConnection object using the connection string as the only parameter.

SSIS Script Task

Your original script might be something like this.
var conn = (CrmConnection)Dts.Connections["Contoso"].AcquireConnection(null);
var orgService = (IOrganizationService)conn.GetCrmService(); // SOAP 2011

You would update your script to something as follows.

var connectionString = (string)Dts.Connections["Contoso"].AcquireConnection(null);
var conn = new CrmConnection(connectionString);
var orgService = (IOrganizationService)conn.GetCrmService(); // SOAP 2011

To learn more about how to write a SSIS script component to consume CRM web services, please refer to my previous blog post which includes more detailed instructions that show how to do it in a step-by-step fashion.

I would like to thank you for choosing KingswaySoft as your data integration solution provider, we appreciate your continued support.

comments powered by Disqus