Introduction
Dynamics CRM 2011 and BizTalk 2010 Server Integration - Retrieve Multiple Dynamics CRM 2011 Entity Records from BizTalk 2010 Server using FetchXML
Background
There is no article about how to retrieve dynamics crm 2011 entity records from BizTalk 2010 server. Previous version of BizTalk/Dynamics CRM used adapter to send and receive the records.
Using the Code
Retrieve Multiple Dynamics CRM 2011 Entity Records from BizTalk 2010 Server
- Create new map (MCRM_List.btm)
- Added <Fetch><Query/></Fetch> schema in the SAuditXML.xml schema
- Select Source Schema (SAuditXML), Destination Schema(DNS_BTS_CRM.organixationservice_schemas_microsoft_com_xrm_2011_contracts_services -> RetrieveMultiple)
- Make Query(source) link to FetchExpression->Query(Destination):
- Create new orchestation (ListService)
Add 3 messages, MesList_Input(sAuditXML), MesList_CRMRequest(DNS_BTS_CRM.IOrganizationService_RetrieveMultiple_InputMessage), MesList_CRMResponse(DNS_BTS_CRM.IOrganizationService_RetrieveMultiple_OutputMessage)
Please read other steps from previous post. - Build and Deploy the project
- Place the below xml in the 'c:\BTS\Audit\Query' folder, make sure your fetch xml query is string, so replace < and > with < and >
<ns0:Audit xmlns:ns0="http://DNS_BTS_CRM.SFAXML">
<Fetch>
<Query>
<fetch version="1.0" output-format="xml-platform" mapping="logical"
distinct="false">
<entity name="dns_audit">
<attribute name="dns_auditnumber" />
<attribute name="dns_firstname" />
<attribute name="dns_lastname" />
<attribute name="dns_dateofbirth" />
<attribute name="dns_countyid" />
<attribute name="dns_matchstatus" />
<attribute name="dns_auditid" />
<order attribute="dns_lastname" descending="false" />
<filter type="and">
<condition attribute="statecode" operator="eq" value="0" />
<condition attribute="dns_matchstatus" operator="in">
<value>810520001</value>
<value>810520002</value>
<value>810520000</value>
</condition>
</filter>
</entity>
</fetch>
</Query>
</Fetch>
</ns0:Audit>
- You will get the response:
<RetrieveMultipleResponse>
<RetrieveMultipleResult>
<a:Entities>
<a:Entity>
<a:Attributes>
<a:KeyValuePairOfstringanyType><b:key>dns_firstname
</b:key><b:value i:type="c:string">First_0
</b:value></a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType><b:key>dns_countyid
</b:key><b:value i:type="a:EntityReference">
<a:Id>33294ecd-f4ed-e111-9564-0050568c5ad0</a:Id>
<a:LogicalName>dns_county</a:LogicalName>
<a:Name>KAYAL COUNTY</a:Name></b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType><b:key>dns_auditnumber
</b:key><b:value i:type="c:int">123456
</b:value></a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType><b:key>dns_matchstatus
</b:key><b:value i:type="a:OptionSetValue">
<a:Value>810520001</a:Value></b:value>
</a:KeyValuePairOfstringanyType>
<a:KeyValuePairOfstringanyType><b:key>dns_auditid
</b:key><b:value i:type="c:guid">
64b89301-f5ce-e211-bc9e-0050568c2ee8</b:value>
</a:KeyValuePairOfstringanyType>
</a:Attributes>
<a:EntityState i:nil="true"/>
<a:FormattedValues></a:FormattedValues>
<a:Id>64b89301-f5ce-e211-bc9e-0050568c2ee8</a:Id>
<a:LogicalName>dns_audit</a:LogicalName><a:RelatedEntities/>
</a:Entity>
<a:Entity></a:Entity>
<a:Entity></a:Entity>
<a:Entity></a:Entity>
<a:Entity></a:Entity>
</a:Entities>
</RetrieveMultipleResult>
</RetrieveMultipleResponse>
Points of Interest
Exception
The adapter failed to transmit message going to send port
"WcfSendPort_OrganizationService_CustomBinding_IOrganizationService_Custom"
with URL http://<CRM SERVER>/XRMServices/2011/Organization.svc.
It will be retransmitted after the retry interval specified for this Send Port.
Details:"System.ServiceModel.CommunicationException:
The maximum message size quota for incoming messages (65536) has been exceeded.
To increase the quota, use the MaxReceivedMessageSize property on the
appropriate binding element. ---> System.ServiceModel.QuotaExceededException:
The maximum message size quota for incoming messages (65536) has been exceeded.
To increase the quota, use the MaxReceivedMessageSize property
on the appropriate binding element.
Solution
Increase the macBufferSize
and maxReceivedMessageSize
size in the BizTalk Server Administration.
Goto BizTalk Server Administration Console:
Application -> [Project Name] -> Send Port ->
WcfSendPort_OrganizationService_CustomBinding_IOrganizationService_Custom ->
Configure -> Binding -> httpTransport ->
increase macBufferSize and maxReceivedMessageSize 65536 to 2147483647