Friday, 17 February 2017

FILE adapter: The Messaging Engine failed while notifying an adapter of its configuration

While using File Adapter to connect a file location (local or Network share) you may encounter errors like below:

" The Messaging Engine failed to add a receive location "Receive Location1" with URL "\\Server\Folder\File" to the adapter "FILE". Reason: "File transport does not have read/write privileges for receive location "\\Server\Folder\". "."

"File transport does not have read/write privileges for receive location "\\Server\Folder\"."

"The receive location "Receive Location1" with URL "\\Server\Folder\File" is shutting down. Details:"The Messaging Engine failed while notifying an adapter of its configuration. "."


Resolution:


1) Please double, triple check that the account which is used in the host instance has required permissions to access to folder location. In your case, permission for the host instance/service account seems to be the issue. Then if you're confident that service account has all the permission to access the folders. Then go to point 2.

2) Check if there is any network issue between your Biztalk server and file location. Get your network team involved and they can confirm this by opening a network trace.

3) IF you are confident that service account has all the permission to access the folders and you're also confident that their is no network issue between your Biztalk server (where the problematic host instance is configured) and file location.

Then another possible case is, number of received location bound to the problematic host instance. Can you check whether the host instance in question is bound to more than 50 Receive location. If so, then its worth checking the MaxCmds and MaxMpxCt registry values. Refer these articles:

Thursday, 16 February 2017

Issue while connecting On Premise BizTalk Server to Azure SQL DB

While trying to connect On-Promise BizTalk Server to Azure SQL database you may encounter an error message like below:

The adapter failed to transmit message going to send port "xxxxxxxxx" with URL "mssql://xxxxxxxxxxx". It will be retransmitted after the retry interval specified for this Send Port. Details:"System.ArgumentException: Value does not fall within the expected range.


Resolution:


Please make sure that on your WCF-Custom send port Transport Properties under Binding Tab you have the properties; EnableBizTalkCompatibilityMode set to true and AmbientTransaction setting set to false. The latter needs to be false as with true the local transaction will be escalated to Microsoft Distributed Coordinator (MSDTC).  According Handling Transactions in Windows Azure SQL Database written by Wayne Walter Berry:

Windows Azure SQL Database SQL Database does not support distributed transactions, which are transactions that multiple transaction managers (multiple resources). This means that Windows Azure SQL Database SQL doesn’t allow Microsoft Distributed Transaction Coordinator (MSDTC) to delegate distributed transaction handling. Because of this you can’t use ADO.NET or MSDTC to commit or rollback a single transaction that spans across multiple Windows Azure SQL Databases or a combination of Windows Azure SQL Database and an on-premise SQL Server.

Hope this helps!

Thursday, 26 January 2017

BIZTALK HEALTH MONITOR- A BizTalk Monitoring Tool



A quick and complete dashboard of a BizTalk group which will help BizTalk administrators monitor the health of the BizTalk platform

Standalone version of BHM can be downloaded from Microsoft Download Center here: BizTalk Health Monitor.

Register BizTalk Health Monitor Snap-In


After downloading and unzipping the BHM.ZIP file from the Microsoft Download Center, use the “InstallUtil.exe” which comes with BizTalk Health Monitor tool to register the BHM snap in.

Important: Unzip the BHM.ZIP to a final destination before you register the snap-in for example: C:\Program Files (x86)\Microsoft BizTalk Server 2010\SDK\Utilities\BHM. Once you register the BizTalk Health Monitor Snap-In you cannot delete the folder or BHM will stop working

To accomplished that we need to:
  • Open a command prompt as an administrator
  • Navigate to the directory file where you unzipped the BHM.ZIP file
    • For example: C:\Program Files (x86)\Microsoft BizTalk Server 2010\SDK\Utilities\BHM
  •  And from the command prompt type:
    •  InstallUtil.exe MBVSnapIn.dll
  •  And hit enter. This step will do some registry changes and register the SnapIn to be used.


Integrate BHM Snap-In into BizTalk Administration Console


