This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit

Content Filter

This section explains, through an example scenario, how the Content Filter EIP can be implemented using WSO2 ESB. The following topics are covered:

Introduction to Content Filter

The Content Filter EIP helps manage a large message when you are interested in a few data items only. It removes unimportant data items from a message and leaves only the important ones. In addition to removing data elements, Content Filter can be used to simplify a message structure. For more information, refer to

Figure 1: Content Filter EIP 

Example scenario

This example scenario explains how a message's content can be optimized to gain a more productive response. A client sends a stock quote request containing additional data that is not necessary for message processing. WSO2 ESB uses an XSLT mediator to restructure the request message and optimize it with only the required data before sending it to the Stock Quote service. This approach improves performance, as removing unnecessary bits of data makes the message more lightweight.

The diagram below depicts how to simulate the example scenario in WSO2 ESB.

Figure 2: Example Scenario of the Content Filter EIP

Before digging into implementation details, let's take a look at the relationship between the example scenario and the Content Filter EIP by comparing their core components.

Content Filter EIP (Figure 1)Content Filter Example Scenario (Figure 2)
Original MessageSimple Stock Quote Request from Client
Content FilterXSLT Mediator
Filtered MessageSimple Stock Quote Request from WSO2 ESB

Environment setup

  1. Download and install WSO2 ESB from For a list of prerequisites and step-by-step installation instructions, refer to Installation Guide in the WSO2 ESB documentation.
  2. Start the sample Axis2 server. For instructions, refer to the section Setting Up the ESB Samples - Starting the Axis2 server in the WSO2 ESB documentation.
  3. Save the following XSLT document as <ESB_HOME>/repository/samples/resources/transform/split_message.xslt.

    <?xml version="1.0" encoding="ISO-8859-1"?> 
    <xsl:stylesheet version="2.0"
                    exclude-result-prefixes="m0 fn"> 
        <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/> 
         <xsl:template match="/"> 
            <m:getQuote xmlns:m="http://services.samples"> 
                        <xsl:value-of select="//m0:getQuote/m0:request[1]"/> 

ESB configuration

Start the ESB server and log into its management console UI (https://localhost:9443/carbon). In the management console, navigate to the Main menu and click Source View in the Service Bus section. Next, copy and paste the following configuration, which helps you explore the example scenario, to the source view. 

<!-- Content Filter -->
<definitions xmlns="">
    <registry provider="org.wso2.carbon.mediation.registry.ESBRegistry">
        <parameter name="root">file:./repository/samples/resources/</parameter>
        <parameter name="cachableDuration">15000</parameter>
    <!-- define the request processing XSLT resource as a static URL source -->
    <localEntry key="filter_data" src="file:repository/samples/resources/transform/split_message.xslt"/>
      <proxy name="ContentFilterProxy">
             <xslt key="filter_data"/>
             <log level="full" />
                    <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> 
            <log level="full" />
                <send />
    <publishWSDL uri="file:repository/samples/resources/proxy/sample_proxy_1.wsdl"/>

Simulating the sample scenario

Send the following request to the ESB using a SOAP client like SoapUI.

<soapenv:Envelope xmlns:soapenv="" xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd">

When a request arrives to the ESB, it is first simplified to the following structure using the XSLT mediator. You can use TCPMon to observe this behavior.

<soapenv:Envelope xmlns:soapenv="" xmlns:ser="http://services.samples" xmlns:xsd="http://services.samples/xsd">

How the implementation works

Let's investigate the elements of the ESB configuration in detail. The line numbers below are mapped with the ESB configuration shown above.

  • localEntry [line 8 in ESB config] - Entry from the local registry
  • xslt [line 12 in ESB config] - The XSLT mediator applies an XSLT transformation to the selected element in the message specified using the source attribute. In this case, no source attribute is given, so the transformation will be applied to the first child element of the message.