URL rewrite mediator is used to modify and transform the URL values available in the message
Properties
By default the mediator will take the 'To' header of the message and apply the provided rewrite rules on it. Alternatively one can specify a property name in the 'inProperty' attribute, in which case the mediator will take the value of the specified property as the input URL. Similarly the mediator by default sets the transformed URL as the 'To' header of the message. Alternatively you can use the 'outProperty' attribute to instruct the mediator to set the resulting URL as a property.
Rules
The rewrite mediator applies URL transformations by evaluating a set of rules on the message. Rules are specified using the 'rewriterule' element. Rules are evaluated in the order they are specified. A rule can consist of an optional condition and one or more rewrite actions. If the condition is provided it will be evaluated first. If it evaluates to 'true' all the specified rewrite actions will be executed. Otherwise the set of actions will be skipped. If no condition is specified, the provided rewrite actions will be always executed. The condition should be wrapped in a 'condition' element within the 'rule' element. Rewrite actions are specified using 'action' elements.
<rewrite [inProperty="string"] [outProperty="string"]> <rewriterule> <condition> ... </condition>? <action [type="append|prepend|replace|remove|set"] [value="string"] [xpath="xpath"] [fragment="protocol|host|port|path|query|ref|user|full"] [regex="regex"]>+ </rewriterule>+ </rewrite>
Figure1: Rewrite Mediator
By default 'rewrite' mediator will take the 'To' header of the message and will apply the provided rewrite rules on it. If user specify a 'inProperty' attribute, the mediator will take the value of the specified property as the input URL.
Similarly the mediator by default sets the transformed URL as the 'To' header of the message. Alternatively user can use the 'outProperty' attribute to instruct the mediator to set the resulting URL as a property.
The rewrite mediator applies URL transformations by evaluating a set of rules on the message
Figure2: Rules
<rewrite> <rewriterule> <action type="replace" regex="soap" value="services" fragment="path" /> </rewriterule> </rewrite>
For instance; if our request is as follows,
"ant stockquote -Daddurl=http://localhost:8280/services/StockQuoteProxy1"
the address URL of the request contains the context 'soap'. In ESB server all the services are deployed under a context named 'services' by default. So,'To' header will be re written by replacing the 'soap' context with 'services'. Hence the requests will be delivered to the server successfully.