blob: 7c9849449a7b9e9dcba0ae4a9f56e64aa1cc5387 [file]
<?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 15</title>
</properties>
<body>
<section name="Sample 15: Message Copying and Content Enriching with Enrich Mediator">
<div class="xmlConf">&lt;definitions xmlns=&quot;http://synapse.apache.org/ns/2010/04/configuration&quot;&gt;
&lt;sequence name=&quot;main&quot;&gt;
&lt;in&gt;
&lt;enrich&gt;
&lt;source type=&quot;custom&quot;
xpath=&quot;//m0:getQuote/m0:request/m0:symbol/text()&quot;
xmlns:m0=&quot;http://services.samples&quot;/&gt;
&lt;target type=&quot;property&quot; property=&quot;ORIGINAL_REQ&quot;/&gt;
&lt;/enrich&gt;
&lt;enrich&gt;
&lt;source type=&quot;body&quot;/&gt;
&lt;target type=&quot;property&quot; property=&quot;REQUEST_PAYLOAD&quot;/&gt;
&lt;/enrich&gt;
&lt;enrich&gt;
&lt;source type=&quot;inline&quot; key=&quot;init_req&quot;/&gt;
&lt;target xmlns:m0=&quot;http://services.samples&quot;
xpath=&quot;//m0:getQuote/m0:request/m0:symbol/text()&quot;/&gt;
&lt;/enrich&gt;
&lt;send&gt;
&lt;endpoint&gt;
&lt;address uri=&quot;http://localhost:9000/services/SimpleStockQuoteService&quot;/&gt;
&lt;/endpoint&gt;
&lt;/send&gt;
&lt;drop/&gt;
&lt;/in&gt;
&lt;out&gt;
&lt;header xmlns:urn=&quot;http://synapse.apache.org&quot; name=&quot;urn:lastTradeTimestamp&quot; value=&quot;foo&quot;/&gt;
&lt;enrich&gt;
&lt;source type=&quot;custom&quot;
xpath=&quot;//ns:getQuoteResponse/ns:return/ax21:lastTradeTimestamp&quot;
xmlns:ns=&quot;http://services.samples&quot;
xmlns:ax21=&quot;http://services.samples/xsd&quot;/&gt;
&lt;target xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot;
xmlns:urn=&quot;http://synapse.apache.org&quot;
xpath=&quot;/soapenv:Envelope/soapenv:Header/urn:lastTradeTimestamp&quot;/&gt;
&lt;/enrich&gt;
&lt;log level=&quot;full&quot;/&gt;
&lt;log&gt;
&lt;property name=&quot;Original Request Symbol&quot; expression=&quot;get-property(&#39;ORIGINAL_REQ&#39;)&quot;/&gt;
&lt;property name=&quot;Request Payload&quot; expression=&quot;get-property(&#39;REQUEST_PAYLOAD&#39;)&quot;/&gt;
&lt;/log&gt;
&lt;send/&gt;
&lt;/out&gt;
&lt;/sequence&gt;
&lt;localEntry key=&quot;init_req&quot;&gt;MSFT&lt;/localEntry&gt;
&lt;localEntry key=&quot;price_req&quot;&gt;
&lt;m0:symbol xmlns:m0=&quot;http://services.samples&quot;&gt;MSFT&lt;/m0:symbol&gt;
&lt;/localEntry&gt;
&lt;/definitions&gt;</div>
<subsection name="Objective">
<p>
Objective: Introduction to Message Copying and Content Enriching with Enrich Mediator
</p>
</subsection>
<subsection name="Pre-requisites">
<p>
<ul>
<li>
Start the Synapse configuration numbered 15: i.e. synapse -sample 15
</li>
<li>
Start the Axis2 server and deploy the SimpleStockQuoteService if
not already done
</li>
</ul>
</p>
</subsection>
<subsection name="Executing the Client">
<p>
Execute the client as follows.
</p>
<div class="command">ant stockquote -Dtrpurl=http://localhost:8280/services/StockQuote</div>
<p>This sample demonstrate the various capabilities of Enrich Mediator. Inside the in-sequence we store/copy different
parts of the message to properties and just before sending the message to the StockQuoteService, we modify the
request value based on the local entry value-init_req. Then in the out-sequence, the enrich mediator is used
to enrich a soap header based on the 'lastTradeTimestamp' value of the response.
</p>
</subsection>
</section>
<p>
<a href="../samples.html">Back to Catalog</a>
</p>
</body>
</document>