<?xml version="1.0" encoding="ISO-8859-1" ?>
<!--
  ~  Licensed to the Apache Software Foundation (ASF) under one
  ~  or more contributor license agreements.  See the NOTICE file
  ~  distributed with this work for additional information
  ~  regarding copyright ownership.  The ASF licenses this file
  ~  to you under the Apache License, Version 2.0 (the
  ~  "License"); you may not use this file except in compliance
  ~  with the License.  You may obtain a copy of the License at
  ~
  ~   http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~  Unless required by applicable law or agreed to in writing,
  ~  software distributed under the License is distributed on an
  ~   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  ~  KIND, either express or implied.  See the License for the
  ~  specific language governing permissions and limitations
  ~  under the License.
  -->

<document>
    <properties>
        <title>Apache Synapse - Sample 450</title>
    </properties>
    <body>
        <section name="Sample 450: Introduction to the URL Rewrite Mediator">
            <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;

    &lt;sequence name="main"&gt;
        &lt;in&gt;
            &lt;rewrite&gt;
                &lt;rule&gt;
                    &lt;action type="replace" regex="soap" value="services" fragment="path"/&gt;
                &lt;/rule&gt;
            &lt;/rewrite&gt;
            &lt;send/&gt;
        &lt;/in&gt;
        &lt;out&gt;
            &lt;send/&gt;
        &lt;/out&gt;
    &lt;/sequence&gt;

&lt;/definitions&gt;</div>
            <subsection name="Objective">
                <p>
                    Demonstrate the basic functions of the URL rewrite mediator
                </p>
            </subsection>
            <subsection name="Pre-requisites">
                <p>
                    <ul>
                        <li>
                            Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
                        </li>
                        <li>
                            Start Synapse using the configuration numbered 450 (repository/conf/sample/synapse_sample_450.xml)
                            <div class="command">
                                Unix/Linux: sh synapse.sh -sample 450<br/>
                                Windows: synapse.bat -sample 450
                            </div>
                        </li>
                    </ul>
                </p>
            </subsection>
            <subsection name="Executing the Client">
                <p>
                    URL rewrite mediator can be used to modify the 'To' header of a request based on
                    one or more user defined URL rewrite rules. A rewrite rule could be a
                    plain rewrite instruction or a conditional instruction. In this sample we use a
                    plain, unconidtional rewrite rule which simply replaces the string 'soap' with
                    'services' in the 'To' header.
                </p>
                <p>
                    Invoke the sample client as follows to try this out.
                </p>
                <div class="command">ant stockquote -Dtrpurl=http://localhost:8280 -Daddurl=http://localhost:9000/soap/SimpleStockQuoteService</div>
                <p>
                    Note that the address URL of the client request contains the context 'soap'. But
                    in the Axis2 server all the services are deployed under a context named 'services'
                    by default. Synapse will rewrite the To header of the request by replacing the
                    'soap' context with 'services. Hence the request will be delivered to the Axis2
                    server and the Axis2 client will receive a valid response.
                </p>                
            </subsection>
        </section>
        <p><a href="../samples.html">Back to Catalog</a></p>        
    </body>
</document>