Skip to content

Latest commit

 

History

History
68 lines (42 loc) · 4.99 KB

runwarehouse.md

File metadata and controls

68 lines (42 loc) · 4.99 KB

How to setup and run the Warehouse sample

Steps required to setup and run the Warehouse sample in IIB and App Connect.

Introduction

The Warehouse sample is very easy to setup and run. For a detailed explanation of the contents of the sample, see What the Warehouse sample does.

To run the sample requires an IIB system and App Connect. For IIB there are two possibilities:

If you do not currently have access to either of these systems, click the links for information about how to get access.

For the sample to work, App Connect must be able to make direct HTTP calls to IIB; the HTTP port in the IIB server must be accessible from the internet. If you use the IIB on-premises option, you can install the IBM Secure Gateway from within App Connect to enable communication between your on-premises IIB server and App Connect.

IBM App Connect only runs in the cloud, there is no on-premises option.

Setting up IIB

  1. Import all the IIB projects from this repository into your IIB Toolkit workspace. Use the "Import existing projects into workspace" wizard to do this.
  2. Deploy the BAR file Warehouse.bar that is provided in the WarehouseNewStockEventToAppConnect project to an IIB server. Note: If you deploy the BAR file to IIB on Cloud, you must turn off basic authentication for your application.

IIB is now running and waiting for App Connect to register.

Configuring the Application Definition file

  1. Make a copy of the Warehouse Webhook definition file file and open the file in either a text editor or, for a better presentation, the online Swagger editor:
  2. For "host", change the host and port to have the correct values for your IIB system. The HTTP port in IIB defaults to 7800. For IIB on Cloud, use the value for "Host" under "Service URLs" in the Integration Details view (no port is required).
  3. For "schemes", you must change the protocol to HTTPS if using IIB on Cloud or if your IIB system requires it.

The Application Definition file is now ready to be used by App Connect

Creating the App Connect 'Warehouse' application

  1. Log in to App Connect and upload your Application Definition file. You can call the application whatever you like (for example: 'Warehouse').

The 'Warehouse' application is ready to be used as a source application in an App Connect flow.

Creating an App Connect flow

  1. Create a new flow and select the 'Warehouse' application as the first application and Google Sheets as the second application.
  2. Select newStock as the trigger, and Create new row as the action.
  3. If you haven't already connected a Google Sheets account to App Connect, click the Connect button and provide your account details.
  4. Select the Google Sheets spreadsheet and worksheet that you want to use as your target. Note: The worksheet must have column names in the first row of the spreadsheet.
  5. Map fields from the 'Warehouse' application to columns in the Google Sheets spreadsheet.
  6. Save your flow and turn it on.

The 'Warehouse' application in App Connect should now subscribe to IIB for any available newStock events. You can check the list of subscribers by doing a REST GET to the Webhook URL running in IIB. For example, type the following command at a command prompt:

curl -X GET http://localhost:7800/user01/warehouse/stock/hook

You should get a response similar to the following:

[{"id":1,"callback":{"url":"https:\/\/webhook-connector-provider-conntest.mybluemix.net\/webhooks\/4c290d9e629b84a5b778e392314ef0f0\/a10953e0-fb1b-11e5-a1d3-8f07ad38ea36\/Events"},"event_types":["newStock"]}]

If the response is [], The 'warehouse' application has not subscribed to IIB successfully.

Driving the integration end-to-end

POST the event that is contained in purple_jumper.txt to the IIB message flow at the path /drive/newstock. For example, type the following command at a command prompt, or use your favourite REST client:

curl -X POST http://localhost:7800/drive/newstock --data @purple_jumper.txt

You should get the following response from the message flow, via the curl command:

{"id":"4444671","name":"woollen jumper","description":"woollen jumper","size":"12","color":"purple"}

The IIB message flow processes the newStock request and sends it to anyone that is subscribed to the Webhook; in this case, the 'Warehouse' application in App Connect. The application receives the event and triggers the flow. The flow updates the Google Sheets spreadsheet with the fields from the 'Warehouse' application.

Now you have the Warehouse sample working why not try modifying it to interact with your own systems; see How to change the Warehouse sample to integrate with your own backend system.