Create a stock manager API that calls the IBM MQ stock query application.
Before you begin
Use the IBM® z/OS® Connect API toolkit to
Stop
the stockmanager
API, and then Remove
the
stockmanager
API.
Procedure
-
Start IBM® Explorer for z/OS and open the z/OS Connect (OpenAPI 2) perspective.
-
From the main menu, click
-
Complete the sections for the new API project and click
Finish.
The
IBM z/OS Connect API editor opens.
-
Change the value of the path attribute to /stock/items/{item-id}, where
{item-id} indicates a path parameter whose value is substituted at
runtime.
For the moment, you use the HTTP GET method of the service only to make stock
queries. Delete the other three methods and save the API.
-
Import the service archive file that you created in the task Create a two-way IBM MQ service.
Click
Service..., select
File System, and find the
C:\sars directory and select
stockQuery.sar.
-
Click Open, OK, OK, and
Save.
The HTTP GET method is now associated with the
stockQuery
service.
-
Click Mapping... and select Open Both
Mappings.
The
Service Interface Mapping editor
opens.
-
Explore the contents of the Response Mapping editor.
For this
scenario, use the default mapping, which passes the response without modification from the service
back to the caller of the API. When you finish exploring, close the Response
Mapping editor.
-
Use the Request editor to map the item-id path parameter that you created
in step 4 to the item-id in the
payload.
This mapping creates a more natural REST API where the caller of the API will
not need to pass any payload in the HTTP GET request.
- Left-click and hold on the item-id path parameter, then drag to the item_id integer on
the right.
- Save your changes.
Results
You have created a stock manager API.