How to Create a Template Project With Anypoint Studio and Mulesoft Exchange

DZone 's Guide to

How to Create a Template Project With Anypoint Studio and Mulesoft Exchange

You write process APIs by making a template process API and template item in Mulesoft Exchange.

· Integration Zone ·
Free Resource

For a project, I needed to write a couple of process APIs. These process APIs all consist of an HTTP connector followed by a Choice element. In this Choice element, a specific HTTP request is made to a system API. The choice is made based on the following query param:

(#[message.inboundProperties.'http.query.params'.brand == 'xxx']

I decided to make a template process API and create a template item in the Exchange (only visible for my account). In this tutorial, I will show how I did it.

Create and Export the Template Project

Make a normal Mule project with the needed elements:

Image title

This Mule project will be used as a template for the other process APIs. Therefore, we need to download the project from Anypoint Studio as a ZIP file. This can be done by right-clicking on the project in the Package Explorer and then choose for Anypoint Studio Project to Mule Deployable Archive (includes Studio metadata).

Image title

Create an Exchange Template

To add the template to Exchange, you need to put the ZIP file you just have created in a place on the internet that's accessible to the public. This can be somewhere on your website, in Dropbox, or in Google Drive. I have made the choice to put on a website.

Image title

In the Exchange, you can add different kinds of items. In this case, we choose a template to add.

Image title

Now, you have to fill in some general details regarding the API.

Image title

At the bottom, you can choose how your template will be provided to the world of Mulesoft developers. Click on Add and you can add a ZIP file.

Image title

You have to fill in a version number and you can choose in which way your template is available. In this case, I have uploaded it to a website and entered the link to the template ZIP. Click on Done, and on the next screen, click on Save new item. Your template is ready to serve!

Use Your Template in Anypoint Studio

Once you have created your template in Exchange, you can use it in Anypoint Studio as a template for a new project.

Image title

The items from the Exchange are loaded and you can now see all public items in the Exchange. In the top-right corner, you can log in with your Anypoint Platform account to see your own templates.

On the right side, you can choose which content should be shown. Choose your company (in my case, NextSense) and you will see your recently added template.

Image title

Click on Open and a new project will be created in Anypoint Studio based on your template.

anypoint studio ,integration ,mulesoft ,templates

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}