This documentation is for WSO2 Enterprise Integrator version 6.0.0 . View documentation for the latest release in the 6.x.x family and the latest release in the 7.x.x family.

All docs This doc
Skip to end of metadata
Go to start of metadata

Note that WSO2 EI is shipped with the following changes to what is mentioned in this documentation:

  • <PRODUCT_HOME>/repository/samples/ directory that includes all Integration profile samples is changed to <EI_HOME>/samples/service-bus/.
  • <PRODUCT_HOME>/repository/samples/resources/ directory that includes all artifacts related to the Integration profile samples is changed to <EI_HOME>/samples/service-bus/resources/.

<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>
           <header name="Action" value="urn:getQuote"/>
           <send>
             <endpoint>
                <address uri="http://localhost:9000/services/SimpleStockQuoteService" format="soap11"/>
             </endpoint>
           </send>
        </inSequence>
        <outSequence>
           <send/>
        </outSequence>
     </resource>
     <resource methods="POST" url-mapping="/order/*">
        <inSequence>
           <property name="FORCE_SC_ACCEPTED" value="true" scope="axis2"/>
           <property name="OUT_ONLY" value="true"/>
		   <header name="Action" value="urn:placeOrder"/>
           <send>
              <endpoint>
                  <address uri="http://localhost:9000/services/SimpleStockQuoteService" format="soap11"/>
              </endpoint>
           </send>
        </inSequence>      
     </resource>
  </api>
</definitions>

Objective:

Introduce the REST API support in WSO2 ESB.

Prerequisites:

  1. You have to start the axis2 server and deploy the SimpleStockQuoteService.
  2. Start the Synapse configuration numbered 800: wso2ei-samples.sh -sn 800
  3. You need a REST client like curl to test this.
curl -v http://127.0.0.1:8280/stockquote/view/IBM
curl -v http://127.0.0.1:8280/stockquote/view/MSFT

The GET calls are handled by the first resource in the StockQuoteAPI. These REST calls will get converted into SOAP calls and sent to the Axis2 server. The response will be sent to the client in POX format.

The following command posts a simple XML to the ESB. Save the following sample request as "placeorder.xml" in your local file system and execute the command that is used to invoke a SOAP service. The ESB returns the 202 response back to the client.

curl -v -d @placeorder.xml -H "Content-type: application/xml" http://127.0.0.1:8280/stockquote/order/
<placeOrder xmlns="http://services.samples">
  <order>
     <price>50</price>
     <quantity>10</quantity>
     <symbol>IBM</symbol>
  </order>
</placeOrder>
  • No labels