Contact Free trial Login

HTTP Request-Response with Logger Example

Mule Runtime Engine versions 3.5, 3.6, and 3.7 reached End of Life on or before January 25, 2020. For more information, contact your Customer Success Manager to determine how you can migrate to the latest Mule version.

This example application illustrates how to use Mule ESB to build a simple HTTP request-response application. After reading this document, and creating and running the example in Mule, you should be able to leverage what you have learned to create a very simple HTTP request-response application.

Logging Activity

loggingThis example was designed to demonstrate interaction between an end user and Mule via an HTTP request, and Mule’s ability to log activity in the application.


This document describes the details of the example within the context of Anypoint Studio, Mule ESB’s graphical user interface (GUI). Where appropriate, the XML configuration accompanies the Studio interface screenshots. This document assumes that you are familiar with Mule ESB and the Anypoint Studio interface. To increase your familiarity with Anypoint Studio, consider completing one or more Anypoint Studio Tutorials.

Example Use Case

In this example, a user calls the Mule application by submitting a request via her browser (i.e. entering a specific URL, http://localhost:8084/echo). The application receives the request and returns the same payload, or "echoes", the response to the end user. In other words, when a user types http://localhost:8084/echo into the address bar of her browser, Mule returns a message in the browser that reads, /echo (see image below, left); if she enters http://localhost:8084/moon, Mule responds with /moon (below, right).


There are two functions the Echo example application illustrates:

  1. it receives HTTP requests and returns HTTP responses

  2. it logs the requests it receives

Set Up and Run the Example

As with other example templates, you can create template applications straight out of the box in Anypoint Studio or, in this case, also in Mule Standalone where this example is called echo. You can tweak the configurations of these use case-based examples to create your own customized applications in Mule.

Follow the procedure below to create, then run the HTTP Request-Response with Logger application.

  1. Create, then run the example application in Anypoint Studio or Standalone.

  2. Open your Web browser, type http://localhost:8084/echo in the address bar, then press enter.

  3. Your browser presents a message that reads, /echo.

  4. In your browser’s address bar, replace the word echo with the word moon, then press enter.

  5. Your browser presents a message that reads, /moon.

How it Works

The HTTP Request-Response with Logger example application consists of one, simple flow which receives end user HTTP requests, logs messages’ payloads, and returns the payloads to end users as HTTP responses.

The sections below elaborate further on the configurations of the application and how it works to respond to end user requests.


This flow makes use of three building blocks to receive, process and respond to an end user requests. When an end user request encounters the application, the first building block it meets is the request-response HTTP Inbound Endpoint. Because it has a two-way message exchange pattern, this HTTP endpoint is responsible for both receiving requests from, and send sending responses to, the end user.

Next, the flow uses a Logger Component to log the message payload in the application’s log files. The logger component uses a MEL Expression to determine what information in, or about, the message it should log. In this case, because it needs to log the message payload, the instructions to log read About to echo #[message.payload].

Studio Visual Editor


XML Editor or Standalone

<logger message="About to echo #[message.payload]" level="INFO" doc:name="Logger"/>

Finally, Mule moves the message to an Echo Component which simply returns the message payload as the response to an end user. In other words, the response echoes the request.

Full Code

Studio Visual Editor


XML Editor or Standalone

<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="" xmlns:core="" xmlns:doc="" xmlns:http="" xmlns:spring="" xmlns:xsi="" xsi:schemaLocation=" ">
    <flow doc:name="EchoFlow" name="EchoFlow">
        <http:inbound-endpoint doc:description="Process HTTP requests or responses." doc:name="HTTP" exchange-pattern="request-response" host="localhost" port="8084"/>
        <logger doc:name="Logger" level="INFO" message="About to echo #[message.payload]"/>
        <echo-component doc:name="Echo"/>

See Also

Was this article helpful?

💙 Thanks for your feedback!

Edit on GitHub