This application demonstrates a simple HTTP request-response flow. It responds to end user calls submitted via a Web browser with a message that reads "Hello World". This example was designed to demonstrate the ability of a Mule application to interact with an end user via an HTTP request. The goal in making it available is to introduce users to Anypoint Studio by illustrating very simple functionality.
This document describes the details of the example within the context of Anypoint™ Studio, Mule Runtime's graphical user interface (GUI).
Set Up and Run the Example
Follow the steps in this procedure to create and run this example in your own instance of Anypoint Studio. You can create template applications straight out of the box in Anypoint Studio and tweak the configurations of the use case-based templates to create your own customized applications in Mule.
- Open the "Hello World" example project in Anypoint Studio from Anypoint Exchange.
- In your application in Studio, click the Global Elements tab. Double-click the HTTP Listener global element to open its Global Element Properties panel. Change the contents of the port field to the required HTTP port (e.g., 8081).
- In the Package Explorer pane in Studio, right-click the project name, then select Run As > Mule Application. Studio runs the application and Mule is up and kicking!
- Open your Web browser.
- In the address bar, type the following URL:
- Press Enter to elicit a response from the application.
How it Works
The Hello World example consists of one simple Mule flow. This flow accepts an HTTP request, sets a static payload on the message, then returns a response to the end user.
The request-response inbound HTTP endpoint receives requests the end user submits to the Web service. Because the message-exchange pattern is request-response, this HTTP endpoint is responsible for both receiving and returning messages. The descriptive notes included in the configuration of the endpoint can help you understand the actions the endpoint performs.
As its name suggests, the Set Payload component sets a value in the message payload. In this example, the value utilizes a Mule expression to set a static string on the payload. Like the HTTP endpoint, the configuration contains descriptive notes to help you understand what the component does.