This .NET Decision as a Service client library is an SDK for .NET applications to communicate with the Decision as a Service platform easily. This is very similar to the client library in Javascript as shown in a previous post.
As we discussed earlier, using a Decision as a Service platform allows you to simply share the decision module as REST API service. Remember, a decision module may have one or multiple different types of a business logic (i.e., Decision Table, decision flow, Decision Model and Notation (DMN), etc.)
Setup
Once you have installed the decision server, you will notice it comes with two client libraries. One is for Javascript clients and the other is for .Net applications.
In your application use NuGet and install the following two components:
1. Json.Net (from Newtonsoft.Json)
2. Microsoft.AspNet.WebAPi.Client
Client library
And finally, from where your server is installed, find FlexRule.Server.ClientLibrary and reference it into your project. This library provides a REST API Client for the Business Rule Server (Decision as a Service) out-of-the-box.
The rest is pretty similar to the Javascript library, so let's now create a simple form as shown below:
And on click event handler of your form just paste the code below:
ExecutionClient.Configuration.MasterServerAddress = "http://192.168.3.11:9000"; var token = ExecutionClient.AcquireToken("app1", "12345678901234567890123456789012"); var response = ExecutionClient.Run(new ExecutionRequest() { // Authentication token Token = token, // A correlation identifier for the request, so you know what requests were made for what reason // This can be deleted if you don't want to track requests. CorrelationId = "12345", // values for input parameters of decision Inputs = new Dictionary() { {"car", GetCar()} }, // Address of decision for execution Service = "Calculator", PackageVersion = "1", PackageName = "Car Insurance" // strategy to select a service within a package UseLatestVersion = true, }); if (!response.IsError) { var result = response.GetValue("car"); UpdateView(result); } else { MessageBox.Show(string.Format("Error {0}: {1}", response.MessageId, response.ErrorMessage)); }
By doing this, your application now connects to the server and returns the result back at the click of a button.
The source code for this application will also be installed on your system when you download and install FlexRule Server.
Read More
- .NET Decision as a Service – REST API Client for .Net
- JavaScript Decision as a Service – REST API Client for HTML/JS
Last updated September 22nd, 2020 at 11:31 am, Published August 10th, 2015 at 11:31 am
CEO and the founder of FlexRule – He is an expert in architecture, design, and implementation of operational decisions, business rules, and process automation. Created Decision-Centric Approach, a methodology that brings People, Data, Rules, and Processes together to automate operational business decisions.
This approach is recognized by Gartner as the missing link to provide business value to organizations.
[…] In the above model those two questions are in the left top corner. Decision as a Service platform allows you to host the entire above decision model (decision module) as a REST service. Then this business decision can be shared across all processes and applications in different technologies (i.e. JavaScript, .Net Framework…) […]