You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@synapse.apache.org by ka...@apache.org on 2011/12/22 15:55:34 UTC
svn commit: r1222269 -
/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample800.xml
Author: kasun
Date: Thu Dec 22 14:55:34 2011
New Revision: 1222269
URL: http://svn.apache.org/viewvc?rev=1222269&view=rev
Log:
Adding sample 800 to docs
Added:
synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample800.xml
Added: synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample800.xml
URL: http://svn.apache.org/viewvc/synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample800.xml?rev=1222269&view=auto
==============================================================================
--- synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample800.xml (added)
+++ synapse/trunk/scratch/hiranya/website/src/site/xdoc/userguide/samples/sample800.xml Thu Dec 22 14:55:34 2011
@@ -0,0 +1,121 @@
+<?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 800</title>
+ </properties>
+ <body>
+ <section name="Sample 800: Introduction to REST API">
+ <div class="xmlConf"><!-- An empty flat synapse configuration shipped with the WSO2 ESB -->
+<definitions xmlns="http://ws.apache.org/ns/synapse">
+
+ <!-- You can add any flat sequences, endpoints, etc.. to this synapse.xml file if you do
+ *not* want to keep the artifacts in several files -->
+<api name="StockQuoteAPI" context="/stockquote">
+ <resource uri-template="/view/{symbol}" methods="GET">
+ <inSequence>
+ <payloadFactory>
+ <format>
+ <m0:getQuote xmlns:m0="http://services.samples">
+ <m0:request>
+ <m0:symbol>$1</m0:symbol>
+ </m0:request>
+ </m0:getQuote>
+ </format>
+ <args>
+ <arg expression="get-property('uri.var.symbol')"/>
+ </args>
+ </payloadFactory>
+ <send>
+ <endpoint>
+ <address uri="http://localhost:9000/services/SimpleStockQuoteService" format="soap11"/>
+ </endpoint>
+ </send>
+ </inSequence>
+ <outSequence>
+ <send/>
+ </outSequence>
+ </resource>
+ <resource url-pattern="/order/*" methods="POST">
+ <inSequence>
+ <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
+ <property name="OUT_ONLY" value="true"/>
+ <send>
+ <endpoint>
+ <address uri="http://localhost:9000/services/SimpleStockQuoteService" format="soap11"/>
+ </endpoint>
+ </send>
+ </inSequence>
+ </resource>
+</api>
+</definitions></div>
+ <subsection name="Objective">
+ <p>
+ Objective: Introduction to REST API
+ </p>
+ </subsection>
+ <subsection name="Pre-requisites">
+ <p>
+ <ul>
+ <li>
+ Deploy the SimpleStockQuoteService in the sample Axis2 server and start Axis2 Server
+ </li>
+ <li>
+ Start Synapse using the configuration numbered 800 (repository/conf/sample/synapse_sample_800.xml)
+ <div class="command">
+ Unix/Linux: sh synapse.sh -sample 800<br/>
+ Windows: synapse.bat -sample 800
+ </div>
+ </li>
+ </ul>
+ </p>
+ </subsection>
+ <subsection name="Executing the REST Client">
+ <p>
+ You might need a REST client like curl to test this
+ </p>
+ <div class="command">curl -v http://127.0.0.1:8280/stockquote/view/IBM</div>
+ <div class="command">curl -v http://127.0.0.1:8280/stockquote/view/MSFT</div>
+
+ <p>
+ The above GET calls will be handled by the first resource in the StockQuoteAPI.
+ These REST calls will get converted into SOAP calls and will be sent to the Axis2
+ server. Response will be sent to the client in POX format.
+ </p>
+ <p>
+ The following command POSTs a simple XML to the ESB. Save following sample place
+ order request as "placeorder.xml" file in your local file system and execute the
+ command. That is used to invoke a SOAP service. ESB returns the 202 response back to the client.
+ </p>
+ <div class="command">curl -v -d @placeorder.xml -H "Content-type: application/xml" http://127.0.0.1:8280/stockquote/order/</div>
+
+ <div class="xmlConf"><placeOrder xmlns="http://services.samples">
+ <order>
+ <price>50</price>
+ <quantity>10</quantity>
+ <symbol>IBM</symbol>
+ </order>
+</placeOrder></div>
+ </subsection>
+ </section>
+ <p><a href="../samples.html">Back to Catalog</a></p>
+ </body>
+</document>
\ No newline at end of file