BizTalk Server: Passing a message to BRE using call rules shape

Business Rule Engine is a powerful tool in BizTalk stack for creating, testing, publishing, and deploying rule sets for our Business process. I am going to demonstrate how to call a policy from an Orchestration using call rules shape using the message as the parameter.

Scenario

Suppose we receive a Customer details message which also contains the CustID. We'll check the CustID and see if the Customer is new or already a member. If the customer is new we'll set the **IsNew **field to YES.

Creating Facts

First of all, we'll start with creating FACTS in BizTalk Rule composer.

Open BizTalk Rule composer and go to Vocabularies and create a new Vocabulary and then create a new definition for XML Schema and select the schema created in the project. For CustID a get operation is created as follows: 

https://1.bp.blogspot.com/-jQknfpaT-1g/UQ6qcfLKcVI/AAAAAAAAANE/NprxaaaMck8/s400/BRE_GetCustID.png

For **IsNew **a set operation is performed as follows:

https://2.bp.blogspot.com/-ike4ocjpgcA/UQ6q24ctp1I/AAAAAAAAANM/UfmOvL9Vako/s400/BRE_SetIsNew.png

After creating the vocabularies publish the vocabularies so that it can be used to create a Policy. 

Next step is to create a Policy and a rule in BRE. It goes like this: 

https://1.bp.blogspot.com/-2WpGUGskD4w/UQ6rrqguzzI/AAAAAAAAANU/aFLMeLDSxtk/s400/Policy.png

This Policy is created such that any CustID greater than 21 would set the IsNew field to YES. This Policy will be called from the Orchestration using call rule shape.

Input Schema

https://1.bp.blogspot.com/-O9Ich9bEsro/UQ6j6j38PyI/AAAAAAAAAMs/-H7qKXk_lu0/s400/InputSchema.png

The input schema contains Customer details which contain fields CustID and IsNew.

Orchestration view

https://4.bp.blogspot.com/-uE3a2GPjxM8/UQ6k1Qr4FfI/AAAAAAAAAM0/CzG85Xvzs7c/s400/Orchestration1.png

The Orchestration contains a receive shape, send shape, logical receive port and send port. A message is created using InputSchema as the message type.

Call rules shape

https://3.bp.blogspot.com/-okx7ASSKbrA/UQ6mQYaIgKI/AAAAAAAAAM8/OsaOw3BygGQ/s400/Orchestration2.png

In call rules shape, the policy that we have created is selected and parameters will automatically be populated. In this case, Message_2 is shown. This whole message is passed to BRE and in return modified message is received.

Input Message

<ns0:Root xmlns:ns0="http://BRE_Samples.InputCustomer">
  <Customer>
    <FirstName>RAhul</FirstName>
    <LastName>Madaan</LastName>
    <CustID>23</CustID>
    <IsNew>IsNew_0</IsNew>
  </Customer>
</ns0:Root>

Output message

<?xml version="1.0" encoding="utf-8"?><ns0:Root xmlns:ns0="http://BRE_Samples.InputCustomer">
  <Customer>
    <FirstName>RAhul</FirstName>
    <LastName>Madaan</LastName>
    <CustID>23</CustID>
    <IsNew>YES</IsNew>
  </Customer>
</ns0:Root>

Call rule shape not any showing parameters ?? 

This problem is related to BRE facts that we had created. When developing facts we have to specify the DocumentType property of the fact. This property should be same as the fully qualified name of the schema otherwise, the call rule shape will not show any parameters. This issue is of call rule shape not finding the matching message to the schema which is deployed with the rule.

See Also

Read suggested related topics:

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