By Amar Shah & Uma Korukonda

Enterprises consist of many endpoints, such as on-premise systems, cloud and mobile applications etc., businesses work better if these endpoints are securely connected.
Application Integration Suite V1.0 delivers a platform for hybrid integration and enables you to innovate faster to take advantage of changing customer needs and market trends.

Application Integration Suite offers the following products:

  • IBM Integration Bus Advanced
  • IBM API Connect Professional
  • IBM WebSphere Cast Iron Hypervisor Enterprise Edition

In this article we show a scenario on how these products work together to form a API-led solution that enables you to easily and quickly connect environments that are comprised of cloud and on-premise applications.

Scenario:
Create an API for the Integration that returns the list of orders for a given customerId.

Assumption:

  • Customer details are stored in backend SAP or Database system.
  • Order details are stored in Cloud services Salesforce/Netsuite.

Solution:

  • Use IBM Integration Bus to create integration for interacting with backend SAP system. The integration flow in IBM Integration Bus is created as a REST Project so that it can be easily exposed as an API to API Connect.
  • Use Cast Iron to interact with Cloud SaaS services like Salesforce.com
  • The customer details retrieved by IBM Integration Bus from SAP are passed on to CastIron either using MQ or Http endpoints.
  • CastIron connects to cloud service (Salesforce / Netsuite) using the cloud connectors available out-of-the box and fetches the order history for the given customer record.
  • Information is returned back to IBM Integration Bus which in turn is responded back to the caller of the API.
  • Push the REST API to API Connect using IBM Integration Bus Toolkit.

The figure below shows the high level architecture and Interaction diagram of various components involved.
Fig1

Note: The integration scenario described in this blog is primarily targeted for the situations where you may already have Cast Iron or IBM Integration Bus or both running and how you could create a hybrid solution to securely integrate on-premise and cloud applications. Finally we show how API Connect enables you to rapidly build new APIs by using integration technology.

We implement this solution in 3 steps.

Step1: IBM Integration Bus REST API Project and Integration with backend EIS system (SAP)

Create a REST API project in IBM Integration Bus Toolkit by importing Swagger 2.0 document.
A Swagger document is the REST API equivalent of a WSDL document for a SOAP-based web service. The Swagger document specifies the list of resources that are available in the REST API and the operations that can be called on those resources. The Swagger document also specifies the list of parameters to an operation, including the name and type of the parameters, whether the parameters are required or optional, and information about acceptable values for those parameters. IBM Integration Bus supports version 2.0 of the Swagger specification.
In this particular example, you can see a GET operation. The input for this operation is customerId. The base URL for this rest API is highlighted as well.

Fig2

The REST Project automatically creates a template for you with HTTP REQUEST and REPLY pair and as you start implementing each of the Operations from the imported JSON, it gets added as a corresponding subflow to the main message flow. As you can see below, getCustomer subflow represents the GET operation that we implemented.

Fig3

The HttpInput Node contains the Base URL for the REST API. This will be populated automatically in the HttpInput node based on the basePath definition in swagger json file.
Fig4

The message received via this transport will be in JSON by default.
Fig5

For every operation and it’s method type that has been imported from the swagger document, there is an ‘Implement the operation’ link . Upon clicking this link, a new subflow is automatically created and opened.

We describe the following two methods for integration between IBM Integration Bus & CastIron:

  1. Async communication using IBM MQ.
  2. Sync communication using WebService.

[1] Async communication using IBM MQ:

Implement the operation by adding any of the standard message flow nodes that are available with IBM Integration Bus to the subflow.

The getCustomer subflow implementation:
Fig6

Information about the current operation is automatically placed into the local environment tree. You can use this information in your implementation if you want to determine which operation in the REST API was called, which HTTP method was used, the request path, or the request URI.

In order to implement Asynchronous communication style between IBM Integration Bus& Cast Iron , we must store the Request Identifier of the client so that when we receive the response back from CastIron, we can restore this identifier to reply back to the same client. Since the request and reply flows are different, we store this ID into a SHARED variable so that it is visible across the flows within the same Integration server.
Fig7

We put this message into an MQ queue ‘TO_SAP_REQUEST’ from where another message flow which drives the integration with backend SAP system as shown below.
Fig8

Implementation of the message flow that integrates with backend SAP system.
Fig9

