You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by hi...@apache.org on 2010/12/26 05:25:28 UTC

svn commit: r1052830 - in /synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples: sample353.xml sample354.xml

Author: hiranya
Date: Sun Dec 26 04:25:27 2010
New Revision: 1052830

URL: http://svn.apache.org/viewvc?rev=1052830&view=rev
Log:
Ruby samples

Modified:
    synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample353.xml
    synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample354.xml

Modified: synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample353.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample353.xml?rev=1052830&r1=1052829&r2=1052830&view=diff
==============================================================================
--- synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample353.xml (original)
+++ synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample353.xml Sun Dec 26 04:25:27 2010
@@ -23,7 +23,7 @@
         <title>Apache Synapse - Sample 353</title>
     </properties>
     <body>
-        <section name="Sample 353: ">
+        <section name="Sample 353: Using Ruby Scripts for Mediation">
             <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
 
     &lt;localEntry key="stockquoteScript"
@@ -49,9 +49,35 @@
     &lt;/sequence&gt;
 
 &lt;/definitions&gt;</div>
+            <p>
+                The external script referenced by the configuration contains the following Ruby
+                scriplet.
+            </p>
+            <div class="xmlConf">&lt;x&gt;&lt;![CDATA[
+require 'rexml/document'
+include REXML
+
+def transformRequest(mc)
+   newRequest= Document.new '&lt;m:getQuote xmlns:m=&quot;http://services.samples&quot;&gt;'&lt;&lt;
+      '&lt;m:request&gt;&lt;m:symbol&gt;&lt;/m:symbol&gt;&lt;/m:request&gt;&lt;/m:getQuote&gt;'
+   newRequest.root.elements[1].elements[1].text = mc.getPayloadXML().root.elements[1].get_text
+   mc.setPayloadXML(newRequest)
+end
+
+def transformResponse(mc)
+   newResponse = Document.new '&lt;m:CheckPriceResponse xmlns:m=&quot;http://www.apache-synapse.org/test&quot;&gt;&lt;m:Code&gt;' &lt;&lt;
+      '&lt;/m:Code&gt;&lt;m:Price&gt;&lt;/m:Price&gt;&lt;/m:CheckPriceResponse&gt;'
+   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)
+end
+]]&gt;&lt;/x&gt;</div>
             <subsection name="Objective">
                 <p>
-
+                    The script mediator of Synapse can be programmed using any BSF compatible
+                    programming language. <a href="sample250.html">Sample 250</a> shows how to
+                    configure it using JavaScript. This sample shows how to configure the script
+                    mediator with Ruby.
                 </p>
             </subsection>
             <subsection name="Pre-requisites">
@@ -61,6 +87,11 @@
                             Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
                         </li>
                         <li>
+                            Synapse does not ship with a Ruby engine by default. Therefore you should
+                            download the Ruby engine from JRuby site and copy the downloaded jar file
+                            to the 'lib' directory of Synapse.
+                        </li>
+                        <li>
                             Start Synapse using the configuration numbered 353 (repository/conf/sample/synapse_sample_353.xml)
                             <div class="command">
                                 Unix/Linux: sh synapse.sh -sample 353<br/>
@@ -71,11 +102,16 @@
                 </p>
             </subsection>
             <subsection name="Executing the Client">
-                <div class="command">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/</div>
-
-                <div class="consoleOutput">Sat Nov 18 21:01:23 IST 2006 SimpleStockQuoteService :: Generating quote for : IBM</div>
-
-                <div class="consoleOutput">Standard :: Stock price = $95.26454380258552</div>
+                <p>
+                    This sample is identical to <a href="sample350.html">sample 350</a> with the
+                    only difference being the use of Ruby instead of JavaScript. Use the stock
+                    quote client to send a custom quote request as follows.
+                </p>
+                <div class="command">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dmode=customquote</div>
+                <p>
+                    The Ruby scriplets will transform the requests and responses as they flow through
+                    the service bus.
+                </p>
             </subsection>
         </section>
         <p><a href="../samples.html">Back to Catalog</a></p>        

Modified: synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample354.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample354.xml?rev=1052830&r1=1052829&r2=1052830&view=diff
==============================================================================
--- synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample354.xml (original)
+++ synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample354.xml Sun Dec 26 04:25:27 2010
@@ -23,7 +23,7 @@
         <title>Apache Synapse - Sample 354</title>
     </properties>
     <body>
-        <section name="Sample 354: ">
+        <section name="Sample 354: Using Inline Ruby Scripts for Mediation">
             <div class="xmlConf">&lt;definitions xmlns="http://ws.apache.org/ns/synapse"&gt;
 
     &lt;sequence name="main"&gt;
@@ -65,7 +65,7 @@
 &lt;/definitions&gt;</div>
             <subsection name="Objective">
                 <p>
-
+                    Shows how to embed Ruby scripts in the Synapse configuration itself.
                 </p>
             </subsection>
             <subsection name="Pre-requisites">
@@ -75,6 +75,11 @@
                             Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2
                         </li>
                         <li>
+                            Synapse does not ship with a Ruby engine by default. Therefore you should
+                            download the Ruby engine from JRuby site and copy the downloaded jar file
+                            to the 'lib' directory of Synapse.
+                        </li>
+                        <li>
                             Start Synapse using the configuration numbered 354 (repository/conf/sample/synapse_sample_354.xml)
                             <div class="command">
                                 Unix/Linux: sh synapse.sh -sample 354<br/>
@@ -85,11 +90,13 @@
                 </p>
             </subsection>
             <subsection name="Executing the Client">
-                <div class="command">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/</div>
-
-                <div class="consoleOutput">Sat Nov 18 21:01:23 IST 2006 SimpleStockQuoteService :: Generating quote for : IBM</div>
-
-                <div class="consoleOutput">Standard :: Stock price = $95.26454380258552</div>
+                <p>
+                    Run the sample client as follows.
+                </p>
+                <div class="command">ant stockquote -Daddurl=http://localhost:9000/services/SimpleStockQuoteService -Dtrpurl=http://localhost:8280/ -Dmode=customquote</div>
+                <p>
+                    The inline Ruby scripts will transform the requests and responses.
+                </p>                
             </subsection>
         </section>
         <p><a href="../samples.html">Back to Catalog</a></p>