Create an API to invoke the IBM MQ stock query service

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

  1. Start IBM® Explorer for z/OS and open the z/OS Connect (OpenAPI 2) perspective.
  2. From the main menu, click File > New > z/OS Connect API Project
    Screen capture shows the IBM z/OS Connect API Project entry screen for a new project called stockManager.
  3. Complete the sections for the new API project and click Finish.
    The IBM z/OS Connect API editor opens.
    Screen capture of the IBM z/OS Connect API editor with the stockManager project loaded.
  4. 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.
    Screen capture of the IBM z/OS Connect API editor with only the GET method selected.
  5. 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.
    Screen capture of the IBM z/OS Connect API editor loading the service archive file.
  6. Click Open, OK, OK, and Save.
    The HTTP GET method is now associated with the stockQuery service.
  7. Click Mapping... and select Open Both Mappings.
    The Service Interface Mapping editor opens.
    Screen capture of the IBM z/OS Connect API editor loading the service archive file.
  8. 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.
  9. 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.
    1. Left-click and hold on the item-id path parameter, then drag to the item_id integer on the right.
      Screen capture of the IBM z/OS Connect API editor mapping the item-id path parameter to the item-id in the payload.
    2. Save your changes.

Results

You have created a stock manager API.

What to do next

Deploy the stock manager API