| <?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"><definitions xmlns="http://synapse.apache.org/ns/2010/04/configuration"> |
| <sequence name="main"> |
| <in> |
| <enrich> |
| <source type="custom" |
| xpath="//m0:getQuote/m0:request/m0:symbol/text()" |
| xmlns:m0="http://services.samples"/> |
| <target type="property" property="ORIGINAL_REQ"/> |
| </enrich> |
| <enrich> |
| <source type="body"/> |
| <target type="property" property="REQUEST_PAYLOAD"/> |
| </enrich> |
| |
| <enrich> |
| <source type="inline" key="init_req"/> |
| <target xmlns:m0="http://services.samples" |
| xpath="//m0:getQuote/m0:request/m0:symbol/text()"/> |
| </enrich> |
| |
| <send> |
| <endpoint> |
| <address uri="http://localhost:9000/services/SimpleStockQuoteService"/> |
| </endpoint> |
| </send> |
| <drop/> |
| </in> |
| <out> |
| <header xmlns:urn="http://synapse.apache.org" name="urn:lastTradeTimestamp" value="foo"/> |
| <enrich> |
| <source type="custom" |
| xpath="//ns:getQuoteResponse/ns:return/ax21:lastTradeTimestamp" |
| xmlns:ns="http://services.samples" |
| xmlns:ax21="http://services.samples/xsd"/> |
| <target xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" |
| xmlns:urn="http://synapse.apache.org" |
| xpath="/soapenv:Envelope/soapenv:Header/urn:lastTradeTimestamp"/> |
| </enrich> |
| <log level="full"/> |
| <log> |
| <property name="Original Request Symbol" expression="get-property('ORIGINAL_REQ')"/> |
| <property name="Request Payload" expression="get-property('REQUEST_PAYLOAD')"/> |
| </log> |
| <send/> |
| </out> |
| |
| </sequence> |
| <localEntry key="init_req">MSFT</localEntry> |
| <localEntry key="price_req"> |
| <m0:symbol xmlns:m0="http://services.samples">MSFT</m0:symbol> |
| </localEntry> |
| |
| </definitions></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> |