This documentation is for WSO2 Enterprise Service Bus version 4.7.0 . View documentation for the latest release.
Skip to end of metadata
Go to start of metadata

The Header Mediator allows you to manipulate SOAP and HTTP headers.


<header name=”string” (value=”string|{property}” | expression=”xpath”) [scope=default|transport] [action=set|remove]/>

The optional action attribute specifies whether the mediator should set or remove the header. If omitted, it defaults to a set-header.

UI Configuration

Here are the option you have in configuring the Header Mediator:

  • Name - The name of the header element. You can declare the namespace used in the header element by clicking the Namespace link next to the text field.
  • Action -Specify whether you want to remove this header from the incoming message or set a new header.
  • Value/Expression - A static value or an XPath expression that will be executed on the message to set the header value.
  • Inline XML Header - Allows you to directly input any XML syntax related to the Header mediator, specifically for SOAP headers. For example, to achieve this configuration:
       <urn:lastTradeTimestamp xmlns:urn=" ">Mon May 13 13:52:17 IST 2013</urn:lastTradeTimestamp> 
    You would enter the lastTradeTimestamp element in the Inline XML Header field.
  • Scope - Specify Default to manipulate SOAP headers or specify Transport to manipulate HTTP headers.
  • Namespaces - You can click this link to add namespaces if you are providing an expression. You will be provided another panel named "Namespace Editor," where you can provide any number of namespace prefixes and URL that you have used in the XPath expression.


You can also configure the Mediator using XML. Click on "switch to source view" in the "Mediator" window.


This section covers the following scenarios in which the Header mediator can be used.

Example 1 -  SOAP headers

In the following example, the value for P1 code should be included in the SOAP header of the message sent from the client to the ESB. To do this, the header mediator is added to the in sequence of the proxy configuration as shown below. 

To get a response with Hello World in the SOAP header, the header mediator is also added to the out sequence.

             <p1:Code xmlns:p1="">XYZ</p1:Code>
              <address uri="http://localhost:8899/services/SimpleStockQuoteService?wsdl"/>
           <p2:Header xmlns:p2="">

Example 2 - HTTP headers

The following example makes the ESB add the HTTP header Accept with the value image/jpeg to the HTTP request made to the endpoint.

    <header name="Accept" value="image/jpeg" scope="transport"/>
        <endpoint name="people">
            <address uri="http://localhost:9763/people/eric+cooke" format="get"/>

Example 3 - Handling headers with complex XML

A header can contain XML structured values by embedding XML content within the <header> element as shown below.

	<m:complexHeader xmlns:m="http://org.synapse.example">
		<property key="k1" value="v1" />
		<property key="k2" value="v2" />
  • No labels