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: 

For IsNew a set operation is performed as follows:

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: 

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

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

Orchestration view

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

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.