BHM Snap-In can be used independently and need not to be integrated with BizTalk Administration Console. The handicap of this approach is that a BizTalk Administration will need to use two different places/tools to monitor and administrate the environment.

To be easier and more convenience for BizTalk Administrators BHM Snap-In can also be integrate it so that it can be used with BizTalk Administration Console.

To accomplished that we need to open a 32-bit Microsoft Management Console (MMC):

  • Click Start, click Run, type:
    • mmc /32
  • Press enter or click OK. This will open a new 32-bit version of MMC (MMC32).
  • From MMC console, go to File menu and select “Options…” option
    • In the text box, replace “Console1” for “BizTalk Administration Console”
    • In the Console mode combo box, select “User mode – full access”
    • And confirm that the option “Do not save changes to this console” is uncheck
                    
                    

  • From MMC console, go to File menu and select “Add/Remove Snap-in…” option
                    
  • From the “Add or Remove Snap-ins” window, add following snap-ins and then click Ok
    • Microsoft BizTalk Server Administration
    • BizTalk Health Monitor
                   

    • You can add the snap-ins by selecting them from the “Available snap-ins” list and click “Add >”
    • Is recommend that you respect the order present in the “Selected snap-ins” list as showed in the picture above

  • This will generate for us a new MMC which contains both the BizTalk Server Administration and BizTalk Health Monitor. And by now your new MMC is ready which shows both the BizTalk Server Administration and BizTalk Health Monitor
                    

Now to save this as a new .msc file so that you don’t have to repeat these steps again but before we complete the creation process of the “new” BizTalk Administration Console, I recommend that you navigate to the BizTalk Server Installation folder:

  • Example: C:\Program Files (x86)\Microsoft BizTalk Server 2010
  • And rename “BTSmmc.msc” file, for example: “BTSmmc-old.msc”
This because we will save the “new” BizTalk Administration Console as “BTSmmc.msc” so that you don’t need to create new shortcuts or having different ways to access the BizTalk Administration Console – however this step is optional!

To finished the creation process of the “new” BizTalk Administration Console

  • From MMC console, go to File menu and select “Save As…” option:
    • Give a name and then save it.
      • Access to BizTalk Server Installation folder
        • C:\Program Files (x86)\Microsoft BizTalk Server 2010
      • Save the file as “BTSmmc.msc”
From next time onwards, when you open the BizTalk Server Administration Console the “new” BizTalk Administration Console will be incorporated with the BizTalk Health Monitor

                     


Working of BizTalk Health Monitor:



Once a group node is added in the BHM hierarchy, you can start immediately to analyze its corresponding BizTalk group by right-clicking on the node and select the “Analyze now” menu item.
The analysis consists of running a number of queries to collect all important information of the BizTalk group, evaluating a set of rules for each of them, and raising any warnings (critical or not) if there is any.

                        


 Each time an analysis process is completed, a child node report is added in the group node. Each child report has further sub-nodes to present the collected information:

  •       Critical Warnings
  •        Warnings
  •       Summary
  •       Topology
  •       Queries

                           


This sub-nodes list details depends on the level of information you selected to display in BHM. The property page Information level of the group node settings allows you to select which sub-nodes you want to display for each generated report, and the level of information to collect during the analysis process (as shown below). The more queries you select to include in the analysis, the more information and potentially more warnings BHM will raise.

You can so customize as you want the level of information to analyse and display in BHM for each added group node.

                 

 

This is for example the output of the Topology sub-node:

                      



The output of the “Analyze Now” action will also generate a dashboard (as shown below) presenting a quick summary all the information you need to know about the BizTalk platform. We have categorized the information under different tiles as their names suggest. Each tile will be presented with a small icon on the bottom right of the tile which represents the overall health of that category. A green right mark shows that this category is healthy. A yellow exclamation sign represents some non-critical warnings whereas a red exclamation represents some critical warnings which need immediate attention. You can click on these tiles to get additional details on the lower pane.
 
                     



 A BizTalk platform processing messages 24x7 needs to be monitored at least daily. BHM provides you a way to create a scheduled task to automate a periodic collection of BHM report.
