This tutorial will guide you through installing the right software to running your first MuleSoft application. Although my pictures show Mule 4 Runtime (the thing that runs the application), this tutorial is good for any version of Mule Runtime.
Download the Stuff
- Download Anypoint Studio IDE (this is where you will code): Although the website says something about a “trial for 30 days”, they mean Anypoint Platform (website where you can make and deploy API’s). But for just the IDE Anypoint Studio, downloading this 100% free forever.
- Download Postman (this is where you will get to interface with your code): Although Postman is also a website, the app is way better in my opinion.
- Download JDK 8 (Java Development Kit): development environment for building applications using Java.
Create Hello World Project
- Open your Anypoint Studio IDE and create a new Mule project by clicking at the top File -> New -> Mule Project
- Name your project firstproject (lowercase is the conventional syntax) and click Finish.
- Go to src/main/mule and open firstproject.xml
- See the Mule Palette on the right? Drag an HTTP listener onto the canvas. You will see a flow automatically get created named firstprojectFlow. Flows are analogous to functions in OOP.
- In the palette to the right, search for “Set Payload” and drag it to the right of the HTTP listener in the flow.
Configure The Connectors
- Double click on Set Payload, erase the Value written in, and make the Value this: Hello World!
- Now, click on the HTTP listener (we will create a configuration so it can accept HTTP requests from Postman later).
- At the bottom, click on the green plus sign next to Connector configuration, put the host as 0.0.0.0 and port as 8080, and click OK!
- Now, we need a path we want to channel our HTTP requests through. In the path field of the HTTP listener, type /path (the HTTP listener path will always tell you where the requests will go to)
- Save your application, right click on the canvas on a white space next to your flow, and run your project
Send Request and View Response
- Open Postman
- Leave everything as is but put this as the path: localhost:8080/path
- Click Send and you should see Hello World be the response!
You just created your first Hello World application! Basically, you create an HTTP Listener to listen for HTTP requests that we send through Postman. Since we did a GET request to the HTTP Listener, it “got” us the payload that was returned from the flow.
For extra help, check out the free course MuleSoft offers on https://training.mulesoft.com/course/mulesoftu-fundamentals