This application demonstrates a simple HTTP request-response activity. Mule 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 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 ESB’s graphical user interface (GUI). This document assumes that you are familiar with Mule ESB and the Anypoint Studio interface. To increase your familiarity with Mule Studio, consider completing one or more Anypoint Studio Tutorials.
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:
http://localhost:8081/helloWorld
- Press Enter to elicit a response from the application.
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.
Anypoint Studio includes a feature that enables you to easily export all the documentation you have recorded for your project. Whenever you want to share your project with others outside the Studio environment, you can export the project's documentation to print, email or share online. Studio's auto-generated documentation includes:
- A visual diagram of the flows in your application
- The XML configuration which corresponds to each flow in your application
- The text you entered in the Notes tab of any building block in your flow
Follow the procedure to export auto-generated Studio documentation.
- Learn more about configuring an HTTP Endpoint in Studio.
- Read about the concept of flows in Mule.