The property page Schedule of the group node settings provides an option to enable a scheduled analyze. This schedule task can be of course modified then in the Windows Task Scheduler.
 
                     




Receiving by mail the list of warning that MBV generates is a feature that has been demanded by lot of MBV users. We have incorporated this feature in BHM where you have an option to send the dashboard and the list of warnings to an email address after a fresh analysis.
BHM provides so an option to send automatically by mail the dashboard and the list of warnings after a fresh analysis. You can enable and configure this feature from the property page of the group node settings (select the “Settings” menu item when right clicking on a group node). An email will also be sent each time if you have scheduled the BHM report collection.
 We have also provided a Test button which you can use to test the SMTP settings you have entered. It will send a test email to make sure that SMPT settings are correct.
 
                    




 BizTalk provides a large number of performance counters to monitor like the state of the BizTalk databases, the BizTalk queues, the messaging and XLANG performances, the  throttling states, the adapters performances etc…There are various such counters available but they are less known and visible to the BizTalk administrators.
 BHM directly integrates Perfmon tool in its own MMC which provides a quick and easy way to monitor these counters. Furthermore, for each group node, BHM provides you a list of predefined views with pre-selected counters that you can quickly display at any time.
BHM will let you display either the current activity of the monitored BizTalk platform, or a recorded performance activity.


Current activity

When the current activity node is selected, you can choose a BizTalk server belonging to the monitored BizTalk group or any server you want. BHM provides default tabs in the current activity view with default counters but you can create your own tabs with your own counters  (right-click on tab to display the context-menu and create a new one).

                     




Recorded activity

BHM can also automate the recording of a perfmon activity for a given period. You can enable and configure this feature from the property page Recorded Performance activity of the group node settings (as show below).
BHM provides you a set of pre-defined scenarios with selected performance counters and you can choose the preferred scenario. You can also add your own counters if you chose the custom scenario option. The property page allows you to configure the sample interval and the duration of the recorded activity.


 
Once the recorded activity is configured, BHM can automate the creation, the start & stop of a performance log file corresponding to the selected scenario. When the recorded activity is completed, you can display it inside BHM by selecting the corresponding sub-node (as show below).

                     




BHM repository has a collection of almost 200 queries and now with v2 you have an option to build and add your own queries to this repository. The type of a custom query you can add are:
  •      WMI query
  •      VB Script
  •      PowerShell query
  •      Batch file (.bat)
  •      CMD

 Once a custom query is added in a profile, it will be saved in that profile and visible in the query tree view of the “Information Level” of the profile settings and can be checked or unchecked, like any native queries of BHM. And like any native BHM queries, a custom query can be pinned to a dashboard.

To add a custom query:

  •       Right click on the Profile select Settings.
  •      Select the “Queries” tab which also list all the BHM queries.
  •      Click on the button “New <query type>”
  •      Fill the query body in the new query Dialog Box and test your query
  •      Validate the query Dialog Box
  •      The query will be visible at that time in the tree view of the information level tab so that you can check it to include in the collect statement
  •      Validate the settings page to persist the custom query in your profile
You can of course edit or remove custom queries

                         


      Notes:

  •       Only WMI queries allow you to specify a target server; for the other types of query, execution will be local to the server running BHM.
  •       Only WMI queries will create columns in the query output; for the other types of query, the output will be on a unique columns named “Output” (this possibility exists in MBV engine used by BHM but not yet exposed)
  •       Each query of BHM can be quickly tested using the “Test” button in the tab “Queries”  



