This documentation is for WSO2 Enterprise Service Bus version 5.0.0. For the latest ESB, view the latest WSO2 Enterprise Integrator documentation.

All docs This doc
Skip to end of metadata
Go to start of metadata

Objective: Demonstrate the ability of the URL Rewrite mediator to perform rewrites based on multiple rules.

<definitions xmlns="">

    <sequence name="main">
            <property name="http.port" value="9000"/>
            <property name="https.port" value="9002"/>
                    <action fragment="host" value="localhost"/>
                    <action fragment="path" type="prepend" value="/services"/>
                        <equal type="url" source="protocol" value="http"/>
                    <action fragment="port" xpath="get-property('http.port')"/>
                        <equal type="url" source="protocol" value="https"/>
                    <action fragment="port" xpath="get-property('https.port')"/>
            <log level="full"/>



  • Deploy the SimpleStockQuoteService in sample Axis2 server and start it on port 9000.
  • Start ESB with the sample configuration 452 (i.e. wso2esb-samples -sn 452).

Invoke the Axis2 client as follows.

ant stockquote -Dtrpurl=http://localhost:8280 -Daddurl=

The provided address URL does not contain a port number and the context. The URL rewrite mediator will replace the hostname to be 'localhost' and add the context '/services' to the path. Then it will add the appropriate port number to the URL by looking at the protocol prefix. Ultimately the service request will be routed the sample Axis2 server and the client will receive a valid response. Note that the Synapse configuration does not specify any endpoints explicitly. So the messages are sent to the rewritten To header.

Another important aspect shown by this sample is the ability of the URL rewrite mediator to obtain the necessary values by executing XPath expressions. The port numbers are calculated by executing an XPath on the messages.

Publishing Events to Topics Using the Event Mediator

WSO2 ESB can be used as an event broker. It comes with a built-in eventing implementation and a lightweight event broker based on Apache Qpid. You can use the ESB management console to create event topics and clients can subscribe to those topics by sending WS-Eventing subscription requests. The management console also allows creating static subscription.

WSO2 ESB is also equipped with an event mediator which can be used to publish messages to predefined topics. With this mediator it is possible for a sequence or a proxy service to directly publish a received request or a response to a topic as an event.

  • No labels