Vishal Modi

Architect

  Home  |   Contact  |   Syndication    |   Login
  45 Posts | 0 Stories | 95 Comments | 0 Trackbacks

News

Tag Cloud


Article Categories

Archives

Post Categories

Image Galleries

Blogs

Links

Tags

Monday, February 7, 2011 #

A few months ago myself and colleagues had open sourced the BizTalk Data Services. We were meanwhile working on other artifacts which comes along with BizTalk Server like the “Business Rules Engine”.  We are happy to announce the first version of BRE Data Services. BRE Data Services is a same concept which we covered through BTS Data Services, providing a RESTFul OData – based API to interact with the Business Rules Engine via HTTP using ATOM Publishing Protocol or JSON as the encoding mechanism.
 
In the first version release, we mainly focused on the browsing, querying and searching BRE artifacts via a RESTFul interface. Also along with that we provide the functionality to execute Business Rules by inserting the Facts for policies via the IUpdatable implementation of WCF Data Services.
 
The BRE Data Services API provides a lightweight interface for managing Business Rules Engine artifacts such as Policies, Rules, Vocabularies, Conditions, Actions, Facts etc. The following are some examples which details some of the available features in the current version of the API.
 
Basic Querying:
Querying BRE Policies
http://localhost/BREDataServices/BREMananagementService.svc/Policies
Querying BRE Rules
http://localhost/BREDataServices/BREMananagementService.svc/Rules
Querying BRE Vocabularies
http://localhost/BREDataServices/BREMananagementService.svc/Vocabularies
 
Navigation:
The BRE Data Services API also leverages WCF Data Services to enable navigation across related different BRE objects.
Querying a specific Policy
http://localhost/BREDataServices/BREMananagementService.svc/Policies(‘PolicyName’)
Querying a specific Rule
http://localhost/BREDataServices/BREMananagementService.svc/Rules(‘RuleName’)
Querying all Rules under a Policy
http://localhost/BREDataServices/BREMananagementService.svc/Policies('PolicyName')/Rules
Querying all Facts under a Policy
http://localhost/BREDataServices/BREMananagementService.svc/Policies('PolicyName')/Facts
Querying all Actions for a specific Rule
http://localhost/BREDataServices/BREMananagementService.svc/Rules('RuleName')/Actions
Querying all Conditions for a specific Rule
http://localhost/BREDataServices/BREMananagementService.svc/Rules('RuleName')/Actions
Querying a specific Vocabulary:
http://localhost/BREDataServices/BREMananagementService.svc/Vocabularies('VocabName')
 
Implementation:
With the BRE Data Services, we also provide the functionality of executing a particular policy via HTTP. There are couple of ways you can do that though the API.
 
Ø First is though Service Operations feature of WCF Data Services in which you can execute the Facts by passing them in the URL itself. This is a very simple implementations of the executing the policies due to the limitations & restrictions (only primitive types of input parameters which can be passed) currently of the Service Operations of the WCF Data Services. Below is a code sample. 

              Below is a traced Request/Response message.             
 
            
 
 
Ø Second is through the IUpdatable Interface of WCF Data Services. In this method, you can first query the rule which you want to execute and then inserts Facts for that particular Rules and finally when you perform the SaveChanges() call for the IUpdatable Interface API, it executes the policy with the facts which you inserted at runtime. Below is a sample of client side code. Due to the limitations of current version of WCF Data Services where there is no way you can return back the updates happening on the service side back to the client via the SaveChanges() method. Here we are executing the rule passing a serialized XML as Facts and there is no changes made to any data where we can query back to fetch the changes. This is overcome though the first way to executing the policies which is by executing it as a Service Operation call.
 
 
This actually generates a AtomPub message shown as below:
 
POST /Tellago.BRE.REST.ServiceHost/BREMananagementService.svc/$batch HTTP/1.1
User-Agent: Microsoft ADO.NET Data Services
DataServiceVersion: 1.0;NetFx
MaxDataServiceVersion: 2.0;NetFx
Accept: application/atom+xml,application/xml
Accept-Charset: UTF-8
Content-Type: multipart/mixed; boundary=batch_6b9a5ced-5ecb-4585-940a-9d5e704c28c7
Host: localhost:8080
Content-Length: 1481
Expect: 100-continue
 
--batch_6b9a5ced-5ecb-4585-940a-9d5e704c28c7
Content-Type: multipart/mixed; boundary=changeset_184a8c59-a714-4ba9-bb3d-889a88fe24bf
 
--changeset_184a8c59-a714-4ba9-bb3d-889a88fe24bf
Content-Type: application/http
Content-Transfer-Encoding: binary
 
MERGE http://localhost:8080/Tellago.BRE.REST.ServiceHost/BREMananagementService.svc/Facts('TestPolicy') HTTP/1.1
Content-ID: 4
Content-Type: application/atom+xml;type=entry
Content-Length: 927
 
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<entry xmlns:d="http://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata" xmlns="http://www.w3.org/2005/Atom">
  <category scheme="http://schemas.microsoft.com/ado/2007/08/dataservices/scheme" term="Tellago.BRE.REST.Resources.Fact" />
  <title />
  <author>
    <name />
  </author>
  <updated>2011-01-31T20:09:15.0023982Z</updated>
  <id>http://localhost:8080/Tellago.BRE.REST.ServiceHost/BREMananagementService.svc/Facts('TestPolicy')</id>
  <content type="application/xml">
    <m:properties>
      <d:FactInstance>&lt;ns0:LoanStatus xmlns:ns0="http://tellago.com"&gt;&lt;Age&gt;10&lt;/Age&gt;&lt;Status&gt;true&lt;/Status&gt;&lt;/ns0:LoanStatus&gt;</d:FactInstance>
      <d:FactType>TestSchema</d:FactType>
      <d:ID>TestPolicy</d:ID>
    </m:properties>
  </content>
</entry>
--changeset_184a8c59-a714-4ba9-bb3d-889a88fe24bf--
--batch_6b9a5ced-5ecb-4585-940a-9d5e704c28c7—
 
 
Installation:
The installation of the BRE Data Services is pretty straight forward.
·         Create a new IIS website say BREDataServices.
·         Download the SourceCode from TellagoCodeplex and copy the content from Tellago.BRE.REST.ServiceHost to the physical location of the above created website.
 
 

·         The appPool account running the website should have admin access to the BizTalkRuleEngineDb database.

·         TheRight click the BREManagementService.svc in the IIS ContentView for the website and wala..

 
 
Conclusion:
The BRE Data Services API is an experiment intended to bring the capabilities of RESTful/OData based services to the Traditional BTS/BRE Solutions. The future releases will target on technologies like BAM, ESB Toolkit.
This version has been tested with various version of BizTalk Server and we have uploaded the source code to our Tellago's DevLabs workspace at Codeplex. I hope you guys enjoy this release.
Keep an eye on our new releases @ Tellago Codeplex. We are working on various other Biztalk Artifacts like BAM, ESB Toolkit.
 
 
Till than happy BizzRuling…!!!
 
 
Thanks,
 
Vishal Mody