Friday, January 27, 2012

Config-less WCF Service Endpoint Binding for CRM 2011 On-Premise

I previously blogged about how to consume CRM 2011 WCF Services through adding service reference in Visual Studio. Sometimes, there might be a need that you want to initialize the service in your code without the config file.

So here is the method that does this job for CRM 2011 on-premise deployment.

private static CustomBinding GetServiceEndpointBinding(string bindingName)
     var endpointBinding = new CustomBinding
                                   Name = bindingName

     // Configure security binding
     var securityElement = SecurityBindingElement.CreateSspiNegotiationBindingElement(true);
     securityElement.DefaultAlgorithmSuite = SecurityAlgorithmSuite.Default;
     securityElement.KeyEntropyMode = SecurityKeyEntropyMode.CombinedEntropy;
     securityElement.MessageSecurityVersion = MessageSecurityVersion.WSSecurity11WSTrustFebruary2005WSSecureConversationFebruary2005WSSecurityPolicy11BasicSecurityProfile10;
     securityElement.MessageProtectionOrder = MessageProtectionOrder.SignBeforeEncryptAndEncryptSignature;
     securityElement.SecurityHeaderLayout = SecurityHeaderLayout.Strict;
     securityElement.IncludeTimestamp = true;

     var messageEncoding = new TextMessageEncodingBindingElement();
     messageEncoding.ReaderQuotas.MaxStringContentLength = int.MaxValue;
     messageEncoding.ReaderQuotas.MaxArrayLength = int.MaxValue;
     messageEncoding.ReaderQuotas.MaxBytesPerRead = int.MaxValue;

     var transport = new HttpTransportBindingElement
                                   MaxBufferSize = int.MaxValue,
                                   MaxReceivedMessageSize = int.MaxValue

     // Add the SymmetricSecurityBindingElement to the BindingElementCollection.

     return endpointBinding;

To use the above method, you can wire it up like this.
 var endpoint = new EndpointAddress("http://CrmServerName/CrmOrgName/XRMServices/2011/Organization.svc");

 var endpointBinding = GetServiceEndpointBinding("CustomBinding_IOrganizationService");

 var organizationService = new OrganizationServiceClient(endpointBinding, endpoint);

 // Provide login credential, you should only need one of the following
 // If you are using integrated authentication
 organizationService.ChannelFactory.Credentials.Windows.ClientCredential = CredentialCache.DefaultNetworkCredentials;

 // if you are using named CRM account
 // organizationService.ClientCredentials.Windows.ClientCredential = new NetworkCredential("UserName", "Password", "Domain");

This is a by-product of my SSIS Integration Toolkit development effort. As you may or may not appreciate, I took me quite some hours to get to the point that the code works for CRM on-premise deployment.

It should be noted that the above snippet works only for CRM on-premise deployment. CRM online or CRM federated deployments have vastly different WCF bindings from on-premise, which require quite some extra effort in order to be able to connect successfully.

Considering the majority of CRM installation is on-premise deployment, I hope this post helps some people in the community who have the same needs.

Friday, January 20, 2012

Introducing SSIS Integration Toolkit for Microsoft Dynamics CRM

Today, I am happy to announce the availability of SSIS Integration Toolkit for Microsoft Dynamics CRM, an easy-to-use and cost-effective data integration library for Microsoft Dynamics CRM and Microsoft SQL Server Integration Services (SSIS).

First of all, this is a commercial offering, which we hope to bring a better solution to the market that can make your data integration job easier.

The toolkit is a set of SSIS adapters that allow you to read data from Microsoft Dynamics CRM server, or write data to it.

Among all the goodnesses, here are some highlighted features that you might be interested.
  • Native CRM 2011 SOAP interface support
  • Support for Microsoft Dynamics CRM 2011 and 4.0
  • Support for On-premise, IFD (federated) and Online deployments, including Office 365 (OSDP) environment
  • Support for CRM Entity or FetchXML query as data source in CRM source component
  • Support for Create/Update/Delete/Upsert actions in CRM destination component. When Upsert action is used, you have three matching options to choose to identify whether it is an existing record in CRM for update, or it's something not in the system that the component should create for you (insert). The three options include a combination of manually selected fields, CRM primary key, or CRM duplicate detection
  • One-click to toggle whether you want all or none of fields from a CRM entity in source component, which makes you more productive when selecting the only necessary fields to read data from CRM
  • Automatic mapping to the CRM fields in the destination component by matching the names from upstream components
  • You can set a picklist/optionset field value by either its integer value or its user friendly label
  • Native support of CRM many-to-many relationship to associate or disassociate CRM records in CRM destination component by using Create or Delete action
Here are some more details about the component along with some screen shots.

SSIS Integration Toolkit for Microsoft Dynamics CRM provides a cost-effective solution that helps integrate Microsoft Dynamics CRM with other data sources or applications.

SSIS Integration Toolkit takes advantage of the flexibility and power of Microsoft SQL Server Integration Services (SSIS) platform, which made it possible to integrate with virtually any application or data source that you may need to work with.

