Lab 5: Proxy Legacy Services with an HTTP Proxy (Optional)
Overview
API management is essential to an API-Led architecture as it provides a governance framework to your APIs in all three layers. You saw in Lab 1 how MuleSoft can proxy your published APIs in Exchange on an API Gateway, and in Lab 4 how you can directly govern a MuleSoft implemented API.
What if you have an existing/legacy service? MuleSoft can govern these as well. We govern these existing services through an HTTP proxy. Note that it is possible to govern REST-JSON services and SOAP Web Services this way!
The API we will use to demonstrate this is an already deployed mock implementation.
Clients will access the API through the API Gateway which will then forward the requests to the actual Omni Channel API Mock Implementation. Having the proxy deployed on the API gateway allows Anypoint Platform to manage, control access and monitor the usage of your legacy services, which we demonstrate in labs 2 and 3.
Step 1: Create an API-HTTP Proxy in API Manager
-
Navigate to API Manager
-
Select Add API and select Add New API
-
Select Mule Gateway
-
Choose the proxi type to "Deploy a proxy application"
-
Choose Cloudhub 2.0 as the target (you might need to change the space based on location)
-
Runtime version: Select the latest
-
Proxy application name:
<username>-mythical-omni-channel-api-http-proxy.This property will define the Proxy URL and the name of the Mule application in the Runtime Manager.
-
Press Next Button
-
The "Select API From Exchange" should be selected by default, now search for the
Omni Channel Experience API
-
Continue to next Step
Step 2: Configure the HTTP-API Proxy in API Manager
For this lab, we are going to configure the API-HTTP proxy to Mythical Corporation’s Omni Channel API Mock Implementation. The API is available as an HTTP Restful API accessible through the base URL http://workshop-omni-channel-mock-service-v5.us-e1.cloudhub.io/api.
Let’s take a look the products resource of this API that returns product information when an HTTP GET is issued.
To see the all the resources of this API, you can view an API Console using the URL http://workshop-omni-channel-mock-service-v5.us-e1.cloudhub.io/console/
-
Configure the Endpoint with the following information:
-
API instance label:
<username>-http-proxy-omni-channel. This Parameter is going to be use to identify the API in the API Manager. -
Base Path:
/ -
Scheme: HTTP
Since we are deploying to CloudHub, there is no need to specify the port. By default it’s port 80 or 443 depending if it’s http or https.
-
-
Press Next
-
Set Upstream URL:
http://workshop-omni-channel-mock-service-v5.us-e1.cloudhub.io/api
-
-
Press Next
-
Review your settings
-
Click Save and Deploy
After you press Save and Deploy the deployment will start.
When you see Your application is started you will see the Api Status change to Active.
| The proxy you just created is a Mule application/project. If you want to see what is going on under the covers just download the proxy and import it into Anypoint Studio. Unlike the blackbox proxies of the “pure-play” API Management tools like Mashery, Layer 7, apigee… Anypoint proxies are Mule applications which you can download and extend with all the capabilities of Mule that you will learn about through the remaining labs. |
| If needed, you could augment the generated flow with additional logic. |
| While you deployed this proxy to an API Gateway running on CloudHub, you could also deploy this proxy application to an on-premise API Gateway. |
Step 3: Test the API-HTTP Proxy
Your proxy API is now accessible through CloudHub.
You can get the exact URL of your hosted proxy under the API Status:
-
Right-click on the URL to copy it.
-
Open another tab in your browser.
-
Paste what you copied into the new tab but do NOT hit enter yet.
-
Add “/products/search” to retrieve the product information using your proxy.
You should have a URL that looks like: http://{your_domain_name}/products/search
-
Now press Enter and you should see a response similar to the following:
-
You can also test the API by using a REST Client like PostMan or ARC (Advanced Rest Client).
Summary
In this lab, we completed the following steps:
-
Create an API-HTTP proxy in exchange>>
-
Configure the API-HTTP proxy in API Manager>>
-
Test the API-HTTP proxy
We saw how easy it is to proxy existing APIs and deploy it on a CloudHub-based API Gateway. This provides a low friction approach to manage existing APIs across your environment. You are able to leverage a hybrid API Gateway service offering which can be on-premise or on the cloud. In this lab, we saw how we can deploy our API Gateway to CloudHub which can significantly speed up your deployment without having to manage and maintain infrastructure.
For further reading on deploying an API gateway and proxying your API, please refer to the following documentation:
Congratulations! You have completed Lab 5.
Please proceed to next Module



