Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagebash
curl -v -H "Content-Type: application/xml" -d "<Customer><id>123</id><name>John</name></Customer>" http://localhost:8282/customerservicestockquote/view/customersIBM?param1=value1&m2param2=value2

In this request, there are two query parameters (customer name and ID) that must be set in the outgoing message from the ESB. We can configure the API to set those parameters as follows:

...

Code Block
languagehtml/xml
<api name="StarbucksService" context="/Starbucks_Service">
    <resource methods="POST" url-mapping="/orders/add">
        <inSequence>
            <property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
            <send>
                <endpoint>
                    <address uri="http://localhost:9764/StarbucksService/services/Starbucks_Outlet_Service/orders/"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence>
            <log level="full"/>
            <property name="messageType" value="application/xml" scope="axis2"/>
            <send/>
        </outSequence>
    </resource>
    <resource methods="PUT" url-mapping="/orders/edit">
        <inSequence>
            <log level="full"/>
            <property name="REST_URL_POSTFIX" scope="axis2" action="remove"/>
            <property name="messageType" value="application/json" scope="axis2"/>
            <property name="ContentType" value="application/json" scope="axis2"/>
            <send>
                <endpoint>
                    <address uri="http://localhost:9764/StarbucksService/services/Starbucks_Outlet_Service/orders/"
                             format="rest"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence>
            <log level="full"/>
            <property name="messageType" value="application/xml" scope="axis2"/>
            <send/>
        </outSequence>
    </resource>
    <resource methods="DELETE GET" uri-template="/orders/{id}">
        <inSequence>
            <property name="REST_URL_POSTFIX"<send>
                <endpoint>
      expression="fn:concat('/orders/',get-property('uri.var.id'))"              <address uri="http://localhost:9764/StarbucksService/services/Starbucks_Outlet_Service/"/>
       scope="axis2"/>         </endpoint>
   <send>         </send>
        <endpoint></inSequence>
        <outSequence>
           <address uri="http://localhost:9764/StarbucksService/services/Starbucks_Outlet_Service/"/>
                </endpoint>
            </send>
        </inSequence>
        <outSequence>
            <log  <log level="full"/>
            <property name="messageType" value="application/xml" scope="axis2"/>
            <send/>
        </outSequence>
    </resource>
</api>

...

For the SOAP back-end service, we are using the StockQuote Service that is shipped with ESB. Configure and start the back-end service as described in Starting Sample Back-End Services. We will use cURL as the REST client to invoke the ESB REST API.

...

Setting up the back end

For the SOAP back-end service, we are using the StockQuote Service that is shipped with ESB.  cURL is used as Configure and start the back-end service as described in Starting Sample Back-End Services. We will use cURL as the REST client to invoke the ESB API. Run Sample 800 as follows.

 For further information on how to run an ESB sample, see ESB Samples Setup.

...

  • On Windows: wso2esb-samples.bat -sn 800
  • On Linux/Solaris: ./wso2esb-samples.sh -sn 800

...

  • On Windows: axis2server.bat
  • On Linux/Solaris: ./ axis2server.sh

...

REST API.

Configuring the API

Create an API using the following configuration:

...