Click here to Skip to main content
Click here to Skip to main content

Retrieve Multiple Dynamics CRM 2011 Entity Records from BizTalk 2010 Server

, 9 Jun 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
Dynamics CRM 2011 and BizTalk 2010 Server Integration - Retrieve Multiple Dynamics CRM 2011 Entity Records from BizTalk 2010 Server

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

  1. Create new map (MCRM_List.btm)
  2. Added <Fetch><Query/></Fetch> schema in the SAuditXML.xml schema
  3. Select Source Schema (SAuditXML), Destination Schema(DNS_BTS_CRM.organixationservice_schemas_microsoft_com_xrm_2011_contracts_services -> RetrieveMultiple)
  4. Make Query(source) link to FetchExpression->Query(Destination):

  5. 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.
  6. Build and Deploy the project
  7. Place the below xml in the 'c:\BTS\Audit\Query' folder, make sure your fetch xml query is string, so replace < and > with &lt; and &gt;
    <ns0:Audit xmlns:ns0="http://DNS_BTS_CRM.SFAXML">
      <Fetch>
        <Query>
            &lt;fetch version="1.0" output-format="xml-platform" mapping="logical" 
            distinct="false"&gt;
              &lt;entity name="dns_audit"&gt;
                 &lt;attribute name="dns_auditnumber" /&gt;
                 &lt;attribute name="dns_firstname" /&gt;
                &lt;attribute name="dns_lastname" /&gt;
                &lt;attribute name="dns_dateofbirth" /&gt;
                &lt;attribute name="dns_countyid" /&gt;
                &lt;attribute name="dns_matchstatus" /&gt;
                &lt;attribute name="dns_auditid" /&gt;
                &lt;order attribute="dns_lastname" descending="false" /&gt;
                &lt;filter type="and"&gt;
                  &lt;condition attribute="statecode" operator="eq" value="0" /&gt;
                  &lt;condition attribute="dns_matchstatus" operator="in"&gt;
                    &lt;value&gt;810520001&lt;/value&gt;
                    &lt;value&gt;810520002&lt;/value&gt;
                    &lt;value&gt;810520000&lt;/value&gt;
                  &lt;/condition&gt;
                &lt;/filter&gt;
              &lt;/entity&gt;
            &lt;/fetch&gt;
        </Query>
      </Fetch>
    </ns0:Audit>
  8. 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 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

mkader

United States United States
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141220.1 | Last Updated 9 Jun 2013
Article Copyright 2013 by mkader
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid