Tellago Devlabs: A RESTful API for BizTalk Server Business Rules

Tellago DevLabs keeps growing as the primary example of our commitment to open source! Today, we are very happy to announce the availability of the BizTalk Business Rules Data Service API which extends our existing BizTalk Data Services solution with an OData API for the BizTalk Server Business Rules engine. Tellago’s Vishal Mody led the implementation of this version of the API with some input from other members of our technical staff.

The motivation

The fundamental motivation behind the BRE Data Services API is to expose the capabilities of the BizTalk Server BRE engine in a highly interoperable RESTful service interface so that they can be accessible to applications developed in heterogeneous platforms such as J2EE, dynamic languages or even mobile application development frameworks.

Since its 2004 release, the BizTalk Server Business Rules has become of the unique and most popular technologies in the BizTalk Server ecosystem. Essentially, BizTalk BRE enables the modeling of Boolean expressions in a completely declarative model and stores them in a central repository so that they can be interpreted by other applications. In that sense, BRE is somewhat independent of BizTalk Server given that the business rules stored in BRE can be consumed by any .NET application. However, in the current version of BizTalk Server, developers will have to rely on BizTalk specific assemblies in order to interact with the BRE system. In order to overcome this limitation, we decided to implement a RESTful, OData-based API that exposes the entire BRE subsystems as simple resources accessible via HTTP.

The result

After debating a few options, we decide to rely on the current version of WCF Data Services and the OData protocol to surface the interactions with the BizTalk Server BRE engine. The result of this implementation is a ridiculous simple interface that allows developers to browse the entire BRE system using HTTP GETs based on the OData protocol as well as to execute policies using simple HTTP POSTs.

Here are a few examples extracted from our basic documentation:

The existing version of the API allows you to navigate the entire BRE systems using simple HTTP GETs.

Browsing BRE artifacts

Querying BRE Policies

http://<service endpoint>/BREDataServices/BREMananagementService.svc/Policies

Querying BRE Rules

http://<service endpoint>/BREDataServices/BREMananagementService.svc/Rules

Querying BRE Vocabularies

http://<service endpoint>/BREDataServices/BREMananagementService.svc/Vocabularies

Querying individual BRE resources

Querying a specific Policy

http://<service endpoint>/BREDataServices/BREMananagementService.svc/Policies(‘PolicyName’)

Querying a specific Rule

http://<service endpoint>/BREDataServices/BREMananagementService.svc/Rules(‘RuleName’)

Querying all Rules under a Policy

http://<service endpoint>/BREDataServices/BREMananagementService.svc/Policies('PolicyName')/Rules

Querying all Facts under a Policy

http://<service endpoint>/BREDataServices/BREMananagementService.svc/Policies('PolicyName')/Facts

Querying all Actions for a specific Rule

http://<service endpoint>/BREDataServices/BREMananagementService.svc/Rules('RuleName')/Actions

Querying all Conditions for a specific Rule

http://<service endpoint>/BREDataServices/BREMananagementService.svc/Rules('RuleName')/Actions

Querying a specific Vocabulary

http://<service endpoint>/BREDataServices/BREMananagementService.svc/Vocabularies('VocabName')

Executing a BizTalk Server Business Rule using HTTP

In addition to the enabling querying capabilities, this version of the BRE Data Services API also enables to execute rules by issuing a HTTP POST against a specific URL as specified in the following code:

Request:

POST /<service endpoint>/BREMananagementService.svc/ExecuteRuleAsSvcOperation?FactInstance='%3Cns0:LoanStatus%20xmlns:ns0=%22http://tellago.com%22%3E%3CAge%3E10%3C/Age%3E%3CStatus%3Etrue%3C/Status%3E%3C/ns0:LoanStatus%3E'&%20FactType='TestSchema'&PolicyName='TestPolicy' HTTP/1.1

Content-Type: application/xml

Host: localhost:8080

Content-Length: 0

Connection: Keep-Alive

Response:

HTTP/1.1 200 OK

Server: ASP.NET Development Server/10.0.0.0

Date: Tue, 08 Feb 2011 16:56:50 GMT

X-AspNet-Version: 4.0.30319

DataServiceVersion: 1.0;

Content-Length: 309

Cache-Control: no-cache

Content-Type: application/xml;charset=utf-8

Connection: Close

<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<ExecuteRuleAsSvcOperation xmlns="http://schemas.microsoft.com/ado/2007/08/dataservices">&lt;ns0:LoanStatus xmlns:ns0="http://tellago.com"&gt;&lt;Age&gt;10&lt;/Age&gt;&lt;Status&gt;false&lt;/Status&gt;&lt;/ns0:LoanStatus&gt;

</ExecuteRuleAsSvcOperation>

Using this capability now we can build applications that leverage BRE without the need of relying on specific BizTalk assemblies. Specifically, this approach opens the BizTalk BRE capabilities to applications built on heterogeneous platforms such as J2EE, dynamic languages such as Ruby or Python or mobile platforms such as Windows Phone 7 or Android.

I hope you truly enjoy this release of the BizTalk BRE Data Services API. We encourage you to download the bits, give it a try and drive us crazy with your feedback.

7 Comments

Comments have been disabled for this content.