The MQInput Node is configured to read from the queue where the WebService message flow writes the request. The request message is in XML format , hence we set the Message Domain to XMLNSC.
Fig10

The SAP Request Node executes the customerGetDetail BAPI to retrieve the details of the customer for the given customerId that is received via REST query (GET).
Fig11

The Data object received from SAP is then sent to an MQ queue from where Cast Iron orchestration is polling the messages.
Fig12

This will drive the CastIron workflow. This is described in the section “Step 2: Implement the Cast Iron workflow to connect to cloud SaaS services”.

[2] Sync communication using WebService

In this style of implementation, we use use HttpRequest Node in IBM Integration Bus message flow to invoke the service in CastIron. This is illustrated as shown below:
After implementing the REST operations (GET method), the message flow design appears as:
Fig37

The getCustomer subflow is implemented as follows:
After receiving customer details from SAP system, the Cast Iron orchestration is invoked via WebService request using HttpRequest Node.
Fig38

The Web Service URL points to the location of Cast Iron endpoint that is listening for the SF_OrderCreate on port no. 2016
Fig39

Step 2: Implement the Cast Iron workflow to connect to cloud SaaS services.

As we discussed in above section, we illustrate the integration between IBM Integration Bus & CastIron in two ways

  1. Async mode using IBM MQ endpoints
  2. Sync mode using WebServices endpoints

[A] Async communication using IBM MQ endpoints

  • In Step1 above, we retrieved the customer record from SAP and put that into an MQ queue.
  • Start the CastIron workflow with MQ endpoint. Configure it to poll the message from the queue to which MQOutput node has put the message (TO_CI_SFDC).
  • Use readXML activity to converts the data read from MQ queue in string format to the XML format using the Xml schema defined in the configuration so that it can be passed on to the next activity of the orchestration.
  • Parse for account object and create an account in the SFDC using the details from the xml data above.This will return an id if the account creation is successful.
  • Parse for Contract object to create a contract in SFDC. Use the account id created above as a input parameter for creating a contract object in the SFDC . If the contract is created in SFDC, then it will return a ID which then used for creating an order object in SFDC
  • Use the account id and contract id created in the above activities and provide more details to create an order. If the order is created in SFDC , then it will return a ID which can be used to retrieve the details of that order.
  • Convert the object record into XML and put that into an MQ queue using put Message activity.

Fig13

Configuration of MQ endpoint

  • Here we specify the Host, MQ listener , Queue manager and Queue details from where the CastIron workflow is going to read the messages from.
    Fig14 Fig15
  • Map input data to the fields in Saleforce to create Account object and create an Order record.
    Fig16
  • Endpoint configuration to connect to Salesforce.com
    Fig17
  • Map the data with the object in SFDC
    Fig18
  • Retrieve the Order record and Salesforce and convert it to XML format and write back to an MQ queue.
    Fig19
  • From this queue, the message flow in IBM Integration Bus will read the message and send it as a response to the requesting client.

  • The output message from above CastIron MQ endpoint is now picked up by the IBM Integration Bus message flow which will drive the HTTP response flow as seen below.You can note that the Queue name in the CastIron workflow PutMessage endpoint is same as queue name for MQInput in IBM Integration Bus message flow.
    Fig21
  • In the compute node , we then restore the RequestIdentifier so that the response is sent the correct client who had requested this service.
    Fig22
  • This completes the integration between IBM Integration Bus & CastIron using MQ based connectivity.

    [B] Sync mode using WebServices endpoints

    The following figure shows the CastIron orchestration with endpoints Http Receive Request and Http Send Response. (We have replaced with MQ Poll and MQ put message activities in CastIron workflow with Http equivalents).
    Fig40

    The Http Receive Request endpoint is configured with service name and port number that is used in IBM Integration Bus HttpRequest URL.
    Fig41

    The configuration steps for Salesforce connectivity remain the same.

    Deploying REST Project to Integration Node

    The REST API project does not work with broker level http listener (which is a default setting for a newly created broker), so the deployment may fail. Hence, Modify the broker to use Execution Group level embedded listener.

    mqsichangeproperties  -e  -o ExecutionGroup -n httpNodesUseEmbeddedListener -v true

    Package the bar file and Deploy the REST API project to Integration Server.
    Fig23

  • You can quickly verify your REST API by invoking it via a web browser.
    http://localhost:7800/customerorders/v1/customers/0000000001
