Getting started with MuleSoft - Hello Mule

getting-started-hello-mule
MuleSoft Logo
MuleSoft
Developer Relations
10 min read
Getting started with MuleSoft
max the mule

Welcome to MuleSoft, where you can deliver APIs and integrations at lightning speed. Do not worry if this is your first time using MuleSoft, this tutorial will walk you through step by step on how to develop, test, and deploy your first Mule Application in just a few minutes! Once your application is deployed, test your application using your favorite REST client by making a simple POST request to your hosted API on CloudHub.

Step 1: Start a free trial Anypoint Platform account

To deploy our first Mule Application, we are going to need an Anypoint Platform account to host our application on CloudHub. Click the Start Free Trial button below to get started and create a free Anypoint Platform account.

Step 2: Download Anypoint Studio for Windows, Mac, or Linux

Click the button below to download Anypoint Studio. Anypoint Studio enables you to start building APIs and integrations quickly with hundreds of pre-built connectors, templates, and examples. 

Download Anypoint Studio

Depending upon what system you are installing on, you may need to go through some troubleshooting steps to launch Anypoint Studio. Click on one of the resources below to get troubleshooting help.

Windows Setup Mac Setup Linux Setup
Step 3: Create a New Project

Upon opening Anypoint Studio, you will have to define your workspace. Your workspace is the location on your computer where your Anypoint Studio project files will be saved. Once you have defined your workspace and have launched Anypoint Studio, click on File then select New > Mule Project

Anypoint Studio will open the New Mule Project wizard. In the Project Name field, enter the value HelloMule, then click Finish.

hellomule

Anypoint Studio will open a new blank project. The following example below explains the different views you will use to build a Mule project:

anypoint-studio-screenshot
  • Package Explorer is where you can view your project structure (highlighted in red)
  • Properties Editor and Console are where you can configure attributes of connectors and few logs to catch any errors in your application (highlighted in blue). Add the Console to your view by going to Window -> Show View -> Console.
  • Mule Palette allows you to select from hundreds of prebuilt connectors from Exchange or the Core Connector components (highlighted in pink)
  • The Canvas allows you to drag and drop Connectors located in the Mule Palette to create a message Flow (highlighted in green)
hello-world-add-module

You can find the HTTP Connector by clicking on Add Modules, then dragging and dropping the HTTP Connector into your Mule Palette. This is how you add new Connectors to your Mule Project. If you click Search in Exchange, you can add any public asset available in the marketplace directly into your Mule Project.

Drag and drop an HTTP Listener from the Mule Palette to the canvas.

Anypoint Studio will automatically wrap the connector with a flow once you drag and drop it on the canvas. An HTTP Listener is an HTTP endpoint that listens for an HTTP request to come to the URL you define. When the Listener receives an HTTP request, the contents inside of the flow will execute in the order that you define. Yes, it's really that simple to create an API in Anypoint Studio! 

drag-and-drop

Next, click on the HTTP Connector, and in the Properties Editor below, click on the Green Plus button. The Green Plus button will create a configuration file under your Global Elements Configuration. Set the Host to: 0.0.0.0 and your Port to: 8081. Then click the OK button.

Then under the General > Path type in: /hellomule

configure http

The Path you define is going to represent the endpoint that will execute your flow when an HTTP request is made to your HTTP Listener. Now, drag the Set Payload Connector into your Flow. You can find the Set Payload Connector under Core in your Mule Palette. Uncheck the fx button and add the string: Hello Mule

hello-world-set-payload

Now go to File > Save to save your project, then right-click on your Canvas and click Run project hellomule to test it live!

run it

If you go into your Console view, you can check to see whether your application has successfully deployed. If it says DEPLOYED at the bottom right, then you are ready to use a REST Client to test your first Mule Application.

deploy-mule-application

Open up your REST Client of choice. There are plenty of options out there for you to use, you can download MuleSofts Advanced REST Client, or you can use the popular REST Client Postman.

Download Advanced REST Client Download Postman

Type in the URL of your HTTP endpoint and path added after the URL. For this demo, you will use the address:

http://0.0.0.0:8081/hellomule

Click the Send button and you should get Hello Mule as a 200 OK Response.

helloworld

Nice job! You have successfully deployed your first Mule Application locally and have gotten a response from your API. To stop the project from running locally, you can right-click again on the Canvas and click Stop project.

stop project
Step 4: Deploy to CloudHub

Now that you have learned how to deploy and test locally, let’s deploy our application to CloudHub. CloudHub will issue your application with a publicly accessible endpoint URL after you complete the deployment process. Right-click on your project in your Package Explorer, and click on Anypoint Platform > Deploy to CloudHub.

cloudhub

Choose the Sandbox environment then choose a unique name for your application. When your application name has a green check next to it, click the Deploy Application button. If your application has a red x next to it, it means someone else has deployed with that application name. It may take a few minutes to fully deploy to CloudHub.

deploying application

After you click Deploy Application, navigate to your web browser and log into Anypoint Platform.

Log in

Navigate to Runtime Manager and find your application. Copy and paste your application URL highlighted in blue below into your REST Client and add your Endpoint Path after the URL: /hellomule

runtime-managerpostman

When you send a POST request to your CloudHub endpoint, you should get Hello Mule as a 200 OK Response.

Congratulations on deploying your first Mule Application

You did it! You built your very first Mule application and deployed it to CloudHub in only a few minutes. You may have noticed that when you made a POST request, you are calling an HTTP endpoint, not HTTPS. Click the next button below to go to the next section where we will teach you how to configure HTTPS in your Mule Application. If you found this tutorial helpful, please give it a rating below.

Next Tutorial

Try Anypoint Platform for free

Start free trial

Already have an account? Sign in.

Related tutorials