Contact Us 1-800-596-4880

HTTP Connector XML Reference

The HTTP connector listens for events or performs operations based on the HTTP or HTTPS protocol. Using the HTTPS protocol requires a TLS context child element in the configuration as shown in the next section. Mule 4.0 and later supports DataWeave syntax for accessing Listener and Request attributes. Mule continues to support the Mule Expression Language (MEL). Tables in this document map one syntax to the other.


The listener-config parent element organizes connection elements, such as the listen port and tls:context, inside a child listener-connection element. The connection element is a child of http:listener-config, as shown in the following code.

<http:listener-config name="lisConfig" basePath="api">
  <http:listener-connection protocol="https" port="${serverPort}" host="localhost" usePersistentConnections="true">
      <tls:key-store path="keystore.jks" keyPassword="key" password="pass"/>

The following code places an HTTP Listener in a flow:

<flow name="server">
  <http:listener path="test" allowedMethods="GET" config-ref="lisConfig"/>
  <logger message="HEY"/>

To access HTTP Listener attributes, use DataWeave syntax as shown in the following table.

HTTP object 3.x 4.x







Relative Path



Request URI



Query String



Query Parameters



URI Parameters












Remote Address



Client Certificate



HTTP Request

Consistent with the listener, the request-config parent element organizes connection elements of the request inside a child request-connection element, as shown in the following code.

<http:request-config name="reqConfig" basePath="api/v2">
  <http:request-connection protocol="HTTP" port="${clientPort}" host="localhost">
      <tls:trust-store path="ssltest-cacerts.jks" password="changeit"/>
      <http:basic-authentication username="#[user]" password="#[password]" preemptive="#[preemptive]" />

The following code places an HTTP request in a flow. The HTTP request returns HttpResponseAttributes.

<flow name="client">
   <http:request path="/" config-ref="reqConfig"/>

To access HTTP request attributes, use DataWeave syntax as shown in the following table:

HTTP object 3.x 4.x

Status Code



Reason Phrase






HTTP Request, Response, and Error Response Body

Defining the body of an HTTP request, response, and error response is optional. When you do not explicitly define the body element, the request or response returns the default payload.

The following example request defines a custom body, a key=value query parameter, an X-Custom header having custom as a value. The uriParamsMap variable populates the URI parameter uriParam.

<http:request path="/{uriParam}/test"  config-ref="reqConfig">
       #['Custom body']
       #[{'X-Custom' : 'custom'}]
       #[{'key’' : 'value’'}]

The following code lacks an explicitly defined body element. The returned value is the default payload. The payload defines a response to a successful execution that consists of a 200 status code and an Ok reason phrase with headers Name, with content as value, and with Something having a value of the someValue.

<http:listener path="test" allowedMethods="GET" config-ref="lisConfig">
   <http:response statusCode="200" reasonPhrase="Ok">
           #[{"Name" : "content", "Something" : someValue}]

The following code defines a response to an execution failure that returns a 502 status code and a Failure reason phrase with the header Error with FIRE as the value and Oops, something went terribly wrong as the body.

<http:listener path="test" allowedMethods="GET" config-ref="lisConfig">
   <http:error-response statusCode="502" reasonPhrase="Failure">
           #[‘Oops, something went terribly wrong.’]
           #[{"Error" : "FIRE"}]

HTTP Operations Reference

The following code shows the syntax of the load static resource operation:

<flow name="server">
   <http:listener path="test" allowedMethods="GET" config-ref="lisConfig"/>
   <http:load-static-resource resourceBasePath="root" defaultFile="index.html"/>

The following example shows the syntax of the basic security filter operation:

<flow name="listenerBasicAuth">
   <http:listener config-ref="listenerConfigBasicAuth" path="/basic"/>
   <http:basic-security-filter realm="mule-realm"/>
   <logger message="TestBasicAuthOk"/>
View on GitHub