SSIS Integration Toolkit is extremely easy to use. It comes with the following three major components to help facilitate the integration development.
  • Microsoft Dynamics CRM Connection Manager
  • Microsoft Dynamics CRM Source Component
  • Microsoft Dynamics CRM Destination Component
The ultimate goal of the toolkit is to simplify the integration development work, so that you can spend more time focusing on resolving business issues. A data migration / integration development can be done as quickly as a few minutes, instead of weeks or months.

Microsoft Dynamics CRM Connection Manager

Microsoft Dynamics CRM Connection Manager allows you to setup a connection in SSIS so that it can used by Microsoft Dynamics CRM Source Component to retrieve data from Microsoft Dynamics CRM Server, or Microsoft Dynamics CRM Destination Component to write data to Microsoft Dynamics CRM server.

The connection manager offers the capability to connect to a Microsoft Dynamics CRM server which can be either version 2011 (including CRM Online) or 4.0. It supports both CRM 2011 SOAP endpoint and CRM SOAP 2007 Web Service interface.
Microsoft Dynamics CRM Connection Manager (TataSolutions SSIS Integration Toolkit)

CRM Connection Manager allows you to choose one of the following authentications based on how your CRM server is deployed or managed.
  • Active Directory (On-Premise)
  • Federated (On-Premise, Partner-hosted or Online Federation)
  • LiveId (CRM Online)
CRM Connection Manager - Authentication Type

Microsoft Dynamics CRM Source Component
Microsoft Dynamics CRM source component is a source component that you can use in SSIS data flow tasks, which allows you to read data from Microsoft Dynamics CRM Server.

Using Microsoft Dynamics CRM source component, you can pick a CRM entity to read data from, after a CRM connection has been chosen.
CRM Source Component - Entity.png

Microsoft Dynamics CRM source component also supports reading data from CRM server through using FetchXml queries.
CRM Source Component - FetchXml.png

When FetchXML option is used as the Source Type, CRM source component can intelligently identify all fields and corresponding metadata including the fields from linked entities.
CRM Source Component - FetchXml Columns

When Entity option is used as the Source Type, Microsoft Dynamics CRM Source Component allows you to select the CRM fields that you want to obtain data, which makes it easy when you have a large number of fields in CRM system, but you only need a small number of them to be used in the downstream pipeline components.
CRM Source Component - Choosing CRM Fields

Microsoft Dynamics CRM Destination Component

Microsoft Dynamics CRM destination component is a destination component that you can use in SSIS data flow tasks, so that you can write data to Microsoft Dynamics CRM Server.
Using Microsoft Dynamics CRM destination component, you can choose a CRM entity to write data to, and the action of such operation, which could be Create, Update, Delete or Upsert.
CRM Destination Component

CRM Destination Component can be smart enough to automatically map all available input columns from upstream components to corresponding CRM fields based on their names, and it also allows to change such mapping using a dropdown list.
CRM Destination Component - Column Mapping

CRM destination component supports CRM many-to-many relationship entities, in which case, you can use Create action to create associations, use Delete action to disassociate them.

CRM destination component supports upsert action, in which case, the component will first try to check if the provided CRM record exists in CRM system, the component will only create a new record if the matching record doesn't exist. If the component has identified any existing records based on the matching criteria provided, it will update the matching records.

CRM destination component's upsert action can use the following three matching criteria.
  1. Primary Key
  2. CRM Duplicate Detection
  3. Manually Specified Fields
CRM Destination Component - Upsert Action

For Create and Update action, CRM destination component allows you to choose "Enable CRM Duplication Detection" option.

When writing data to Microsoft Dynamics CRM, dealing with picklist / optionset imposes quite some challenges since CRM can only take integer numbers for them. Microsoft Dynamics CRM destination component has made this significantly easy, for any picklist / optionset fields (including statecode and statuscode fields), you can use either internal integer values, or their string values (user localized labels).

That's All
For more details about the offering, please proceed to my company's website at

Please give it a try, and let us know how it goes.

A free trial license can be requested after the installation using the accompanied License Manager program.

Hope you like this offering.

Sunday, January 01, 2012

Pass the Captcha Challenge of CRM Online Trial Request

This is a post that may not be technically interesting, but I thought I should share it in case you run into the same problem.

Yesterday, I was trying to sign up for a CRM online trial account, I was stunned to realize that I couldn't pass the eye test in the second step of the trial request.
I failed the eye exam miserably after many attempts including using the audio option.

The system I was using has an IE9 installed. 
I realized today this could possibly be a problem that happens to unique system environment, since it doesn't seem to be an often reported issue. The only report of this problem is a post on CRM forum, but nobody has ever responded since Nov 20, 2010. Based on the above speculation, I tried the same process on a computer with IE8 installed, and I was able to pass the eye test with my first try. 
I was relieved to realize that I was not visually blind or disabled, which I have been questioning myself ever since. PHEW!
I cannot explain the reason behind the problem, I have logged this as an issue on Microsoft connection site. If you get stuck with this issue, you may want to try a different system with an older version of IE installed. 
Hope this helps. 
Happy New Year, everyone!