Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Header Mediator sets or removes a specified header from the current soap info-set. At the moment, Header supports only simple-valued headers.

...

Table of Contents
maxLevel3
minLevel3
styleborder:1
locationtop
typeflat
separatorpipe

...

Syntax

Code Block
XML
XML

<header name="qname" (value="literal" | expression="xpath") [action="set"]/>
<header name="qname" action="remove"/>

...

  • 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

      Info
      titleTip

      Default to Set.

  • Value/Expression - A static value or an XPath expression that will be executed on the message to set the header value.

...

Info
titleNote

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

...

Example 1- Removing Reliable Messaging headers

Code Block
XML
XML

<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.

Code Block
languagexml
<header>
	<m:complexHeader xmlns:m="http://org.synapse.example">
		<property key="k1" value="v1" />
		<property key="k2" value="v2" />
	</m:complexHeader>
</header>
Excerpt
hiddentrue

Description of the Header Mediator in WSO2 ESB.