This documentation is for WSO2 API Manager 1.4.0 View documentation for the latest release.
Invoking APIs using a Web App Deployed in WSO2 AS - API Manager 1.4.0 - WSO2 Documentation
Skip to end of metadata
Go to start of metadata


This sample demonstrates and end to end pizza ordering scenario where we have back-end services deployed in WSO2 Application Server (AS) to which we create APIs in WSO2 API Manager. Then, we invoke those APIs using a Web application deployed in WSO2 AS. 


  • Download and install WSO2 Application Server. If you do this on the same server as the APIM, be sure to offset its port by 1 to avoid port conflict. Go to <PRODUCT_HOME>/repository/conf/carbon.xml and change <Offset>1</Offset>. For more information, see Changing the Default Ports with Offset.

Building the Sample

Run mvn clean install command in <APIM_HOME>/samples/PizzaShack/pizza-shack-web and <APIM_HOME>/samples/PizzaShack/pizza-shack-api to build the sample files.

Executing the Sample

  1. Log in to the API Publisher (https://localhost:9443/publisher) and create the following APIs.

    Delivery API
            API Name= pizzaShack
            Context = /pizzashack/delivery
            Version = 1.0.0
            Production Endpoint URL=http://localhost:9765/pizzashack-api-1.0.0/api/delivery
            API Resources =Keep the default values 
       Order API
            API Name= pizzashack-order
            Context = /pizzashack/order
            Version = 1.0.0
            Production Endpoint URL=http://localhost:9765/pizzashack-api-1.0.0/api/order
            API Resources =Keep the default values 
       Menu API
            API Name= pizzashack-menu
            Context = /pizzashack/menu
            Version = 1.0.0
            Production Endpoint URL=http://localhost:9765/pizzashack-api-1.0.0/api/menu
            API Resources =Keep the default values 
  2. Navigate to the Lifecycles tab of each API and promote them to PUBLISHED state. This will push the APIs to the Gateway and they will be available for subscription in the API Store.
  3. Log in to the API Store (https://localhost:9443/store) and click on each API created earlier. Next, subscribe to each of them using the default application.
  4. After subscription, a message appears. Choose Go to My Subscriptions.
  5. The Subscriptions page opens. Create a production key by clicking the Generate button associated with it. You also have the option to increase the default token validity period, which is 1 hour.
  6. You get the access token, a consumer key and a consumer secret. Replace the consumer key and secret pair in <APIM_HOME>/samples/PizzaShack/pizza-shack-web/src/main/webapp/WEB-INF/web.xml with the newly generated ones. For example,


    You now have three APIs subscribed under an application and an access token to the application. Next, we deploy a Web application in the Application Server and use it to invoke the APIs.

  7. Start WSO2 AS (https://localhost:9443+<offset>/console) and log into its management console. For instructions, see AS documentation (If the AS documentation link doesn't load, please clear your browser cache and retry).

  8. Deploy <APIM_HOME>/samples/PizzaShack/pizza-shack-web/target/pizzashack.war and <APIM_HOME>/samples/PizzaShack/pizza-shack-api/target/pizzashack-api-1.0.0.war into the Application Server.

  9. After deploying, access the application using http://localhost:9764/pizzashack. It opens the application in a Web browser.

  10. You can use this application to order pizza. Internally, the APIs get invoked when you use the application.
  • No labels