BHM engine has a repository of rules which are applied on its queries and are displayed in the report accordingly. Out of the box BHM comes up with around 450 rules which does various kind of checks on your BizTalk environment. And if that’s not enough BHM v2 will give you an option to write your own custom rules on existing or custom queries.
A Rule in BHM is a set of conditions (AND between the conditions) checking each row of a query output, and a set of triggered actions if all the conditions are validated. Each rule target a query and will be executed at the end of the query execution, parsing each row of the query output to validate the conditions.
A condition is composed of two fields to compare using a predicate. One field represent the column value to check for the current parsed row and the other field is the value to compare with. The predicate can be selected among a given list. You can add as many conditions as you want, and if all the conditions are validated for a parsed row then the rule will trigger some actions.

You can create three types of action:

ü  Add an entry in the summary or warnings sections  (if the information level field  is a warning)
ü  Add an entry in the topology section
ü  Spawn a process

Follow this to add a rule:

ü  Right click on the Profile and select settings.
ü  Select the tab “Rules” listing all the BHM rules and their source query.
ü  Click on the button “Add custom rule”
ü  Select the target query, click ok.
ü  Fill the rule properties, conditions and actions in the rule Dialog Box
ü  Test your rule : an HTML view will be displayed with the query output and the Summary & warnings sections
ü  Validate that the rule is added to the rules list view
ü  Validate at the settings page that the rule is persisted as a custom rule in your profile

You can of course edit or remove custom rules

                    
 



Notes:

Ø  You can also add a rule by right clicking on a query in the queries output node
Ø  To help you creating your own rule, we recommend to look at the details of existing native rules of BHM :
For example select any rule targeting the query “BizTalk events in last hours” and then click on the button “Show Rule details”. You can then select each condition and actions of the rules and see their details.
Ø  Some rules of BHM will not display conditions because they are coded in a custom assembly.
Ø  Because of only AND logic between the conditions and of the limited number of predicates available, complex custom rule cannot be created using the rule Dialog Box.

MBV engine used by BHM allows to create complex rules in custom assemblies but this feature is not yet exposed in BHM.

References

Sunday, 23 October 2016

BizTalk Server - Dynamics CRM Online / On Premise CRM Paging Cookie


Problem Scenario

·          While communicating with CRM Entities using Retrieve Multiple operation using request response pattern there  are some scenarios where you need to process bulk request queries like using pattern matching Contains Data,  Not null, etc.

       These query results bulk data to BizTalk as a response in XML Format with all the details.  

        Scenario 1: Assume you need to process 10,000 records by interacting with CRM.
             OR
        Scenario 2: Single fetch Query, Expression can get you up to 5,000 records.

       Handling these huge file in BizTalk at once could result in performance impact. Now think of scenario when  you have to process multiples request of such huge records. 5000 records XML data can be up to 500 MB plus,  depending on the data you retrieve like column / attributes.

Solution


·         In such scenario using the below pattern will help you to process the limited records with multiple calls without overloading BizTalk with huge data.

·         There are multiple ways with which you can query CRM
  1. Retrieve Operation
  2. Retrieve Multiple Operation

·         Some Points one needs to consider when using Retrieve, Retrieve Multiple Operation for retrieving data from CRM.


         Retrieve Operation


  •           Retrieves Only one record using the parameters like Entity Name, GUID, Columns of the record.
  •           Using this we cannot retrieve multiple records or related data.
  •          This will not support for using where clauses.     
  •           Where there is a scenario to retrieve single record, with known GUID we could use this approach.




                                                               Fig – Retrieve Operation

The below request will return you all the column for the GUID matching record.

 <Retrieve xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">  
      <entityName>account</entityName>  
      <id>1D30CA6E-E355-E511-80F2-C4346BC5A780</id>  
      <columnSet xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">  
       <b:AllColumns>true</b:AllColumns>  
       <b:Columns xmlns:c="http://schemas.microsoft.com/2003/10/Serialization/Arrays">  
         <c:string>name</c:string>  
       </b:Columns>  
      </columnSet>  
   </Retrieve>  

                                                                  Sample XML Retrieve Request

Retrieve Multiple Operation


  • Retrieve Multiple supports many other options / several overloads like QueryExpressionFetchExpression,QueryByAttribute.
  • We can use this operation to retrieve multiple, related entity records in a single request using where clauses, with many other parameters filtering options.
  • However, it has some limitation like single Retrieve Multiple Request can get you some limited records up to 5000, this is configurable in CRM On premise but not in Online.





                                              Fig – Retrieve Multiple Operation