Step 3: Push REST API project in IBM Integration Bus to API Connect to externalize it as a public URI and for governance

We now describe the steps to register Integration Bus REST API with API Connect.
Right Click the deployed REST API in Integration Server. The dialog box offers an option to push the REST API project to API Connect service.
Fig24

Enter the connection details where API Connect service is running and ent Authentication credentials.
Fig25

The wizard automatically fetches the Organization details that you are registered with for your API Connect account. Select the Organization from the drop down list that you want the REST API to be hosted at and then Click ‘Finish’.
Fig26

Now, go to the API Connect console, and you would see the REST API project that we just pushed under the ‘APIs’ tab.
Fig27

The available Operations for this REST API are listed under Operations tab.
Fig28

Click on the ‘Edit’ icon as highlighted above. Under the implementation tab, Enter the proxy URL which the API Connect service will internally use to connect to On-prem system where IBM Integration Bus is running. If you are using a cloud hosted API Connect service, you may need to use the hostname/Port generated by the Secure Gateway.
Fig29

Create a new plan to publish the above REST operations. You can define the limits to your REST operation . For example, we have put a limit of 35 requests per minute for this GET operation.
Fig30

Save the plan and Stage it to a ‘Sandbox’ environment. Once the plan is Staged successfully, go to the Management tab from the left side menu. For publishing the plan. The Publish menu appears on clicking the icon under Actions as highlighted below.
Fig31

The dialog box offers you option to specify the visibility of the plan and the subscribers of this plan. For this scenario we use default options. When the plan is published successfully, the status gets updated as shown above.

Now go to the Environments section from the left side menu and select the Portal tab and click Portal URL under Basic Developer Portal as shown below.
Fig32

Sign in to the API Manager developer portal as shown below. Go to the Application section from left side menu and Click + sign to add a new application
Fig33

After adding the Application, Click APIs tab at left side menu and click Select a Plan drop down list as shown below. Expand the Operations by clicking the sign under Details column to get the public URL generated by API Connect service.
Fig34

You can test your API using the Test section as shown below. Enter the customerId as a input parameter to this GET request.
Fig35

The response received is shown as below.
Fig36

Summary
This offering shows that how you can accelerate your integration creation and management for cloud and on-premise resources through the rich connectors and easy to use tooling. The capabilities of the products demonstrate how rapidly you can design APIs with essential security policies and share APIs across organizational boundaries and environments.
Note:
IBM Integration Bus v10.0.0.4 provides a ‘SalesforceRequest node’, which enables you to communicate with Salesforce.com to create, retrieve, update, and delete Salesforce records.
The SalesforceRequest node is available on Windows and Linux x64 systems, in developer mode and applicationIntegrationSuite mode. The detail information about this new capability and step-by-step procedure to configure Salesforce Request Node in IBM Integration Bus v10 is illustrated in the Blog :
Integrating with Salesforce using a REST API created in IBM Application Integration Suite 1.0

2 comments on"Create an Integration Solution as an API using IBM Integration Bus, Cast Iron and API Connect"

  1. This is a good example to showcase, few doubts:

    1.I am not able to use the push to API management to API connect 5.0, its working only on the older version when it comes to cloud.
    2. Customer data should be in sales force and order data in SAP but in the example its other way round.
    3. is API connect professional available on premise.?

    • Thank you for your interest in the blog.

      To answer you queries,
      As of IIB v10.0.0.4, the push to API Management from Toolkit is support only for API Connect 4.x. However, you can still work with IIB v10 (any fixpack) and API Connect 5.0 by manually importing the Swagger document for the REST API (available from the IIBv10 web UI) into the API Connect web UI.
      An additional step you would need to do is add a proxy assembly to the API once it’s in API Connect so that it knows how to send the requests onto IIB.

      Regarding API Connect professional on premise, please refer to IBM’s statement of general direction at :

      http://www-01.ibm.com/common/ssi/cgi-bin/ssialias?infotype=an&subtype=ca&appname=gpateam&supplier=897&letternum=ENUS216-019#sodx

      Hope this helps.

Join The Discussion

Your email address will not be published. Required fields are marked *