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


This sample demonstrates a pizza ordering scenario with backend 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. For instructions, see Installation.

  • As you run the Application Server on the same server as the API Manager, increment the default port of the Application Server to avoid port conflicts. To do this, go to <AS_HOME>/repository/conf/carbon.xml and change <Offset>2</Offset>. 

Building the sample

  1. Go to <APIM_HOME>/samples/PizzaShack/pizza-shack-api in command shell and run mvn clean install to build the sample.

  2. Go to <APIM_HOME>/samples/PizzaShack/pizza-shack-web in command shell and run mvn clean install.

  3. See step 7 below if you are rebuilding the sample.

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. Rebuild the sample.

    If you are rebuilding this sample, execute the following steps:

    1. Remove the following module from <APIM_HOME>/samples/PizzaShack/pom.xml file: <module>pre-processor</module>.
    2. Delete the file from <APIM_HOME>/samples/PizzaShack.
    3. Go to <APIM_HOME>/samples/PizzaShack in command shell and run mvn clean install.
  8. Start WSO2 AS (https://localhost:9445/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).

  9. Deploy the following into the Application Server.

    • <APIM_HOME>/samples/PizzaShack/pizza-shack-web/target/pizzashack.war
    • <APIM_HOME>/samples/PizzaShack/pizza-shack-api/target/pizzashack-api-1.0.0.war
  10. After deploying, access the application using http://localhost:9765/pizzashack. It opens the application in a Web browser.

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