Sample Retrieve Multiple Request from BizTalk to CRM in two formats FetchExpression, QueryExpression for the same query.

      The below sample basic query will return all the entity records with all the columns / attributes specified, maximum entity records can be 5000 as it’s a limit at CRM.

 <RetrieveMultiple xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:ns2="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:ns0="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:ns3="http://schemas.microsoft.com/xrm/2011/Metadata" xmlns:ns5="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:ns1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" xmlns:ns4="http://schemas.microsoft.com/xrm/2011/Contracts">  
      <query i:type="b:FetchExpression" xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">  
       <b:Query>  
       &lt;fetch version=&quot;1.0&quot; output-format=&quot;xml-platform&quot; mapping=&quot;logical&quot; distinct=&quot;false&quot; &gt;  
      &lt;entity name=&quot;sms_registrationpage&quot;&gt;  
      &lt;attribute name=&quot;sms_registrationpageid&quot; /&gt;  
      &lt;attribute name=&quot;sms_firstname&quot; /&gt;  
      &lt;attribute name=&quot;sms_mobile&quot; /&gt;  
      &lt;attribute name=&quot;sms_lastname&quot; /&gt;  
      &lt;attribute name=&quot;sms_ismarried&quot; /&gt;  
      &lt;attribute name=&quot;sms_gender&quot; /&gt;  
      &lt;attribute name=&quot;sms_emailid&quot; /&gt;  
      &lt;attribute name=&quot;sms_country&quot; /&gt;  
      &lt;attribute name=&quot;sms_age&quot; /&gt;  
      &lt;order attribute=&quot;sms_firstname&quot; descending=&quot;false&quot; /&gt;  
      &lt;/entity&gt;  
      &lt;/fetch&gt;  
       </b:Query>  
      </query>  
    </RetrieveMultiple>  

                             Fig- Retrieve Multiple Using FetchExpression

 <RetrieveMultiple xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:ns2="http://schemas.microsoft.com/2003/10/Serialization/Arrays" xmlns:ns0="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:ns3="http://schemas.microsoft.com/xrm/2011/Metadata" xmlns:ns5="http://schemas.microsoft.com/2003/10/Serialization/" xmlns:ns1="http://schemas.datacontract.org/2004/07/System.Collections.Generic" xmlns:ns4="http://schemas.microsoft.com/xrm/2011/Contracts">  
      <query i:type="b:QueryExpression" xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">  
       <b:ColumnSet>  
         <b:AllColumns>false</b:AllColumns>  
         <b:Columns xmlns:e="http://schemas.microsoft.com/2003/10/Serialization/Arrays">  
          <e:string>sms_registrationpageid</e:string>  
          <e:string>sms_firstname</e:string>  
          <e:string>sms_mobile</e:string>  
          <e:string>sms_lastname</e:string>  
          <e:string>sms_ismarried</e:string>  
          <e:string>sms_gender</e:string>  
          <e:string>sms_emailid</e:string>  
          <e:string>sms_country</e:string>  
          <e:string>sms_age</e:string>  
         </b:Columns>  
       </b:ColumnSet>  
       <b:Criteria>  
         <b:Conditions/>  
         <b:FilterOperator>And</b:FilterOperator>  
         <b:Filters/>  
       </b:Criteria>  
       <b:Distinct>false</b:Distinct>  
       <b:EntityName>sms_registrationpage</b:EntityName>  
       <b:LinkEntities/>  
       <b:Orders>  
         <b:OrderExpression>  
          <b:AttributeName>sms_firstname</b:AttributeName>  
          <b:OrderType>Ascending</b:OrderType>  
         </b:OrderExpression>  
       </b:Orders>  
       <b:PageInfo>  
         <b:Count>0</b:Count>  
         <b:PageNumber>1</b:PageNumber>  
         <b:PagingCookie i:nil="true"/>  
         <b:ReturnTotalRecordCount>false</b:ReturnTotalRecordCount>  
       </b:PageInfo>  
       <b:NoLock>false</b:NoLock>  
      </query>  
    </RetrieveMultiple>  

                             Fig- Retrieve Multiple Request Using QueryExpression

        

       CRM Paging Cookie


