Nav

Lab 2: Download the complete Omni Channel project

Overview

Now that we’ve seen how APIKit helps developers import the designed REST API to enable MuleSoft flow development, we’ll download a fully implemented Omni Channel API project.

Step 1: Import the project from Anypoint Exchange

  1. From Studio open exchange

    module2 lab2 open exchange
  2. Filter by Examples

  3. Select the sub organization

  4. Click on the omni-channel-api

    module2 lab2 omni channel
  5. In the portal press Open

    module2 lab2 open project

    Once you open it, the project is going to be imported into Studio.

    module2 lab2 menu import

Step 2: Examine the different flows within the project

The previous lab already introduced the APIKit, Error handling and Dataweave Transform Message processors. In below flows we introduce REST Connectors, Flow Control components and Scopes. So let’s first look at these in more detail.

module2_lab2_step3_4a_rest_connector

REST Connector
A REST Connector is a component that can be used in Mule applications that’s been custom created via a specific framework. This framework allows you to create components entirely by using other existing Mule components. When an API Specification is published to exchange a REST Connector is automatically generated for it in Exchange by REST Connect Tool.

module2_lab2_step3_4b_flow_control

Flow Control
Flow Control Routers such as the Choice Router allows for controling the message flow within a Mule flow.

module2_lab2_step3_4c_scopes

Scopes
Sometimes referred to as "wrappers", the message processors known as Scopes appear as processing blocks when you first place them on the Message Flow canvas.

Now, lets look at all the flows within the project.

module2_lab2_step3_5_get_order_by_id

get:\orders\order\{order_id}
This flow calls the Order API to get an order from the database based on the order id

module2_lab2_step3_6_get_order_search

get:\orders\search
This flow calls the Order API to get orders from the database based on a search

module2_lab2_step3_7_get_product_by_id

get:\products\product\{product_id}
This flow calls the Product API to get a product based on the product id

module2_lab2_step3_8_get_product_search

get:\products\search
This flow returns products from the database by calling the Product API

module2_lab2_step3_9_get_user_shopping_cart

get:\users\user\{user_id}\shopping_cart
This flow returns all the items in a users shopping cart based on the user id

module2_lab2_step3_10_put_user_shopping_cart

put:\users\user\{user_id}\shopping_cart
This flow puts an item into a users shopping cart based on the user id

module2_lab2_step3_11_post_shopping_cart

post:\users\user\{user_id}\shopping_cart\confirmation
This flow confirms the items to purchase in a users shopping cart.

Step 3: Test the application

To test the API, let’s run it within Studio first.

  1. Right click the application.

  2. Select Run As > Mule Application.

    module2 lab2 step4 12 studio run.png
  3. The application will start running, and the console will show the Mule Runtime logs

    module2 lab2 step4 13 studio console deployed
    Anypoint Studio deployed this application to an embedded Mule Runtime. There is no need to deploy to a separate Mule server environment. The developer will be able to develop and test the application locally until it’s ready to be deployed to a shared development or QA environment.
  4. Test the application using the console. Click the Open Console on the APIkit Console tab.

    module2 lab2 step4 14 apikit console base url
  5. A browser window opens at: http://localhost:8081/console/.

  6. Click open the /products/search resource on the left and click GET.

  7. Click the TRY IT button on the top right to submit the request.

    module2 lab2 step4 15 browser apikit console tryit
  8. Then tick the Show optional parameters and fill them in as below and click SEND.

    module2 lab2 step4 16 apikit console get request
  9. Unlike Lab 1, this project is a complete solution and is making calls to System and Process REST APIs. The response you see in the Console is coming from other sources.

    module2 lab2 step4 17 apikit console response

    Let’s go ahead and stop the application to get ready for the next lab.

  10. Go to the console tab and press the red squared button to stop the Mule runtime server.

    module2 lab2 step4 18 studio stop

Summary

In this lab, we

This lab shows how quick and easy it is to enable your teams to get up and running quickly with pre-built project templates.

Congratulations! You have completed Lab 2.

Please proceed to Lab 3