Try WSO2 Cloud for Free
Sign in

All docs This doc

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Manually added ToC


titleAlternate Method

You can do the same using a dynamic sequence as well. For that you will need to make the below changes to the sequence explained in Resource-based routing. However all the versions needs to be defined and handled separately whereas the above sequence will dynamically populate any version which you pass in the header.

titleExpand to see the sample sequence...
Code Block
<sequence name="dynamic_ep" trace="disable" xmlns="">
    <!-- The property which is retrieved as get-property('To')" stores the request URI for the API. Based on this value we will determine the endpoint which the request needs to be routed to.-->
	<switch source="get-property('transport','Version')">
    	<case regex="1.0.0.*">
           <!-- We are then assigning the endpoint which we need to route to in a property named service_ep in this step -->
        	<property name="service_ep" value="https//first.backend.url/1.0.0/customers/>
    	<case regex="2.0.0">
        	<property name="service_ep" value="https//first.backend.url/2.0.0/customers/"/>
    	<!– add endpoints as needed –>
        	<property name="service_ep" value="https//first.backend.url/1.0.0/customers/"/>
        	<!–default endpoint if required. However there should be a matching resource–>
    <!-- Next we need to store this endpoint in a header named To as shown below -->
	<header name="To" expression="get-property('service_ep')"></header>
	<property expression="get-property('service_ep')" name="ENDPOINT_ADDRESS"></property>
	<!–Please note that "ENDPOINT_ADDRESS" (additional) property is defined here in order to populate
    destination address for statistics (API Usage by Destination). –>

Working with properties

The Property Mediator has no direct impact on the message, but rather on the message context flowing through Synapse.

Code Block
<property name="string" [action=set|remove] [type="string"] (value="literal" | expression="xpath") [scope=default|transport|axis2|axis2-client] [pattern="regex" [group="integer"]]>

Setting properties within your custom mediation 

For a list of the types of properties which you are able to work with, see Properties Reference. All properties which need to be set follow the same basic syntax. The following are some examples of setting properties.

Table of Contents

Setting a content type
Code Block
<sequence xmlns="" name="property_sequence"> 
           <property name="ContentType" value="text/xml" scope="axis2"/>