Module 1 MAX150 WI25v1 en Exercise Guide
Module 1 MAX150 WI25v1 en Exercise Guide
Table of Contents
able of Contents
T
2
Introducing the course 3
Walkthrough: Set up your computer for class 4
Module 1: Introducing application networks and API-led connectivity
9
Walkthrough 1-1: Explore an API directory and an API portal 0
1
Walkthrough 1-2: Make calls to an API 19
Module 2: Introducing Anypoint Platform 6
3
Walkthrough 2-1: Explore Anypoint Platform and Anypoint Exchange 37
Module 3: Designing APIs 9
4
Walkthrough 3-1: Use API Designer to define an API with RAML 50
Walkthrough 3-2: Use the mocking service to test an API 58
Walkthrough 3-3: Add request and response details 67
Walkthrough 3-4: Add an API to Anypoint Exchange 86
Walkthrough 3-5: Share an API 100
Module 4: Building APIs 09
1
Walkthrough 4-1: Create a Mule application with Anypoint Studio 110
Walkthrough 4-2: Connect to data (MySQL database) 121
Walkthrough 4-3: Transform data 141
Walkthrough 4-4: Create a RESTful interface for a Mule application 155
alkthrough 4-5: Use Anypoint Studio to create a RESTful API interface from a RAML file
W
166
Walkthrough 4-6: Implement a RESTful web service 178
alkthrough 4-7: Synchronize changes to an API specification between Studio and
W
Anypoint Platform 185
Module 5: Deploying and managing APIs 01
2
Walkthrough 5-1: Deploy an application to CloudHub 202
Walkthrough 5-2: Create and deploy an API proxy 211
Walkthrough 5-3: Restrict API access with policies and SLAs 230
Walkthrough 5-4: Request and grant access to a managed API 239
Walkthrough 5-5: Add client ID enforcement to an API specification 250
In this walkthrough, you make sure your computer is set up correctly, so you can complete
the class exercises. You will:
● Install Advanced REST client (if you did not already).
1. Locate your course enrollment email and follow the instructions to download the
student files ZIP.
NOTE:Keep this file open. You will copy and pastetext from it during class.
4. Again, follow your course enrollment email to access the student manual and slides.
5. In your computer's file browser, navigate to where you installed Anypoint Studio and
open it.
NOTE:If you do not have Anypoint Studio, you can download it from
https://www.mulesoft.com/lp/dl/studio. Upon startingAnypoint Studio, users on Windows
may get a popup asking to allow Windows Defender Firewall access for OpenJDK; access
should be allowed.
6. In the Workspace Launcher dialog box, look at the location of the default
workspace; change the workspace location if you want.
NOTE:If you cannot successfully start Anypoint Studio,make sure that you have enough
available memory (at least 8GB available) to run Anypoint Studio.
8. If you get a new features page, click theContinueto Studiobutton to close it.
9. If you get an Updates Available popup in the lower-right corner of the application,
click it and install the available updates.
NOTE:If you do not have Advanced REST Client (or another REST API client) installed,
download it now from https://install.advancedrestclient.com/and install it.
11.Leave Advanced REST Client open; you will use it throughout class.
NOTE:If you do not have an account, sign up for afree, 30-day trial account now. Also, if
you get prompted here or in other parts of the course to enable multi-factor authentication,
select Not Now.
13.Click the menu button located in the upper-left in the main menu bar.
16.Check your subscription level and if it is a trial account, make sure it is not expired.
NOTE:If your trial is expired or will expire during class, sign out and then sign up for a new
trial account now.
In this walkthrough, you locate and explore documentation about APIs. You will:
● Explore the API portal for an API to be used in the course.
2. Scroll down and examine the various APIs that are available.
3. At the top of the page, enter vimeo in the search text field.
5. In the new browser tab that opens, clickAPI Referencein the left-side navigation.
6. Review the API Reference for information about endpoints, HTTP methods and
parameters.
9. Copy the URL for the MuleSoft Training API portal.
16.Review the information about the GET method; you should see there is an optional
query parameter called destination.
In this walkthrough, you make calls to a RESTful API. You will:
● Use Advanced REST Client to make calls to an unsecured API (an implementation).
● Use Advanced REST Client to make calls to a secured API (an API proxy).
● Use the API console in an API portal to make calls to a managed API using a
mocking service.
● Use the API console to make calls to an API proxy endpoint.
4. Copy the URL for the American Flights web service.
NOTE:This is the URL for the API implementation,not the managed API proxy. The -ws in
the URL stands for web service.
5. Return to Advanced REST Client and paste the URL in the text box that says Request
URL, replacing any existing content.
8. Review the response body containing flights to SFO, LAX, and CLE.
10.Click theOpen parameters editoricon (the pencil) to the right of the URL.
11.In the query parameters editor area that appears, click theAddbutton.
12.Set the parameter name to destination and the parameter value to CLE then click
Close.
13.Click theSend the requestbutton; you should getjust flights to CLE returned.
14.Edit the query parameters again, click theRemovethis parameterbutton next to
the parameter to delete it, then clickClose.
15.Change the request URL to add a URI parameter to retrieve the flight with an ID of 3.
16.Click thesendbutton; you should see only the flight with that ID returned.
18.Click thesendbutton; you should see a 200 responsewith the message Flight
deleted (but not really).
NOTE:The database is not actually modified so that its data integrity can be retained for
class.
20.Click thesendbutton; you should get a 405 responsewith the message Method not
allowed.
22.Click thesendbutton; you should get a 415 response with the message
Unsupported media type.
26.Select theBodytab.
27.Return to the course snippets.txt file and copy the value for American Flights API
post body.
28.Return to Advanced REST Client and paste the code in the body text area.
29.Click thesendbutton; you should see a 201 Createdresponse with the message
Flight added (but not really).
30.Return to the request body and remove the plane field and value from the request
body.
35.Send the request; you should see a 400 Bad Request response with the message
Bad request.
39.In the request body field, pressCmd+Z or Ctrl+Zuntilthe emptySeats field is added
back.
40.Send the request; you should get a 200 OK response with the message Flight
updated (but not really).
45.Return to the course snippets.txt file and copy the value for the American Flights API
client_id.
47.Set client_id to the value you copied from the snippets.txt file.
48.Return to the course snippets.txt file and copy the value for the American Flights API
client_secret.
50.Set client_secret to the value you copied from the snippets.txt file.
NOTE:The client credentials in the snippets filemay be different than what is shown here;
the values in the snippets file differ for instructor-led and self-study training classes.
52.Click thesendbutton several more times; you shouldget a429 Too Many Requests
response with the messageQuota has been exceeded.
NOTE:.For the self-study training class, the API service level agreement (SLA) for the
application with your client ID and secret has been set to allow three API calls per minute
while, for the instructor-led class, the SLA allows for a higher number to accommodate
shared use.
Use the API console in the API portal to make requests to the API
using a mocking service
53.Return to the browser window with the American Flights API portal at
https://anypoint.mulesoft.com/exchange/portals/muletraining.
57.In the API console located on the right side of the page, make sure theMocking
Serviceendpoint is selected.
61.ClickSend; you should get the example flights thatare to SFO and ORD.
62.At the top of the API console, change the endpoint toProduction – Rate limiting
SLA based policy.
65.Copy and paste the client_id and client_secret values from the course snippets.txt
file.
66.ClickSend; you should get a200 OKresponse with only flights to LAX.
● Describe the benefits of Anypoint Platform and MuleSoft’s approach to be successful
with it.
● Locate APIs and other assets needed to build integrations and APIs in Anypoint
Exchange.
In this walkthrough, you get familiar with Anypoint Platform. You will:
● Discover and make calls to the Training: American Flights API in the public Exchange.
2. Click the menu button located in the upper-left in the main menu bar.
3. In the menu that appears, selectAnypoint Platform; this will return you to the home
page.
7. On the business group page, select the name of your organization (Training in the
screenshots).
16.In the left-side navigation, selectProvided by MuleSoft; you should see all the
content in the public Exchange.
17.In the left-side navigation, select the name of your organization above Provided by
MuleSoft (Training in the screenshots); you should now see only the content in your
private Exchange, which is currently empty.
29.In the category filter menu, selectBanking, clickApply,and review the filtered APIs.
30.In the lifecycle state menu, selectDeprecatedandclickApply.
Discover and review the API portal for the Training: American Flights
API
35.In the left-side navigation, expand and review the list of available resources.
37.On the GET /flights page, review the information for the optional destination query
parameter; you should see the API is similar to the one you explored in the public
MuleSoft Training portal.
Use the API console to make calls to the Training: American Flights API
38.In the API console, review the options for the instances you can test.
39.SelectMocking Service.
43.Change the API instance from Mocking Service to Rate limiting SLA based policy.
45.In the Headers section, copy and paste the client_id and client_secret values from
the course snippets.txt file
46.ClickSendagain; you should get results from theactual API implementation for the
destination you selected.
● Define APIs with RAML, the Restful API Modeling Language.
● Mock APIs to test their design before they are built.
● Make APIs discoverable by adding them to the private Anypoint Exchange.
In this walkthrough, you create an API definition with RAML using API Designer. You will:
3. In the New API Specification dialog box, set the project name toAmerican Flights
API.
5. Review the three sections of API Designer: the file browser, the editor, and the API
console.
6. In the editor, place the cursor on a new line of code at the end of the file.
8. Look at the API console on the right side of the window; you should see summary
information for the API.
NOTE:If you do not see the API console, click theDocumentation icon located in the right
column.
9. In the editor, on the last new line of code backspace so you are indented the same
amount as the flights resource; look at the contents of the API Designer shelf.
NOTE:If you don’t see the API Designer shelf, it is either minimized or there is an error in
your code. To check if it is minimized, go to the bottom of the web browser window and
look for an arrow. If you see the arrow, click it to display the shelf.
10.Indent by pressing the Tab key; the contents in the API Designer shelf should
change.
12.Look at the API console; you should see a GET method for the flights resource.
13.In the editor, backspace so you are indented the same amount as the get method.
15.Look at the API console; you should see GET and POST methods for the flights
resource.
17.Make sure you are still under the flights resource (at the same indentation as the
methods).
/{ID}:
20.Look at the API console; you should see the nested resource with a GET method.
21.In the editor, indent under the /flights get method (not the /flights/{ID} get
method).
24.Indent under the destination query parameter and look at the possible parameters
in the shelf.
27.Go to a new line of code; you should be at the same indent level as required.
In this walkthrough, you test the API using the Anypoint Platform mocking service. You will:
Starting file
I f you did not complete the previous walkthrough, you can get a starting file h ere. This file is
also located in the solutions folder of the student files ZIP located in the Course Resources.
3. Review the information; you should see a mocking service URL.
4. Click theTry itbutton for the flightsGETmethod then click theSendbutton; you
should get a 200 status code and an empty response.
5. In the destination drop-down menu, selectSFOandclickSend; you should get the
same response.
6. Click the menu button located in the upper-left of the API console and select
Summaryto return to the resource list.
8. ClickTry itthenSend; get a 400 Bad Request responseand a message that ID is
missing.
10.Click theSendbutton.
11.Look at the response; you should get a 200 status code and an empty response.
12.Use the menu button located in the upper-left of the API console to return to the
resource list.
13.Click thePOSTmethod.
15.Look at the response; you should get the same generic 200 status code response.
22.Return to Advanced REST Client, paste the copied link and append it with/flights.
24.Make sure the method is set toGETand clickSend; you should get a 200 status code
and an empty response.
In this walkthrough, you add information about each of the methods to the API
specification. You will:
● Add a data type and use it to define method requests and responses.
Starting file
I f you did not complete walkthrough 3.1, you can get a starting file h ere. This file is also
located in the solutions folder of the student files ZIP located in the Course Resources.
4. In the API Specification Fragments dialog box, select theTraining: American Flight
Data Typeand theTraining: American Flights Example.
6. In the dependencies list, click theTraining: AmericanFlight Data Typeoptions
menu and review the menu options.
11.Return toamerican-flights-api.raml.
12.Near the top of the code above the /flights resource, add atypeselement.
NOTE:You can also add the path by navigating throughthe exchange_modules folder in
the shelf.
15.Go to a new line of code at the end of the /flights get method and indent to the
same level as queryParameters.
16.In the shelf, clickresponses > 200 > body > application/json> type >
AmericanFlight.
20.Return toamerican-flights-api.raml.
21.In the editor, go to a new line after the type declaration in the /flights:get 200
response (at the same indentation as type).
NOTE:You can also add the path by navigating through the exchange_modules folder in
the shelf.
27.In the response information, ensure you see the example array of AmericanFlight
objects.
28.Click theTry itbutton and clickSend; you shouldnow see the example response
with two flights.
29.In the editor, indent under the /{ID} resource get method.
30.In the shelf, clickresponses > 200 > body > application/json> type >
AmericanFlight.
32.In the Add new folder dialog box, set the name toexamplesand clickCreate.
34.In the Import file(s) dialog box, leave File or ZIP selected and click theChoose file
button.
39.Return to american-flights-api.raml.
40.In the editor, go to a new line after the type declaration in {ID}:/get (at the same
indentation).
44.In the API console, return to the /{ID}:get method; you should now see the response
will be of type AmericanFlight.
45.In the response information, ensure you see the example AmericanFlightExample
data.
46.Click theTry itbutton, enter an ID, and clickSend;you should now see the example
flight data returned.
50.In the file browser, click theaddbutton next tothe examples folder and selectNew
file.
51.In the Add new file dialog box, set the following values:
52.ClickCreate.
53.Delete any code in the new file and then paste the code you copied.
55.Return to american-flights-api.raml.
56.In the post method, go to a new line under type and add anexampleselement.
59.Go to a new line of code at the end of the /flights:post method and indent to the
same level as body.
62.Indented under example, add a message property equal to the string: Flight added
(but not really).
64.Look at the request information; you should now see information about the body -
that it is type AmericanFlight and it has an example.
65.Click theTry itbutton; in the Body section you should see the example request body.
66.Click theSendbutton; you should now get a 201 responsewith the example
message.
68.ClickSendagain; you should get a 400 Bad Requestresponse and a message that
the emptySeats key is required.
In this walkthrough, you make an API discoverable by adding it to Anypoint Exchange. You
will:
● Review an auto-generated API portal in Exchange and test the API.
Starting file
I f you did not complete the previous walkthrough, you can get a starting file h ere. This file is
also located in the solutions folder of the student files ZIP located in the Course Resources.
2. In the Publishing to Exchange dialog box, ensure the following values are set:
4. Wait for the API to publish then in the resultant dialog box, clickClose.
6. Click theOpen in Exchangelink; the auto-generatedportal for your American Flights
API opens in a new browser tab.
7. Select theExchangelink near the upper-left cornerof the page; you should see the
asset listing for your API.
8. In the type filter menu, selectREST APIsthen clickApply; you should still see your
API.
9. In the left-side navigation, selectProvided by MuleSoft;you should not find your
American Flights API in the public Exchange (just the Training: American Flights API).
10.In the left-side navigation, select the name of your organization (Trainingin the
screenshots); you should see your American Flights API in your private Exchange.
12.Review the page; you should see that as the creator of this API, you can perform
management operations such as editing, sharing, and downloading this version.
13.Locate theAPI version (v1)andminor version (1.0.x)near the upper-right corner of
the page.
15.In the Patch versions for 1.0 dialog box, you should see one version (1.0.0) of this
API specification has been published for this minor version and there is one API
instance for it that uses the mocking service and has a stable lifecycle state.
16.ClickClose.
17.In the left-side navigation, selectAPI instances; you should see information for the
API instance generated from the API specification using the mocking service.
20.In the left-side navigation, select the/flights GETmethod; you should now see the
API console on the right side of the page.
22.ClickSend; you should get a 200 response and theexample data displayed – just as
you did in the API console in API Designer.
25.Return to the course snippets.txt file and copy the text for the American Flights API
description text.
32.Select theVisualtab in the editor toolbar and view the rendered markdown.
33.Click theSavebutton; you should now see buttonsto discard, view, edit, or publish
the draft.
34.Click thePublishbutton; you should now see the newinformation about the API in
the API portal.
36.Return to the browser tab with your American Flights API in API Designer.
37.Return to the course snippets.txt file and copy theAmerican Flights API - /{ID}
DELETEmethod.
38.Return to american-flights-api.raml and paste the code after the {ID}/get method.
41.Click thePublishbutton.
42.In the Publishing to Exchange dialog box, examine the asset version then click the
Publish to Exchangebutton.
43.Wait for the API to publish then in the resultant dialog box, clickClose.
44.Navigate to the portal for your American Flights API using the Exchange button in
the file browser.
46.In the Patch versions for 1.0 dialog box, you should see both asset versions of the
API listed with an associated API instance using the mocking service for the latest
version.
47.ClickClose.
50.ClickSaveand thenPublish.
In this walkthrough, you share an API with both internal and external developers to locate,
learn about, and try out the API. You will:
Starting file
I f you did not complete the previous walkthrough, you can get a starting file h ere. This file is
also located in the solutions folder of the student files ZIP located in the Course Resources.
2. ClickShare.
3. In the Share dialog box, you should see that you are an Admin for this API.
4. ClickCancel.
6. In the left-side navigation, select the name of your organization if necessary.
NOTE:This is how users you share the API with willfind the API.
11.ClickSave.
19.In the API console, clickSend; you should get a 200 response with example flights
returned from the mocking service.
20.ClickAssets list.
21.Click theCustomizebutton.
22.In the Title field, change the text toWelcome to your MuleSoft Training portal!
24.In the file browser dialog box, navigate to the student files and locate the
MuleSoft_training_logo.pngfile in the resources folderand clickOpen.
27.In the file browser dialog box, navigate to the student files and locate thebanner.jpg
file in the resources folder and clickOpen.
31.In the Publish changes dialog box, clickYes,publish;you should see your
customized public portal.
32.In the browser, copy the URL for the public portal.
34.Navigate to the portal URL you copied; you should see the public portal (without the
customize button).
NOTE:As an anonymous user, you can make calls toan API instance that uses the mocking
service but not managed APIs.
● Use Anypoint Studio to build, run, and test Mule applications.
● Synchronize changes to API specifications between Anypoint Studio and Anypoint
Platform.
● Make an HTTP request to the endpoint using Advanced REST Client.
2. In the Package Explorer, selectCreate a Mule Projector selectFile > New > Mule
Projectif you already have a Mule project in yourStudio workspace.
3. In the New Mule Project dialog box, set the Project Name totraining4-american-ws.
5. ClickFinish.
8. In the Listener properties view that opens at the bottom of the window, click the
Addbutton next to connector configuration.
9. In the Global Element Properties dialog box, verify the following default values are
present.
10.ClickOK.
15.Review the information in the Global Element Properties dialog box and click
Cancel.
Display data
18.Scroll down on the right side of the Mule Palette and locate theTransformers
section.
19.Drag the Set Payload transformer from the Mule Palette into the process section of
the flow.
20.In the Set Payload properties view, click theSwitch to literalmode button for the
value field.
22.Select the Configuration XML tab at the bottom of the canvas and examine the
corresponding XML.
Comment a component
25.Select theConfiguration XMLtab at the bottom ofthe canvas and examine the
changes to the XML.
30.Watch the Console view; it should display information letting you know that both the
Mule runtime and the training4-american-ws application started.
32.Make sure the method is set toGETand that no headersor body are set for the
request.
In this walkthrough, you connect to a database and retrieve data from a table that contains
flight information. You will:
● Configure a Database connector that connects to a MySQL database (or optionally
an in-memory Derby database if you do not have access to port 3306).
● Configure the Database Select operation to use that Database connector.
Starting file
I f you did not complete the previous walkthrough, you can get a starting file h ere. This file is
also located in the solutions folder of the student files ZIP located in the Course Resources.
Seeherefor steps on importing a starting file deployablejar archive into Studio.
1. Return to the course snippets.txt file and locate theMySQLandDerby database
information.
NOTE:The database information you see may be differentthan what is shown here; the
values in the snippets file differ for instructor-led and self-study training classes.
5. Select the Database connector in the right side of the Mule Palette and drag and
drop it into the left side.
6. If you get a Select module version dialog box, select the latest version and clickAdd.
This section attempts to connect to a MySQL database and tests whether you are
successful. A successful connection requires access to port 3306. If you find that you cannot
successfully connect, a second option is described in the sections following this one that
will allow you to locally host the database along with other services that may be needed in
the course.
9. In the Select properties view, click theAddbuttonnext to connector configuration.
10.In the Global Element Properties dialog box, set the Connection to MySQL
Connection.
14.In the Maven dependency dialog box, locate theSearch Maven Centraltext field.
17.ClickEdit selected.
19.ClickFinish.
20.Back in the Global Element Properties dialog box, click theTest Connectionbutton;
you should get a successful test dialog box.
NOTE:If the connectivity test fails, make sure you are not behind a firewall restricting access
to port 3306. If you cannot access port 3306, use the instructions in the next section for
option 2.
22.ClickOKto close the Global Element Properties dialogbox and skip to theWrite a
query to return all flightssection.
Option 2 - Part 1: Run the MuleSoft training services application (if no
access to port 3306)
If you were unable to connect to the MySQL database, the second option described here
presents an alternative solution that will allow you to locally host the database along with
other services that may be needed in the course.
NOTE:Replace X.X.X with the version of the JAR file,for example 2.2.1. The application uses
ports 1527, 9090, 9091, and 61616. If any of these ports are already in use, you can change
them when you start the application as shown in the following code.
java -jar
training-services
-X.X.X.jar --database.port=1530
--ws.port=9092
--activemq.broker.url=tcp://localhost:61617 --server.port=9193
25.Look at the output and determine whether all the services started successfully or if
there was an error.
NOTE:When you want to stop the application, returnto this window and pressCtrl+C.
26.If the services started successfully, skip to theOption 2 - Part 3: Configure a Derby
Database connectorsection.
30.Use the edit functionality to copy the value in the Location column for the Java 17
JRE then close the Preference dialog.
NOTE:Be sure not to copy the location for the selectedembedded JDK.
● Windows
● Mac:
● Windows:
● Mac:
33.Look at the output and make sure all the services started.
36.In the Global Element Properties dialog box, set the Connection to Generic
Connection.
37.Set the URL and driver class name values to the Derby database values listed in the
course snippets.txt file.
40.In the Maven dependency dialog box, locate theSearch Maven Centraltext field.
43.ClickEdit selected.
45.ClickFinish.
46.Back in the Global Element Properties dialog box, click theTest Connectionbutton;
you should get a successful test dialog box.
49.In the Select properties view, add a query to select all records from the american
table.
SELECT *
FROM american
In this walkthrough, you transform and display the flight data into JSON. You will:
● Use the DataWeave visual mapper to change the response to a different JSON
structure.
Starting file
I f you did not complete the previous walkthrough, you can get a starting file h ere. This file is
also located in the solutions folder of the student files ZIP located in the Course Resources.
2. In the Mule Palette, selectCoreand locate the Transform Message component in
the Components section.
4. In the Transform Message properties view, look at the input section and review the
payload metadata.
NOTE:If you are using the local Derby database, theproperties will be uppercase instead.
5. In the Transform Message properties view, change the output type from
application/java to application/json and change the {} to payload.
7. In Advanced REST Client, send the same request; you should get a 200 response and
the American flight data represented as JSON.
NOTE:If you are using the local Derby database, theproperties will be uppercase instead.
9. Look at the example data returned for the /flights GET method.
10.Notice that the structure of the JSON being returned by the Mule application does
not match this example JSON format.
16.Click theeditbutton.
18.In the Create new type dialog box, set the type id toamerican_flights_json.
20.Back in the Select metadata type dialog box, set the first type toJSON.
24.ClickSelect.
26.Map fields with the same names by dragging them from the input section and
dropping them on the corresponding field in the output section.
27.Map fields with different names by dragging them from the input section and
dropping them on the corresponding field in the output section.
28.Concatenate two fields by dragging them from the input section and dropping them
on the same field in the output section.
30.In the Functions dialog box, select thetrimfunctionunder dw:Core and examine
the documentation for it on the right side.
31.ClickInsert.
32.In the Parameters for: trim dialog box, locate the editable contents of the text: String
section.
33.ClickCancel.
NOTE: You would normally select Finish to incorporatethe selected function or operator
into your transformation.
35.In the preview section, click theCreate requiredsample data to execute preview
link.
36.Look at the input section, you should see a new tab calledpayloadwith sample data
generated from the input metadata.
37.Look at the output section, you should see a sample response for the
transformation.
42.Look at the console; you should get a no listener found for request (GET)/flights/3.
In this walkthrough, you continue to create a RESTful interface for the application. You will:
Starting file
I f you did not complete the previous walkthrough, you can get a starting file h ere. This file is
also located in the solutions folder of the student files ZIP located in the Course Resources.
3. In the left-side navigation of the Listener properties view, selectAdvanced.
7. Click on the canvas beneath the flow and selectEdit > Paste.
NOTE:If you want, change the name of the event sourceand event processors.
14.Modify the query WHERE clause, to select flights with the ID equal to 1.
SELECT *
FROM american
WHERE ID = 1
NOTE:You did not add logic to the application tosearch for a flight with a particular ID. You
will deploy an application with this additional functionality implemented next.
19.In the Select properties view, locate theQuery InputParameterssection, click the
Switch to expression modebutton, then paste the expressionyou copied.
{'ID' : attributes.uriParams.ID}
20.Change the WHERE clause in the SQL Query Text to use this input parameter.
SELECT *
FROM american
WHERE ID =
:ID
NOTE:The API specifies that an AmericanFlight objectshould be returned and not an array.
You will update the deployed application to correct this in the next module.
25.DragListenerfrom the Mule Palette and drop it in the canvas below the two existing
flows.
27.In the Listener properties view, ensure the connector configuration is set to the
existing HTTP_Listener_config.
31.Drag theSet Payloadtransformer from the Mule Paletteand drop it in the process
section of the flow.
32.Return to thecourse snippets.txtfile and copy the American Flights API - /flights
POST response example.
33.Return to Anypoint Studio and in the Set Payload properties view, click the Switch to
literal mode button for the value field.
NOTE:This flow is just a stub. For it to really workand add data to the database, you would
need to add logic to insert the request data to the database.
39.Send the request; you should now see the message the flight was added – even
though you did not send any flight data to add.
In this walkthrough, you generate a RESTful interface from the RAML file. You will:
● Use APIkit to generate a RESTful web service interface from an API.
● Test a web service using APIkit console and Advanced REST Client.
Starting file
I f you did not complete the previous walkthrough, you can get a starting file h ere. This file is
also located in the solutions folder of the student files ZIP located in the Course Resources.
3. In the Authentication page of the Preferences dialog box, click theAddbutton.
4. In the User login dialog box, enter your username and password and clickSign in.
5. On the Authentication page, make sure your username is listed and selected.
6. ClickApplyandClose.
8. In the Properties for training4-american-ws dialog box, click theAddbutton and
selectfrom Exchange.
9. In the Add Dependencies to Project dialog box, enteramericanin the search field.
10.Select yourAmerican Flights API(not the Training:American Flights API) and click
Add.
NOTE:If you did not successfully create the AmericanFlights API in the first part of the
course, you can use the pre-built Training: American Flights API connector.
11.In the selected modules, clickAmerican Flights API,then the1.0.1version then the
version'sdown-arrow.
NOTE:If you use the pre-built Training: AmericanFlights API connector, select version 1.0.2.
13.ClickFinish.
17.Expand the API; you should see the RAML files imported from Exchange.
18.Examine the generated american-flights-api.xml file and locate the following four
flows:
● delete:\flights\{ID}
● get:\flights
● get:\flights\{ID}
● post:\flights
NOTE:You will also see a series of automaticallygenerated components like the one shown
here. These are related to error handling.
22.Locate theamerican-flights-api-mainflow.
24.In the Listener properties view, notice that the connector configuration is the
existing HTTP_Listener_config and that path is set to /api/*.
25.Click theEditbutton for the connector configuration;you should see that the same
port 8081 is used as the HTTP Listener you created previously.
26.ClickCancel.
31.Locate the new APIkit Consoles view that is created and opened in Anypoint Studio
and note that there is no data to display.
33.Run the project and wait until Mule and the application restart.
36.Select theGETmethod for /flights and then click theTry itbutton if it's present.
37.ClickSend; you should get a 200 response with theexample flight data – not all the
flights.
In this walkthrough, you wire the RESTful web service interface up to your back-end logic.
You will:
Starting file
I f you did not complete the previous walkthrough, you can get a starting file h ere. This file is
also located in the solutions folder of the student files ZIP located in the Course Resources.
3. In the Rename Resource dialog box, set the new name tointerface.xmland click
OK.
5. In the Rename Resource dialog box, set the new name toimplementation.xmland
clickOK.
6. Openinterface.xml.
8. In the Mule Palette, selectCoreand locate the Components section on the
right-side.
9. Drag aFlow Referencecomponent from the Mule Paletteand drop it into the
process section of the flow.
10.In the Flow Reference properties view, selectgetFlightsfor the flow name.
13.Drag aFlow Referencecomponent from the Mule Paletteand drop it into the flow.
14.In the Flow Reference properties view, selectgetFlightsByIDfor the flow name.
16.Openimplementation.xml.
19.Return toimplementation.xml.
In this walkthrough, you synchronize changes to an API specification between Anypoint
Studio, Design Center, and Anypoint Exchange. You will:
● Publish the modified API specification from Anypoint Studio to Exchange.
Starting file
I f you did not complete the previous walkthrough, you can get an Anypoint Studio starting
file here. If you have not developed an American FlightsAPIto add to your project, you can
also get an API Designer starting file here. Thesefiles are also located in the solutions folder
of the student files ZIP located in the Course Resources. Use these two starting files while
following the steps in the addendum following this walkthrough.
7. Return to the course snippets.txt file and copy theAmerican Flights API - /{ID} PUT
method.
9. Paste the put method that you copied after the {ID}/delete method.
13.Locate the new Git Staging view that opened in Anypoint Studio.
Review the API specification that was imported into the Mule project
16.Review the american-flights-api.raml file in that project; you should NOT see the new
put method.
Push the changes for the modified API from Anypoint Studio to Design
Center
18.Click theAdd selected files to the indexbutton inthe upper-right corner of the
Unstaged Changes section; the american-flights-api.raml file should move from the
Unstaged Changes section to the Staged Changes section.
20.Click theCommit and Pushbutton; the Staged Changes section should now be
empty.
21.In the Push Results dialog box, examine the commit log messages.
22.ClickClose.
24.Notice the addition of the PUT method after the {ID}/delete method.
27.In the API configuration dialog box, notice that the Last published version is 1.0.1.
29.ClickFinish.
30.Wait until the API publishes to Exchange and then in the Publish your API to
Exchange dialog box that appears, clickOK.
34.In the left-side navigation, clickHometo returnto the API portal for American
Flights API.
35.On the right side of the page, locate the latest asset versions listed for the API; you
should see the new 1.0.2 asset version.
NOTE:If you do not see the 1.0.2 asset version, refreshthe page.
38.ClickSaveand thenPublish.
Review the API specification that was imported into the Mule project
again
40.Locate the American Flights API in the training4-american-ws project and notice that
it is still v1.0.1.
41.Review the american-flights-api.raml file; you should still NOT see the new put
method.
Update the version of the API used in the Mule project and rescaffold
the flows
43.In the Properties for training4-american-ws dialog box, select theAmerican Flights
API; an Update version button should appear.
45.ClickApplyandClose.
46.In the dialog box that appears, clickYesto scaffold American Flights API
specification, and clickYesif you get a ConfirmPerspective Switch dialog box.
47.When the scaffolding is complete, review the flows in interface.xml; you should now
see five method flows, including the new put:\flights\{ID} method.
48.Look at the get:\flights\{ID} method; it was not overwritten and still has your change
to use a Flow Reference component.
Create your editable API in Exchange with the correct asset number
2. Publish the API to Exchange with an asset/version of 1.0.1/v1 and a stable lifecycle
state.
Create your Studio application and replace the static API with your
editable API
4. Right-click the project and selectManage Dependencies> Manage APIsto delete
Training: American Flights API and to add your American Flights API from Exchange.
Transfer the flow references from the old scaffold to the new
5. Copy/paste the flow reference from interface.xml get:\flights to its corresponding
location in american-flights-api-2.xml replacing any transforms.
8. Set the main Listener in interface.xml to use the configuration HTTP_Listener_config.
9. Save your changes; you should now be ready to perform this walkthrough.
NOTE:When using these starting files, walkthroughsteps such as updating the API portal
information in Exchange may not match the screenshots.
In this walkthrough, you deploy and run your application on CloudHub. You will:
NOTE:If you do not have a working application atthis point, import the
wt4-7_training4-american-ws_solution.jar solution into Anypoint Studio and work with that
project.
Starting file
I f you did not complete the previous walkthrough, you can get a starting file h ere. This file is
also located in the solutions folder of the student files ZIP located in the Course Resources.
2. In the Package Explorer, right-click the project and selectAnypoint Platform >
Deploy to CloudHub.
4. In the Anypoint Platform dialog box, ensure the Deployment Target is set to the
shared space for the CloudHub 2.0 default.
5. On the Runtime tab, make sure the runtime version is set to the version your project
is using, Release Channel is set to Edge, Java version is set to Java 17, and the replica
size is set to0.1 vCores.
NOTE:If you don’t know what version it is using,look at the Package Explorer and find a
library folder with the name of the server being used, like Mule Server 4.x.0 EE.
7. In the resultant Runtime Manager dialog box, click theOpen in Browserbutton (you
don't have to wait for your application to fully deploy).
NOTE:The Runtime Manager dialog box will appear afterthe build process for the project
completes. Build progress can be seen in the Studio console and may take some time to
finish.
8. In the Runtime Manager browser window that opens, chooseSandboxfor an
environment (if prompted) then locate the status of your deployment on your
application’s settings page.
NOTE:If your browser window brings you to RuntimeManager’s applications page instead
(for example if you are required to log into the Anypoint Platform again), click on the name
of your application,training4-america-ws, to bringyou to its settings page.
NOTE:In addition to the log output, the round statusindicator to the left of the application
name will turn green once successfully started. If your application does not successfully
deploy and start, read the logs to help figure out why. Examine the errors, troubleshoot
them, fix them, and then redeploy.
13.Locate the link for the application on its new domain in the Public Endpoint field:
https://training4-american-ws-{unique_id}.{shard}.{region}.cloudhub.io.
14.Click the link; a GET request will be made to that URL in a new browser tab and you
should get a message that there is no listener for that endpoint.
NOTE:If you are using the local Derby database, yourapplication will not return results
when deployed to CloudHub. You will update the application with a version using the
MySQL database in the next section, so it works.
16.Add a query parameter calleddestinationto the URL and set it equal toSFO.
17.Send the request; you should still get all the flights.
NOTE:You did not add logic to the application tosearch for a particular destination. You will
deploy an application with this additional functionality implemented next.
22.Selecttraining4-american-ws-v2_SP.jarand clickOpen.
NOTE:The filename differs slightly for instructor-led and self-study training classes. This
updated version of the application adds functionality to return results for a particular
destination. You will learn to do this later in the Development Fundamentals course.
NOTE:Because this can take some time for trial accounts,your instructor may move on with
the next topic and then come back to test this later.
25.Return to the browser tab with a request to the API implementation on CloudHub
with a destination of SFO and refresh it; you should now get only flights to SFO.
In this walkthrough, you create and deploy an API proxy for your API implementation on
CloudHub. You will:
● Use API Manager to create and deploy an API proxy application.
● Set a proxy consumer endpoint so requests can be made to it from Exchange.
● Make calls to an API proxy from API portals for both internal and external
developers.
Starting file
This walkthrough uses Anypoint Platform. There is no starting file. To complete the
walkthrough, you must have completed the preceding walkthrough.
2. In the main menu, selectAPI Managerand the Sandbox environment if necessary;
you should see no APIs listed for the Sandbox environment.
4. On the APIs / Add API page, select theMule Gatewaybutton for the Runtime
settings.
6. Set the rest of the Runtime settings to the following values:
7. ClickNext.
8. For the API settings, ensureSelect API from Exchangeis selected then select your
American Flights APIin the Select API section.
9. Ensure the rest of the API settings fields are set to the following values:
10.ClickNext.
11.For the Downstream settings, leave the default values and expandAdvanced
optionsand examine the additional fields and values.
12.ClickNext.
14.On the settings page fortraining4-american-ws, locate the link for the application in
the Public Endpoint field:
https://training4-american-ws-{unique_id}.{shard}.{region}.cloudhub.io.
16.On the browser tab with API Manager, paste the copied address value in the
Upstream URLfield and appendapito the end of thepasted value.
17.ClickNext.
NOTE:If it does not successfully deploy, examinethe logs for your proxy application in
Runtime Manager to help figure out why the application did not deploy. If you had errors
when deploying, troubleshoot them, fix them, and then redeploy.
21.In the left-side navigation, selectApplications;you should see the proxy application
listed along with your original application deployed from Anypoint Studio.
22.Click the row for the proxy (not its name) and review its information in the right
section of the window.
23.Return to the browser tab with API Manager and review the API proxy information at
the top of the page.
24.In the left-side navigation, click theAPI Administrationlink; you should now see
your American Flights API listed.
25.In the API list, click the name of the API; you should be returned to the summary
page for the API.
28.On the summary page, look at the requests graph in the Key Metrics section; you
should not see any API requests yet.
NOTE:You may get spurious 4xx client errors whichyou can safely ignore.
NOTE:You may need to refresh your browser page beforeclicking Manage versions.
32.ClickClose.
34.In the API console, notice that there is no drop-down menu to select an instance
and the URL indicates that only the mocking service is available.
35.In the left-side navigation, selectAPI instances;you should see that the new proxy
instance does not have a URL.
37.ClickManage applicationin the information for your proxy application in the right
section of the window.
38.On the settings page fortraining4-american-api, locatethe link for the proxy
application in the Public Endpoint field:
https://training4-american-api-{unique_id}.{shard}.{region}.cloudhub.io.
43.On the Settings page for your American Flights API, locate the Consumer endpoint
field in the Downstream section and paste the copied value in the field.
46.Click Save & Apply and wait for your API to be deployed.
48.Refresh the API instances page for your American Flights API; you should see the
new label and the URL.
49.In the left-side navigation, selectHometo returnto the API's main page.
51.ClickClose.
53.In the API console, you should now see a drop-down menu to select a server; click
the drop-down arrow and notice your API proxy instance is now available as a choice.
55.Click theSendbutton; you should now see the real data from the database, which
contains multiple flights.
60.In the API console, notice that there is no drop-down menu to select an instance
and the URL indicates that only the mocking service is available.
62.In the left-side navigation for American Flights API, selectAPI instances.
66.In the API console, change the API instance fromMockingServicetoSandbox - No
policy.
68.Return to the browser tab with API Manager and, in the left-side navigation, select
API Summary.
70.Look at the Request chart again; you should now see data for some API calls.
72.Click in the time and date drop-down menu near the upper-right corner and select1
hourfor the show-last time range.
73.ClickConfirm.
In this walkthrough, you govern access to the API proxy. You will:
Starting file
This walkthrough uses Anypoint Platform. There is no starting file. To complete the
walkthrough, you must have completed the preceding walkthrough.
1. Return to the summary page for your American Flights API in API Manager.
̀
6. ClickNext.
7. On the Configure Rate limiting policy page, set the following values:
10.ClickApply; you should see the policy listed under API-level policies.
14.Return to the browser tab with your American Flights API in Exchange.
NOTE:You may need to refresh the page to see thenew label for the API instance.
18.Return to the browser tab with your American Flights API in API Manager.
21.In the Add SLA Tier dialog box, set the following values:
● # of Reqs: 1
22.Click theAddbutton.
● # of Reqs: 1
28.In the quality of service category, choose theRatelimiting - SLA based policyand
clickNext.
29.On the Configure Rate limiting – SLA based policy page, look at the expressions and
see that a client ID and secret need to be sent with API requests as headers.
30.SelectExpose Headers.
33.Change the Instance label toRate limiting – SLA basedpolicy, clickSave & Apply,
and wait for your API to be deployed.
35.Refresh the page and select the /flights GET method to make a call to theSandbox –
Rate limiting – SLA based policy.
36.ClickSend; you should get a 401 Unauthorized responsewith the error Invalid client
id or secret.
In this walkthrough, clients request access to an API proxy and administrators grant access.
You will:
● Request application access to SLA tiers from private and public API portals.
Starting file
This walkthrough uses Anypoint Platform. There is no starting file. To complete the
walkthrough, you must have completed the preceding walkthrough.
2. In the left-side navigation, selectHometo returnto the API's home page.
NOTE:Other internal users that you shared the APIwith that do not have Edit permissions
will see a different menu.
4. In the Request access dialog box, selectRate limiting- SLA based policyin the API
Instance drop-down menu.
6. In the Create new application dialog box, set the name toTraining internal appand
clickCreate.
7. In the Request access dialog box, set the SLA tier toFree.
9. In the Request API access dialog box, you should see that your request has been
approved; view the assigned values for the client ID and client secret.
10.ClickClose.
12.In the left-side navigation, select Home to return to the API's home page; you should
now see a Request access button (refresh if necessary); hover over it and notice the
login tooltip.
13.ClickLoginin the upper-right corner; you shouldget a page to sign in or create an
Anypoint Platform account.
NOTE:Instead of creating an external user, you willjust use your existing account.
16.In the Request access dialog box, selectRate limiting- SLA based policyin the API
Instance drop-down menu.
18.In the Create new application dialog box, set the name toTraining external appand
clickCreate.
19.In the Request access dialog box, set the SLA tier toSilver.
20.ClickRequest access.
22.In the portal main menu bar, right-clickMy applicationsand select to open the link
in a new tab; on the new tab, you should see the two applications you created.
23.Click the link forTraining external app; you should see what APIs the application
has access to, values for the client ID and secret to access them, and request data.
24.Leave this page open in a browser so you can return to it and copy these values.
25.Return to the browser window and tab with the Settings page for American Flights
API v1 in API Manager.
26.In the left-side navigation, selectContracts; youshould see the two applications that
requested access to the API.
Add authorization headers to test the rate limiting – SLA based policy
from an API portal
30.Return to the private/incognito browser window and tab with the American Flights
API portal in the public portal.
31.Try again to make a call to theSandbox – Rate limiting– SLA based policy; you
should still get a 401 Unauthorized response.
36.Hover over theShowlink next to Client Secret then click theSave to clipboardicon
icon to copy its value.
37.Return to the browser tab with the API console in the public portal.
40.In the course snippets.txt file, record these client_id and client_secret values in the
section reserved for this module.
In this walkthrough, you add client ID enforcement to the API specification. You will:
● Modify an API specification to require client id and client secret headers with
requests.
● Call a governed API with client credentials from API portals.
NOTE:If you do not complete this exercise for Fundamentals,the REST connector that is
created for the API and that you use later in the course will not have client_id
authentication.
Starting file
This walkthrough uses Anypoint Platform. There is no starting file. To complete the
walkthrough, you must have completed the preceding walkthrough.
1. Return to the browser tab with American Flights API v1 in API Manager.
3. In the Rate limiting – SLA based policy options menu, selectAPI specification
snippet.
4. On the API specification for Rate limiting - SLA based page, select theRAML 1.0tab.
6. In the API Manager asset path near the top of the page, clickAmerican Flights API.
7. Return to the browser tab with your API in Design Center.
8. Go to a new line after thetypesdeclaration and pastethe traits code you copied.
9. Go to a new line after the /flights resource declaration and indent.
is: []
11.Make sure the cursor is inside the array brackets and add the client-id-required trait
name as an array element.
12.Repeat this process so the trait is applied to all methods of the {ID} resource as well.
13.In the API console, select one of the resources and clickTry it(refresh if necessary).
14.In the Headers section, you should now see fields to enter client_id and
client_secret.
16.Enter any values for the client_id and client_secret and click Send; you should get a
200 response with the example results.
17.Click thePublishbutton.
18.In the Publishing to Exchange dialog box, examine the asset version then click the
Publish to Exchangebutton.
19.Wait for the API to publish then, in the resultant dialog box, clickClose.
Update the managed API instance to use the new version of the API
specification
20.Return to the browser tab with American Flights API v1 in API Manager.
21.Refresh the page then locate the asset version displayed at the top of the page; you
should still see 1.0.2.
24.ClickChange; you should see 1.0.3 (Latest) as the asset version displayed at the top
of the page.
Test the rate limiting – SLA based policy in the API console in
Exchange
26.Refresh the home page for the API; you should see the 1.0.3 asset version displayed
at the top of the page with the Latest label next to it.
27.Click theManage versionsbutton; you should see the new version listed with
instances for both the Mocking Service instance and the new proxy.
28.ClickClose.
29.Click theGETmethodfor the flights resource; you should see required text fields for
client_id and client_secret and no longer need to add the headers manually for each
request.
NOTE:You will test and use the authentication withthe REST connector later in the
Fundamentals course.