Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 8 Using Sample Projects : The InvokePartnerREST Project

The InvokePartnerREST Project
The Invoke_partner_rest project describes how to use the REST Dispatch and Reply activity to expose TIBCO ActiveMatrix BusinessWorks processes as RESTful web services and how to use the Invoke REST API activity to invoke the exposed RESTful web services.
Business Scenario
This project implements a complete workflow of asking for a loan from a bank through the mortgage broker as shown in Figure 19.
Here, a lender wants to ask for a loan from Bank C. The lender sends his request to the local broker. After receiving the loan request, the broker sends the loan request to Bank C that the lender prefers and Bank C invokes the CreditCheck service to check whether the lender is qualified for the loan.
Figure 19 Workflow of a Loan Request
Process Definition
Four process folders are included in the Invoke_partner_rest project:
Borrow  This folder contains one process, LoanRequestProcess, which is used by the lender to initiates a loan request.
See LoanRequestProcess (in the Borrow Folder) for more details.
MortgageBroker  This folder contains a PartnerProcesses process folder and a LoanRequestProcess process for the broker to handle the request from the lender.
The LoanRequestProcess process is used for the broker to send the request to the corresponding bank according to the request from the lender.
See LoanRequestProcess (in the MortgageBroker Folder) for more details.
The PartnerProcesses folder contains the partners of the broker. That is, banks that are available for the banker to invoke. The bank process in this folder invokes the corresponding bank service when a request is received.
See PartnerProcess(in the MortgageBroker Folder) for more details.
Banks  This folder contains two separate RESTful services to be invoked. Each folder contains one shared resource and three processes. See Banks for more details.
CreditCheck  This folder contains one shared resource and three processes. See Credit Check for more details.
LoanRequestProcess (in the Borrow Folder)
The LoanRequestRrocess process in the Borrow folder as shown in Figure 20, sends the loan request by invoking a local process.
Figure 20 The Lender Initiates a Loan Request
LoanRequestProcess (in the MortgageBroker Folder)
The LoanRequestProcess in the MortgageBroker folder as shown in Figure 21, sends the loan request to the corresponding bank based on the information provided by the lender.
If the lender has a preferred bank, the CallPreferredBankProcess is run.
If the lender has no preferred bank, the CallDefaultBankProcess is run.
Figure 21 Sending the Request to the Bank
PartnerProcess(in the MortgageBroker Folder)
The loan request is sent to the corresponding Bank process in the PartnerProcess folder. Here, the lender chooses Bank_C, so the loan request is sent to Bank_C. As Figure 22 shows, Bank_C invokes its bank service to handle the loan request.
Figure 22 The Broker Sends the Loan Request to the Bank
Banks
This folder contains two folders: Bank_A and Bank_C.
Take the Bank_C folder as an example. As shown in Figure 23, one shared resource and three processes are included in the Bank_C process folder.
Figure 23 Bank_C Process Folder
The Bank_C_HTTP_Connection shared resource is used to receive the incoming HTTP request.
The Bank_C_Process process is exposed as a RESTful web service. When a loan request is received, it invokes the subprocess to check the credit of the lender as shown in Figure 24.
Figure 24 The Bank_C_Process
The Bank_C_Service process is used to expose the Bank_C_Process process as a RESTful service as shown in Figure 25.
Figure 25 Bank_C_Service
shows how the HTTP request and response are mapped to the input and output of the bound Bank_C_Process process.
Figure 26 Bank_C_Service
 
The BankSubProcessForCreditCheck process is called by the Bank_C_Process process. The BankSubProcessForCreditCheck process invokes the CreditCheck service to check the credit history of the lender as shown in Figure 27.
Figure 27 Invoking the CreditCheck Service
Credit Check
The CreditCheck folder includes one shared resource and two processes as shown in Figure 28.
Figure 28 Credit Check Folder
The CreditCheckHTTPConnection shared resource is used to receive incoming HTTP request.
The CreditCheckProcess process is exposed as a RESTful service. When the request of checking credit is received, it checks the credit of the account provided by the bank and sends the check result (approved or rejected) to the bank.
The CreditCheckService process exposes the CreditCheckProcess process as a RESTful service as shown in Figure 29.
Figure 29 CreditCheck Service
Figure 30 shows how the HTTP request and response are mapped to the input and output of the bound CreditCheck service process.
Figure 30 Credit Check Service Mapping
Setting Up the Project
Before running the project, you must perform the following steps to set up the project in TIBCO Designer:
1.
2.
Click Open Existing Project in the TIBCO Designer startup panel. The Open Project dialog is displayed.
3.
Click Browse next to the Project Directory field, and then select the Invoke_partner_rest folder, which is located in the RESTJSON_HOME\examples directory. Click OK. The Invoke_partner_rest project is displayed.
4.
Select InvokePartnerREST > Borrow > LoanRequestProcess in the Project panel.
5.
Click the InvokeLocalPartner process and configure the Input tab as shown in Figure 31.
Figure 31 The Configuration Panel for the LoanRequestProcess
6.
Select Project > Save from the TIBCO Designer menu to save the project.
Running the Project
After setting up the project, the next step is to trigger the processes in the InvokePartnerREST project:
1.
In the Project panel, click the Tester tab, and then click Start testing viewed process at the top left corner in this panel. The Select Processes To Load dialog is displayed.
2.
Click Select All, and then click Load Selected . The processes are loaded in the Tester panel.
3.
Click the Borrow/LoanRequestProcess.process in the right panel, and then click to start running the process.
When the process executes, the elements of the process change colors depending upon what is occurring in the executing process instance. If all the transition lines change to green, it means the process runs successfully.
4.
Click Stop testing to return to Design mode.
See TIBCO ActiveMatrix BusinessWorksTM Process Design Guide for detailed information on using the test mode including setting breakpoints and the element colors in the test mode.
Expected Results
After the process is completed, the response is returned in the Output tab as shown in Figure 32.
Figure 32 Returned Response

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved