Process controls are used to send requests to and receive responses from other business processes in the same domain using Java/RMI. This scenario demonstrates a typical use case for a process control – to call a subprocess from a parent business process.
In this part of the tutorial, you change the design of the business process you created in the previous part, to take advantage of a tax calculation service provided by a business process instead of using the tax calculation web service you used earlier. You can do this by first creating a process control from the tax calculation business process. Then, you simply change the control nodes in such a way that instead of communicating with the tax calculation web service through the web service control, the nodes communicate with the tax calculation business process through the new process control.
The tasks in this step include:
RequestQuote.java
in the Package Explorer view.Instances of controls that are already available in your project are displayed in the Controls folder of the Data Palette view.
The Insert Control: Process dialog box is displayed.
taxCalcProcess
as the name for the instance of the process control that you creating, and click Next.TaxCalculationProcess
in the Name field, and click Next. /Tutorial_Process_Application_Web/src/requestquote.services/TaxCalcProcess.java
.This Java file is a simple business process that calculates the sales tax for an RFQ.
The start method for TaxCalcProcess.java
(requestTaxRate) is displayed in the Start Method field.
The process control (TaxCalcControl.java
) is created and displayed in the Package Explorer view. An instance of the control (taxCalcProcess
) is added to the Data Palette. The Controls area in the Data Palette view now resembles the following figure:
taxCalcProcess
under the Controls folder to expand the list of methods on the control. RequestQuote.java
process.The following message is displayed:
This Control node is already associated with a control method. Do you wish to replace this control method?
The requestTaxRate node changes to reflect the type of control with which it is now associated. The node changes as follows:
taxCalcProcess
is selected in the Control field and that the following method is selected in the Method field:void requestTaxRate(QuoteRequestDocument quoteRequest)
By default, the Variable Assignment option is selected, and the Control Expects field contains QuoteRequestDocument quoteRequest, indicating the format and type of the message that the tax calculation process requires.
Note: | The tax calculation process requires a message of XML type QuoteRequestDocument – the same type as the requestXML variable to which the XML message sent from a client to the RequestQuote.java process is assigned. Unlike the scenario for sending data to the tax calculation web service in
Step 4: Invoke a Web Service, no transformation is required on this node; you can create a direct variable assignment. |
This step completes the procedure to change your business process to call the tax calculation business process instead of the tax calculation web service.
taxCalcProcess
under the Controls folder to expand the list of methods on the control.RequestQuote.java
process.The following message is displayed:
The Control node is already associated with a control method. Do you wish to replace this control method?
The returnTaxRate node changes to reflect the type of control with which it is now associated.
void returnTaxRate(float salesTaxRate)
The Variable Assignment option is selected by default, and the Control Returns field contains float salesTaxRate, indicating the type and name of the parameter expected to be returned by the tax calculation process.
taxRate (float)
.This step completes the procedure to change the callback handler to receive a message from the tax calculation business process instead of from the tax calculation web service.
You can run and test the business process, which now contains an asynchronous call to another business process in the same way that you tested the business process in the previous part. Perform steps 1 through 7 of Step 5: Run the Business Process.
When you start the operations in the Test Form page, the Message Log refreshes to display a summary of the calls to, and responses from, the tax calculation business process.
Entries in the message log correspond to the methods in your business process:
quoteRequest
method that starts the business process.taxCalcProcess.requestTaxRate
. Note that, in this case, the entire XML document (contained in the requestXML
variable) is passed to the subprocess. This is different from when the business process called the tax calculation web service; in that case, only the state
field was passed to the web service.taxCalcProcess.returnTaxRate
. Note that instead of the tax rate being returned in a web services SOAP envelope, as it was in the return from the web service, the process control returns the raw float value (0.08
).