This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.
Header Mediator
The Header Mediator sets or removes a specified header from the current soap info-set. At the moment, Header supports only simple-valued headers.
Syntax
<header name="qname" (value="literal" | expression="xpath") [action="set"]/> <header name="qname" action="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.
- Set
Remove
Tip
Default to Set.
- Value/Expression - A static value or an XPath expression that will be executed on the message to set the header value.
Tip
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.Â
Note
You can configure the Mediator using XML. Click on "switch to source view" in the "Mediator" window.
Example 1- Removing Reliable Messaging headers
<in> <RMSequence single="true" version="1.0"/> <send> <endpoint name="reliable"> <address uri="http://localhost:9000/services/ReliableStockQuoteService"> <enableRM/> <enableAddressing/> </address> </endpoint> </send> </in> <out> <header name="wsrm:SequenceAcknowledgement" action="remove" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm"/> <header name="wsrm:Sequence" action="remove" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm"/> <header name="wsrm:AckRequested" action="remove" xmlns:wsrm="http://schemas.xmlsoap.org/ws/2005/02/rm"/> <send/> </out>
The ESB receives an unreliable message and forwards it to an endpoint that supports Reliable Messaging. In this example, when the ESB receives a message, we send it using Reliable Messaging. So the response ESB receives Reliable Messaging headers. We don't want to send these headers to the client, who doesn't support Reliable Messaging. So we remove the Reliable Messaging headers before sending the response to the client.
Example 2 - Â Handling headers with complex XML
A header can contain XML structured values by embedding XML content within the <header>
 element as shown below.
<header> <m:complexHeader xmlns:m="http://org.synapse.example"> <property key="k1" value="v1" /> <property key="k2" value="v2" /> </m:complexHeader> </header>