BizTalk and CRM first AID – Ask to CRM

In these days I’m working around a integration solution, the topics are BizTalk + CRM + SAP + Axapta, last time I integrated CRM was in version 3.0.
the current CRM version is CRM 2011, I notice many good updates but there are stil some aspects to be considered to integrate CRM.
I want report/share the most important topics for a BizTalkers , as my reminder too :-), logically I assume that hte person reading this post has good BizTalk knowlegde.

The first, CRM exposes an ASMX layer to call his entities, and you can have two bound type, early-bound and late-bound, the choose depend from the type of project approach, performance requirement.
With late-bound you are more flexible and have more dymamic option but you have to consider many others aspect as implicit cast, performance, developer effort could be more, rather than early-bound, less developer effort but more strictly for aspects as solution architecture and developing aspects.
See more informations here
http://msdn.microsoft.com/en-us/library/gg509027.aspx under Use Early-Bound Types

just to start you can create a CRM query, in this sample I query one custom CRM entity (territory)

First get all CRM schemas, from project Add generated item-> Consume WCF Service, enter CRM ASMX url, usually http://CRMserver/MSCrmServices/2007/CrmService.asmx, use CrmService.BindingInfo.xml to binding your CRM send port (Import Bindings from BTS adm console)

At this point you can use many method to make a query, one using Retrieve/RetrieveResponse schema, to do this you must mapping the most important fields, see picture below

where EnityName is the name of CRM table, see picture below

in id you must write the CRM unique identifier CRM field, see picture below

Another method is with Fetch/FetchResponse schema, in this case you must put a query in XML format in FetchXML node, see picture below

One tip, write CRM query in fetch mode is not so simple, to do easly you can use one CRM tool, Advance Search see below

Create you CRM query, in this panel you can add columns and many other things

and use download fetch to have the CRM XML query

Create BizTalk port importing your binding file, in the most usually scenario you must use secutiry authentication, for example ntlm, see error below

The adapter failed to transmit message going to send port “WcfSendPort_CrmService_CrmServiceSoap12” with URL “http://CRMServer/MSCrmServices/2007/CrmService.asmx”. It will be retransmitted after the retry interval specified for this Send Port. Details:”System.ServiceModel.Security.MessageSecurityException: The HTTP request is unauthorized with client authentication scheme ‘Ntlm’. The authentication header received from the server was ‘Negotiate,NTLM’. —> System.Net.WebException: The remote server returned an error: (401) Unauthorized.

in this case you must set some more setting on your WCF-Custom port.

In Binding tab:


In Behavior tab:

If your CRM solution is in Multitenant you must specify the organization name too, to do this you must set WCF.OutboundCustomHeaders property of the message before send it, see below one sample

Message_Area(WCF.OutboundCustomHeaders) = “<headers><CrmAuthenticationToken xmlns=\”http://schemas.microsoft.com/crm/2007/WebServices\”><AuthenticationType xmlns=\”http://schemas.microsoft.com/crm/2007/CoreTypes\”>0</AuthenticationType><OrganizationName xmlns=\”http://schemas.microsoft.com/crm/2007/CoreTypes\”>PUT HERE YOUR ORGANIZATION NAME (EXAMPLE test or production or other)</OrganizationName><CallerId xmlns=\”http://schemas.microsoft.com/crm/2007/CoreTypes\”>00000000-0000-0000-0000-000000000000</CallerId></CrmAuthenticationToken></headers>”;

one frequent strange error during your integration mission is this general error:

Code 0x80040216 An unexpected error occurred.

many reasons can cause this error, but if your CRM ambient is correct the error is the using of wrong name for the entityname or fields

In next post I’ll explain the most important thing to create entity in CRM

more other nice resources here:

http://seroter.wordpress.com/2011/02/10/the-good-bad-and-ugly-of-integrating-dynamics-crm-2011-and-biztalk-server-2010/

http://seroter.wordpress.com/2011/05/20/creating-complex-records-in-dynamics-crm-2011-from-biztalk-server-2010/

http://blog.eldert.net/integrating-crm-2011-with-biztalk-2010-continued/

http://www.packtpub.com/article/integrating-biztalk-server-microsoft-dynamics-crm

Related blog posts