There can be some scenario where you need to query the CRM records and process the response data records in set of records. You can use the paging cookie feature to make paging in an application faster for large datasets. When you use the paging cookie feature when querying a set of records, the result contains a value for the paging cookie. To improve system performance, you can then pass that value when you retrieve the next set of records. 

  Scenario 1:

Assume that an entity has 10,000 records and BizTalk has to query to get those records and process individual records within a loop. Here we know that CRM will return maximum of 5000 records in single response. In this case we can split it up with two requests, set 1st to get 1st 5000, 2nd set to get next another 5000 records and then process them in BizTalk. The downside here will be that file with 5000 records will be size approx 300 – 500 MB depending on the attributes selections.


Scenario 2:

Assume, an entity has 10,000 records, BizTalk has to process them individually. Here the requirement is to query a set of 1000 records at a time, process them in BizTalk and then go for next set of batch of records and so on. So BizTalk has to query CRM 10 times to get 1000 records every time to process 10,000 records. Going with this approach there will be less load in BizTalk as we restricted the batch size.

The approach discussed in Scenario 2 is more performance oriented and yield better results.



Demo


                                                          Fig – CRM Entity Records total 4 records.


·         Page Cookie using FetchExpression



                                                                              Fig – Mapping to FetchExpression

  
 <xsl:template name="FetchExpression">  
   <xsl:param name="Count" />  
   <xsl:param name="pageIndex"/>  
   <xsl:param name="pageCookie" />  
   <RetrieveMultiple xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">  
    <query i:type="b:FetchExpression" xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">  
     <b:Query>  
      &lt;fetch version=&quot;1.0&quot; output-format=&quot;xml-platform&quot; mapping=&quot;logical&quot; distinct=&quot;false&quot; count=&quot;<xsl:value-of select="$Count"/>&quot; <xsl:if test="$pageIndex">  
       page="<xsl:value-of select="$pageIndex"/>"  
      </xsl:if> <xsl:if test="$pageCookie">  
       paging-cookie="<xsl:value-of select="$pageCookie"/>"  
      </xsl:if> &gt;  
      &lt;entity name=&quot;sms_registrationpage&quot;&gt;  
      &lt;attribute name=&quot;sms_registrationpageid&quot; /&gt;  
      &lt;attribute name=&quot;sms_firstname&quot; /&gt;  
      &lt;attribute name=&quot;sms_mobile&quot; /&gt;  
      &lt;attribute name=&quot;sms_lastname&quot; /&gt;  
      &lt;attribute name=&quot;sms_ismarried&quot; /&gt;  
      &lt;attribute name=&quot;sms_gender&quot; /&gt;  
      &lt;attribute name=&quot;sms_emailid&quot; /&gt;  
      &lt;attribute name=&quot;sms_country&quot; /&gt;  
      &lt;attribute name=&quot;sms_age&quot; /&gt;  
      &lt;order attribute=&quot;sms_firstname&quot; descending=&quot;false&quot; /&gt;  
      &lt;/entity&gt;  
      &lt;/fetch&gt;  
     </b:Query>  
    </query>  
   </RetrieveMultiple  
 </xsl:template>  


                                               Fig – XSLT Used in Scripting




Fig – End to End Output FetchExpression Request, Response with Count Set to 2





·         Using Page Cookie using QueryExpression



