Skip to content

Automatic Creation of Client Interfaces

Mike edited this page Jun 1, 2024 · 2 revisions

Automatic Creation of Client Interfaces

A decision is not very useful on its own. Something has to invoke it with appropriate data in order for it to produce a result that can be used. So even though the process of creating the decision is made easier by using decision tables, you often still need to write conventional code in java (or other languages) to invoke the decision.

Is there a way that this client code could be created automatically?

Yes, Of course!

The decision explicitly declares the inputs and outputs and so it should be possible to generate automatically code such as this:

        MediaType JSON = MediaType.parse("application/json; charset=utf-8");
        String json = "{\"name\": \"John\", \"age\": 30}";
        RequestBody body = RequestBody.create(json, JSON);
        Request postRequest = new Request.Builder()
                .url("http://localhost:8080/decision")
                .post(body)
                .build();
        Response response = client.newCall(postRequest).execute())
        System.out.println("POST Response: " + response.body().string());

Clone this wiki locally