Skip to content

14. Deploying and testing the Decision Service

With our decision model completed, we can now package our DMN model in a Deployment Unit (KJAR), deploy it on the Execution Server and test our decision.

14.1 Deploying the decision service

To deploy your business application, follow these steps:

  1. In the bread-crumb navigation in the upper-left corner, click on call-centre-decisions to go back to the project’s Library View.

  2. Click on the Deploy button in the upper-right corner of the screen. This will package our DMN mode in a Deployment Unit (KJAR) and deploy it onto the Execution Server (KIE-Server).

  3. Go to the Execution Servers perspective by clicking on "Menu → Deploy → Execution Servers". You will see the Deployment Unit deployed on the Execution Server.

14.2 Testing DMN Solution

In this section, you will test the DMN solution with Execution Server’s Swagger interface and via Java KIE Client API.

14.2.1 Testing the Decision Service via the REST API

The Swagger interface provides the description and documentation of the Execution Server’s RESTful API. At the same time, it allows the APIs to be called from the UI. This enables developers and users to quickly test a, in this case, a deployed DMN Service .

  1. Navigate to KIE Server swagger docs

  2. Locate the DMN Models section. The DMN API provides the DMN model as a RESTful resources, which accepts 2 operations:

    • GET: Retrieves the DMN model.

    • POST: Evaluates the decisions for a given input.

  3. Expand the GET operation by clicking on it.

  4. Click on the Try it out button.

  5. Set the containerId field to call-centre-decisions and set the Response content type to application/json and click on Execute DMN Swagger Get

  6. If requested, provide the username and password of your Business Central and KIE-Server user.

  7. The response will be the model-description of your DMN model.

14.3 Evaluate the Model

Next, we will evaluate our model with some input data. We need to provide our model with the incoming call, list of employees and office location.

  1. Expand the POST operation and click on the Try it out button

  2. Set the containerId field to call-centre-decisions. Set the Parameter content type and Response content type fields to application/json.

  3. Pass the following request to evaluate whether the given call is accepted by the call-centre.

    IMPORTANT: We’re explicitly specifying the decision-name of the decision we want to evaluate. If we would not specify this, the engine will evaluate the full model, and hence will also require us to pass the call input. When we only evaluate the Accept Call decision, we only need to specify the inputs of Accept Call. In the decision service invocation in the Accept Call logic, the input incoming call is passed to the call parameter of the decision service.

        "decision-name" : "Accept Call",
          "incoming call":{ 
              "phone": { 
                  "country prefix": "+420", 
                  "phone number": "1234" 
                "purpose": "help" 
          "employees": [{ 
              "name": "Duncan", 
              "office location": "Rome" 
          "office": { 
              "location": "Rome" 

    Click on Execute. The result value of the Accept Call should be true. Test the service with a number of other values. For example, specify a banned phone number like: +421 92000001

14.3.1 Using the KIE-Server Client

IBM Decision Manager provides a KIE-Server Client API that allows the user to interact with the KIE-Server from a Java client using a higher level API. It abstracts the data marshalling and unmarshalling and the creation and execution of the RESTful commands from the developer, allowing him/her to focus on developing business logic.

In this section we will create a simple Java client for our DMN model.

IMPORTANT: If your KIE Server is exposed via https you need to configure the ` the Java client code using the Remote Java API. If not, you may get arest.NoEndpointFoundException`. For more information check this solution Red Hat's knowledge base.

  1. Create a new Maven Java JAR project in your favourite IDE (e.g. IntelliJ, Eclipse, Visual Studio Code).

  2. Add the following dependency to your project:

  3. Create a Java package in your src/main/java folder with the name org.kie.dmn.lab.

  4. In the package you’ve just created, create a Java class called Main.

  5. Add a public static void main(String[] args) method to your main class.

  6. Before we implement our method, we first define a number of constants that we will need when implementing our method (note that the values of your constants can be different depending on your environment, model namespace, etc.):

    private static final String KIE_SERVER_URL = "http://localhost:8080/kie-server/services/rest/server"; 
    private static final String CONTAINER_ID = "call-centre-decisions"; 
    private static final String USERNAME = "bamAdmin"; 
    private static final String PASSWORD = "ibmpam1!"; 
    private static final String DMN_MODEL_NAMESPACE = "";
    private static final String DMN_MODEL_NAME = "call-centre";

    📘 INFO: If you're using the Linux environment on Skytap use the following.

    private static final String KIE_SERVER_URL = "http://localhost:8080/kie-server/services/rest/server"; 
    private static final String CONTAINER_ID = "call-centre-decisions"; 
    private static final String USERNAME = "pamadmin"; 
    private static final String PASSWORD = "pamadm1n"; 
    private static final String DMN_MODEL_NAMESPACE = "";
    private static final String DMN_MODEL_NAME = "call-centre";
  7. KIE-Server client API classes can mostly be retrieved from the KieServicesFactory class. We first need to create a KieServicesConfiguration instance that will hold our credentials and defines how we want our client to communicate with the server:

KieServicesConfiguration kieServicesConfig = KieServicesFactory.newRestConfiguration(KIE_SERVER_URL, new
EnteredCredentialsProvider(USERNAME, PASSWORD)); 
  1. Next, we create the KieServicesClient:

    KieServicesClient kieServicesClient = KieServicesFactory.newKieServicesClient(kieServicesConfig);
  2. From this client we retrieve our DMNServicesClient:

    DMNServicesClient dmnServicesClient = kieServicesClient.getServicesClient(DMNServicesClient.class);
  3. To pass the input values to our model to the Execution Server, we need to create a DMNContext:

    DMNContext dmnContext = dmnServicesClient.newContext(); 
  4. We pass the input variables to the DMNContext. We define the following three methods that create the data inputs:

    private static Map<String, Object> getIncomingCall() { 
      Map<String, Object> incomingCall = new HashMap<>(); 
      Map<String, Object> phone = new HashMap<>(); 
      phone.put("country prefix", "+420"); 
      phone.put("phone number", "1234"); 
      incomingCall.put("phone", phone); 
      incomingCall.put("purpose", "help"); return incomingCall; 
    private static List<Map<String, Object>> getEmployees() {
      List<Map<String,Object>> employees = new ArrayList<>();
      Map<String, Object> employee = new HashMap<>();
      employee.put("name", "Duncan");
      employee.put("office location", "Rome");
      return employees;
    private static Map<String, Object> getOffice() {
      Map<String, Object> office = new HashMap<>();
      office.put("location", "Rome");
      return office;
  5. We can now add the data to the DMNContext as follows:

    dmnContext.set("incoming call", getIncomingCall()); dmnContext.set("employees", getEmployees()); 
    dmnContext.set("office", getOffice()); 
  6. We now have defined all the required instances needed to send a DMN evaluation request to the server. We explicitly specify which decision we want to evaluate, in this case the Accept Call decision, by using the evaluateDecisionByName of the DMNServiceClient.

    ServiceResponse<DMNResult> dmnResultResponse = dmnServicesClient.evaluateDecisionByName(CONTAINER_ID, DMN_MODEL_NAMESPACE, DMN_MODEL_NAME, "Accept Call", dmnContext);
  7. Finally we can retrieve the DMN evaluation result and print it in the console:

    DMNDecisionResult decisionResult = dmnResultResponse.getResult().getDecisionResultByName("Accept Call"); 
    System.out.println("Is the call accepted?: " + decisionResult.getResult()); 
  8. Compile your project and run it. Observe the output in the console, which should say: Is the call accepted?: true

The complete project can be found here:

Last update: 2023-02-03