Fig – Mapping to QueryExpression Request, Response with Count Set to 2


 <xsl:template name="QueryExpression">  
   <xsl:param name="Count" />  
   <xsl:param name="pageIndex"/>  
   <xsl:param name="pageCookie" />  
   <RetrieveMultiple xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services">  
    <query i:type="b:QueryExpression" xmlns:b="http://schemas.microsoft.com/xrm/2011/Contracts" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">  
     <b:ColumnSet>  
      <b:AllColumns>false</b:AllColumns>  
      <b:Columns xmlns:e="http://schemas.microsoft.com/2003/10/Serialization/Arrays">  
       <e:string>sms_registrationpageid</e:string>  
       <e:string>sms_firstname</e:string>  
       <e:string>sms_mobile</e:string>  
       <e:string>sms_lastname</e:string>  
       <e:string>sms_ismarried</e:string>  
       <e:string>sms_gender</e:string>  
       <e:string>sms_emailid</e:string>  
       <e:string>sms_country</e:string>  
       <e:string>sms_age</e:string>  
      </b:Columns>  
     </b:ColumnSet>  
     <b:Criteria>  
      <b:Conditions/>  
      <b:FilterOperator>And</b:FilterOperator>  
      <b:Filters/>  
     </b:Criteria>  
     <b:Distinct>false</b:Distinct>  
     <b:EntityName>sms_registrationpage</b:EntityName>  
     <b:LinkEntities/>  
     <b:Orders>  
      <b:OrderExpression>  
       <b:AttributeName>sms_firstname</b:AttributeName>  
       <b:OrderType>Ascending</b:OrderType>  
      </b:OrderExpression>  
     </b:Orders>  
     <b:PageInfo>  
      <xsl:choose>  
       <xsl:when test="$Count">  
        <b:Count>  
         <xsl:value-of select="$Count"/>  
        </b:Count>  
       </xsl:when>  
       <xsl:otherwise>  
        <b:Count>0</b:Count>  
       </xsl:otherwise>  
      </xsl:choose>  
      <xsl:choose>  
       <xsl:when test="$pageIndex">  
        <b:PageNumber>  
         <xsl:value-of select="$pageIndex"/>  
        </b:PageNumber>  
       </xsl:when>  
       <xsl:otherwise>  
        <b:PageNumber>0</b:PageNumber>  
       </xsl:otherwise>  
      </xsl:choose>  
      <xsl:choose>  
       <xsl:when test="$pageCookie">  
        <b:PagingCookie>  
         <xsl:value-of select="$pageCookie"/>  
        </b:PagingCookie>  
       </xsl:when>  
       <xsl:otherwise>  
        <b:PagingCookie i:nil="true"/>  
       </xsl:otherwise>  
      </xsl:choose>  
      <b:ReturnTotalRecordCount>false</b:ReturnTotalRecordCount>  
     </b:PageInfo>  
     <b:NoLock>false</b:NoLock>  
    </query>  
   </RetrieveMultiple>  
  </xsl:template>  

                                              Fig – XSLT Used in Scripting



Fig – End to End Output QueryExpression Request, Response with Count Set to 2


            


MSDN Sample Using C#


Sample: Use QueryExpression with a paging cookie: https://msdn.microsoft.com/en-in/library/mt269606.aspx 


Sample: Use FetchXML with a paging cookie: https://msdn.microsoft.com/en-us/library/gg328046.aspx 

Building the Sample


Follow the below-detailed steps to Run the below sample.
  •  It has some pre requisites if you are checking this article for the 1st time, Refer the below see also sections articles for related BizTalk artifacts for more details to run this sample End to End.
  • To download the sample BizTalk Application for using Dynamics CRM Online / On Premise CRM Paging Cookie, Refer here MSDN Code Samples  
  •  Zip File Includes: BizTalk Sample Solution, Application Port Bindings, Sample Retrieve Multiple Request, Response files for FetchExpression, QueryExpression.


 


Conclusion


·         In this article you have learn on how to utilize the CRM Online / On premise Paging, Paging Cookie features.
·         Using this technique , you can minimize the load on BizTalk, when you are working with bulk data processing as Retrieve Response.
·         You could choose which query expression you wish to go with depending on the scenarios, both are similar the way we write expression is difference.

     See Also



      Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki