In previous posts, we learnt how to set up an Oracle API Platform Cloud Service, then Install the Oracle API Gateway and register it with the API Platform Cloud instance:
In this post, I will cover the following:
- Create a simple REST based service.
- Deploy the service to a separate WebLogic Managed server instance (used to host deployed applications).
- Create the API entry within the Oracle API Platform Cloud instance and point to the service on the application WebLogic Managed server.
- Allow the Oracle API Gateway to poll the Logical Gateway / 'phone home' and fetch the API, Policies etc.
- Attempt to access the service via the Oracle API Gateway Node.
- If all goes well, we will be routed to the deployed service and will use the Analytics tool on the API Management Portal to confirm the end-to-end activity.
Notes:
- I am covering a simple end to end. No additional Policies are applied to the API.
- I am using the main Administrator user (weblogic) for all activities. Ideally, we would have users assigned to x and y roles to perform respective tasks.
- The IP addresses of the Application managed server and Gateway Node are being used rather than Load Balancer URL's - Ideally, the servers will be placed behind an LB and the LB URL will be utilised in the API Management implementation.
Firstly, create and deploy an API service to an Application server
1. I have created a REST service - I won't go in-depth too much in terms of the coding, but I have used JDeveloper to create a simple service and when invoked, will return a JSON response:
2. The REST Service has been deployed to a WebLogic Managed server:
3. Now, I call the REST service directly from the Managed Server it has been deployed on. URL:
http://wcp12cr2:7001/apiblog/resources/helloworldpath
Next is where the fun starts: Let's manage the above service with Oracle API Platform Cloud
4. Log into your API Management Portal (https://CLOUD_IP/apiplatform):
5. By default, you will land on the APIs page:
6. Now, let's continue to create our first API entry. The 'View Documentation' directs you to the following
Oracle Documentation. Click 'Create API':
7. Populate the Name, Version and Description of your API:
8. An API Container will be created:
9. Click on the new API so we can continue to populate the implemenation details:
10. Hover over 'API Request' and click 'Edit':
11. In the 'Edit Policy' dialog, populate the API Endpoint URL of your deployed service:
12. Click Apply. The 'API Request' box will be updated with the URL. In the top right, click 'Save Changes':
13. Hover over 'Service Request' and click 'Edit':
14. In the Edit Policy dialog, select 'Enter a URL' and enter the URL to the REST service created above. In this case, it is http://wcp12cr2:7001/apiblog/resources/helloworldpath
15. Click Apply. The 'Service Request' box will be updated with the URL. In the top right, click 'Save Changes':
Next, we will begin the process of Deploying the API to our Gateway Node
16. Confirm our Gateway Node is running by using the status command to ensure the Gateway will fetch the deployed API:
17. If for any reason, the Gateway Node is not running, we can still continue with the API Deployment. The Gateway Node will perform a fetch when it comes back online.
18. Before we deploy the API, I want to show an unresolved request of accessing the service through the Gateway managed server. We will then access the same request again after the deployment to show that the Gateway has pulled down our deployed API correctly:
19. Back on the Management Portal, click on the 'Deployments' icon from the left:
20. Click on 'Deploy API':
21. Select our Gateway Node instance that was previously configured and then click 'Deploy':
22. Now, a request for Deployment will be Submitted. Click on the 'Waiting' tab to see the request:
23. Let's move onto approving the Request.
24. Click on 'Gateways' > Click on the Logical Gateway we have selected to deploy to > Click on the 'Deployments' icon. Our request has automatically moved to 'Waiting'. Typically, the Request would appear under 'Requesting' but this step has been skipped because I have used the Administrator user (weblogic) to create the Deployment Request. If the request appears under 'Requesting', then a Gateway Manager user must Approve the request first. Then the Request will move to 'Waiting':
25. Note: Once Deployments have been Requested and Approved, they will automatically appear under the 'Waiting' tab. This means that Requests will be processed once the Gateway Node polls the Logical Gateway or 'phones home'. (Clever eh!)
26. Once the Gateway Node has polled our Deployment(s), the Request should move from 'Waiting' to 'Deployed' automatically:
27. Now for the big finale! We are ready to access our service via the Gateway URL:
http://10.0.2.15:8000/apiblog/resources/helloworldpath
28. Success! JSON Response has been returned.
Next, let's take a look at the Analytics within the API Management Portal
29. In the Logical Gateway instance, click on the 'Analytics' icon:
30. We can assess several types of statistics for the requests we have made:
That's it! Our simple end-to-end has been implemented and tested. In my next blogposts, I will focus on integrating our API Platform with Apiary for a focus on API First design. I will explore applying Policies such as Authentication etc. on the above solution.
- OS.