Author: indika
Date: Mon Dec 17 02:07:22 2007
New Revision: 11224
Log:
add a in-lined ruby script mediator sample and update the documents
Added:
trunk/esb/java/repository/conf/sample/synapse_sample_354.xml
Modified:
trunk/esb/java/modules/distribution/src/main/docs/ESB_Samples.html
Modified: trunk/esb/java/modules/distribution/src/main/docs/ESB_Samples.html
==============================================================================
--- trunk/esb/java/modules/distribution/src/main/docs/ESB_Samples.html
(original)
+++ trunk/esb/java/modules/distribution/src/main/docs/ESB_Samples.html Mon Dec
17 02:07:22 2007
@@ -153,6 +153,8 @@
context API methods using scripting language</a></li>
<li><a href="#Sample353">Sample 353: Using Ruby scripts for
mediation</a></li>
+ <li><a href="#Sample354">Sample 354: Using In-lined Ruby scripts
+ for mediation</a></li>
</ul>
</li>
<li><a href="#DBMediators">Database interactions in mediation (DBLookup
@@ -3081,6 +3083,64 @@
the stock quote client to send a custom stock quote as per example #350 and
check the received stock quote response.</p>
+<h2><a name="Sample354">Sample 354: Using In-lined Ruby scripts for
+mediation</a></h2>
+
+<div>
+<pre> <!-- Using In-lined Ruby scripts for mediation -->
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+ <in>
+ <script language="rb">
+ <![CDATA[
+ require 'rexml/document'
+ include REXML
+ newRequest= Document.new '<m:getQuote
xmlns:m="http://services.samples/xsd"><m:request><m:symbol>...test...</m:symbol></m:request></m:getQuote>'
+ newRequest.root.elements[1].elements[1].text =
$mc.getPayloadXML().root.elements[1].get_text
+ $mc.setPayloadXML(newRequest)
+ ]]>
+ </script>
+ <send>
+ <endpoint>
+ <address
uri="http://localhost:9000/soap/SimpleStockQuoteService"/>
+ </endpoint>
+ </send>
+ </in>
+ <out>
+ <script language="rb">
+ <![CDATA[
+ require 'rexml/document'
+ include REXML
+ newResponse = Document.new '<m:CheckPriceResponse
xmlns:m="http://services.samples/xsd"><m:Code></m:Code><m:Price></m:Price></m:CheckPriceResponse>'
+ newResponse.root.elements[1].text =
$mc.getPayloadXML().root.elements[1].elements[1].get_text
+ newResponse.root.elements[2].text =
$mc.getPayloadXML().root.elements[1].elements[2].get_text
+ $mc.setPayloadXML(newResponse)
+ ]]>
+ </script>
+ <send/>
+ </out>
+</definitions> </pre>
+</div>
+
+<p><strong>Objective: Script mediators using Ruby(In-lined Ruby
+Script)</strong></p>
+
+<p><strong>Prerequisites:</strong></p>
+
+<p>This sample uses Ruby so first setup support for this in ESB as described
+at <a href="ESB_Samples_Setup.html#script">Configuring JRuby</a>. </p>
+
+<p>Start the Synapse configuration numbered 354: i.e. bin/synapse -sample
+354<br>
+Start the Axis2 server and deploy the SimpleStockQuoteService if not already
+done</p>
+
+<p></p>
+
+<p>This sample is functionally equivalent to the sample #353.</p>
+
+<p>Runs the client with </p>
+<pre> ant stockquote
-Daddurl=http://localhost:9000/soap/SimpleStockQuoteService
-Dtrpurl=http://localhost:8080/ -Dmode=customquote</pre>
+
<h2><a name="DBMediators">Database interactions in mediation (DBLookup /
DBReport)</a></h2>
Added: trunk/esb/java/repository/conf/sample/synapse_sample_354.xml
==============================================================================
--- (empty file)
+++ trunk/esb/java/repository/conf/sample/synapse_sample_354.xml Mon Dec
17 02:07:22 2007
@@ -0,0 +1,52 @@
+<!--
+ ~ 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.
+ -->
+
+ <!-- Using In-lined Ruby scripts for mediation -->
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+ <in>
+ <script language="rb">
+ <![CDATA[
+ require 'rexml/document'
+ include REXML
+ newRequest= Document.new '<m:getQuote
xmlns:m="http://services.samples/xsd"><m:request><m:symbol>...test...</m:symbol></m:request></m:getQuote>'
+ newRequest.root.elements[1].elements[1].text =
$mc.getPayloadXML().root.elements[1].get_text
+ $mc.setPayloadXML(newRequest)
+ ]]>
+ </script>
+ <send>
+ <endpoint>
+ <address
uri="http://localhost:9000/soap/SimpleStockQuoteService"/>
+ </endpoint>
+ </send>
+ </in>
+ <out>
+ <script language="rb">
+ <![CDATA[
+ require 'rexml/document'
+ include REXML
+ newResponse = Document.new '<m:CheckPriceResponse
xmlns:m="http://services.samples/xsd"><m:Code></m:Code><m:Price></m:Price></m:CheckPriceResponse>'
+ newResponse.root.elements[1].text =
$mc.getPayloadXML().root.elements[1].elements[1].get_text
+ newResponse.root.elements[2].text =
$mc.getPayloadXML().root.elements[1].elements[2].get_text
+ $mc.setPayloadXML(newResponse)
+ ]]>
+ </script>
+ <send/>
+ </out>
+</definitions>
+
_______________________________________________
Esb-java-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/esb-java-dev