IBM App Connect Enterprise (ACE) - Developing a REST API Project

Yasothar Arulnayagam
4 min readJul 6, 2020

I’ve been a middleware developer for quite some time mostly working on WSO2 technology stack. Recently I moved to IBM stack (App Connect Enterprise, IBM MQ). Though the core concepts were same, IBM and WSO2 had their own wonderful ways of doing things. Both are enterprise
grade middleware and provide powerful ways of developing integration solutions. One thing I found lack in IBM was the resources
to tryout samples for self learning. Though IBM has a structured and organized documentation, during my self learning period I found fewer resources for IBM samples compared to WSO2. Hence my intention of writing this blog, not to just write about IBM ESB but to write about the interesting things I found in both technologies. I’ll begin with what I stared,
developing a simple REST API project using App Connect Enterprise (ACE). In this write up I’ll focus more on the development part rather than the installation and configuration which I’ll save it for a later write-up. To download and install ACE please refer this IBM link. Make sure you have the toolkit installed and ESB up and running before start working on this sample.

Use case

We are going to create a simple REST API that takes in three types of parameters Query, Path and Header, build a JSON response message comprising the values of these parameters and respond back to the caller. In the toolkit create a new REST API project providing the required details and a REST API description will appear.

The header section will have the base URL, we still don’t have any resources or models defined yet. Click on the (+) at the right corner of the resources to add resources.

I have given the resource name as params with a GET method and a path parameter name pathParameter. Once you click OK the the API decription will be updated as below.

As you can see the pathParam is non-editable. Defining the path parameter is the tricky part. Other parameters we can just add by clicking the (+) sign pertaining to the resources.

We are ready with the API description and now have to implement the API.

Click the ‘Create a subflow for the operation’ in the right corner which will create a subflow. Add a compute node to process the message.

Double click the compute node and open the ESQL. Add the following code.

SET OutputRoot = InputRoot;
SET OutputLocalEnvironment = InputLocalEnvironment;

SET OutputRoot.JSON.Data.pathParamValue = InputLocalEnvironment.REST.Input.Parameters.pathParam;
SET OutputRoot.JSON.Data.queryParamValue = InputLocalEnvironment.REST.Input.Parameters.queryParam;
SET OutputRoot.JSON.Data.headerParamValue = InputRoot.HTTPInputHeader.Headerparam;

First two lines copy the header and message information. Next three line build the JSON message based on the input values. Note that even though I have defined the header parameter value as headerParam when reading the value from the input I’m using Headerparam . This is some ACE internal mechanism (the name should start with a capital and be a single word) and needs to be carefully handled, though this link stackoverflow question discusses HTTP headers are case insensitive. Make sure you set the Compute Node property Compute Mode to LocalEnvironment and Message.

Once you are done with the implementation deploy it in a server and test it using a test tool. (I used Postman).

I have used 100, 200, 300 respectively for the path, query, header param values in the request and they are being sent back in the JSON message.

Conclusion

Just like any tool, creating a REST API project is simple and easy in IBM toolkit. Few things to take note here are setting the resource with path parameter and reading a header parameter.

--

--

Yasothar Arulnayagam

Integration developer, worked on WSO2, IBM integration stack. Java, Spring, Micro-services aficionado.