Service Invocation is an integral part of a Services Oriented Architecture. Business Logic Extensibility enables you to invoke services from Business Logic Methods, as illustrated in this example.
We presume that customers apply for a Sale, supplying an
amountRequested and a series of
Credit Accounts identifying their
These are input (e.g., via a user interface) to the Approval Process. The business logic requirements are to
- For each Credit Account, invoke a Bank Web Service. We supply the Credit Account Number, and the Web Service returns the Amount Approved
- Compute the Total Amount Approved, by totaling the Amount Approved for each Account
- Compute the Approval Summary, by comparing the Amount Requested to the Total Amount Approved
In this particular example, Web Services are invoked synchronously. Asynchronous processing would present a more complex problem, dependent on the actual Web Services implementations. (Please contact us if your system includes such requirements - we would be happy to review it with you).
Stub for Service Proxy
We want to be able to run this sample without requiring complex internet connections, so we provide the stub shown below.
In the code shown below, our simulated Web Service simply computes the amountApproved which we have embedded in the
In actual practice, you would typically use commonly available tooling to create a Java proxy from your Web Service Definition Language file. We presume our WebService takes an input parameter of the
customerAccountNumber, and returns a Response Bean
BankCreditApprovalResponse, which includes the attribute
customerAccountNumber. So, for example, supplying a
customerAccountNumber of "=50" returns a
BankCreditApprovalResponse.amountApproved of 50.
The database design is illustrated below. (Note: Bank.serviceName is not used - it is provided to suggest generalize the service invocation using reflection).
The entire logic is based on the Request pattern, and is shown in the screen shot below.
This action rule runs in response to any insert, update or delete of a SaleCreditRequest. The logic simply invokes the stub proxy, and copies the Response Bean attributes to the SaleCreditRequest attributes.
Totals all the
Computes whether the
Sale is approved, by comparing
The log is attached - you can study it to gain a better understanding of the logic execution.
To install the sample:
- Product Installation: install the download.
- Download and unzip PointOfSale.zip, below
- Import>Existing Project into the workspace you created from product installation