In the previous step, you designed a set of conditions for a decision node (Sales Tax Calculation Needed?). In this step, you learn how to create the activities to be performed when the condition defined in your decision node (Sales Tax Calculation Needed?) evaluates to true (that is, shipAddress/state
in the XML document received from a client equals CA, California, NJ, or New Jersey). Specifically, you learn how to design your business process to invoke with a tax calculation web service through a web service control.
The TaxCalcControl.java
web service control is created for you and included in the Tutorial_Process_Application_Web\requestquote\services
folder.
Note: | Java controls are server-side components managed by the Workshop framework. They encapsulate external resources and business logic for use in Workshop applications. They represent the interfaces between your business process and other resources. The underlying control implementation takes care of most of the details of the interaction for you. Controls expose Java interfaces that may be invoked directly from your business process. You can add an instance of a control to your project and then invoke its methods. |
Note: | A complete description of how to create a web service and its associated control is beyond the scope of this tutorial. For more information about creating web services and creating controls from web services, see the following: |
Invoking a web service control involves the following tasks:
Note: | You can also create an instance of the control by dragging it from the Package Explorer view and dropping it in the Data Palette under the Controls node. |
void requestTaxRate(String stateID_arg)
method from the Data Palette view to the Design view, and drop it immediately below the Yes node of the Sales Tax Calculation Needed? node.
A Control Send node is created; this node represents an asynchronous call to the tax calculation web service control. The name of the node is the same as the name of the method (requestTaxRate
) that you selected from the Data Palette view.
Note: | This interaction is designed to be asynchronous, meaning that the business process, after sending a request to the web service, does not wait for a response. It continues processing and receives a response when the web service completes the request. |
taxCalcControl
and void request TaxRate(String stateID_arg)
respectively.
By default, the Send Data tab opens in the Variable Assignment pane. The Control Expects field indicates the data type (String stateID_arg
) that is expected by the requestTaxRate()
method exposed by the taxCalcControl
web services.
Note: | As you learned in a previous step, Send Data tabs have two modes: Variable Assignment and Transformation. |
In this case, you must switch to the Transformation mode because the data type required as input for the taxCalcControl
control is Java String, whereas the data type of the variable in which the RFQ message (including the value of shipAddress/state
) is stored, is Typed XML (QuoteRequestDocument
, valid against an XML schema).
Note: | WLI provides a tool called XQuery Mapper to transform data between heterogeneous data types. The data transformations that you create using XQuery Mapper are stored in xq files. You can think of a transformation file as another resource with which your business process interacts. The files containing the data transformations are built as controls. The controls expose methods, which business processes can invoke to transform disparate data types. |
requestXML
(QuoteRequestDocument
), which is the variable you created for the Client Request node at the start of your business process.An XQuery file is created and opened in the XQuery transformation perspective automatically.
The design view of the XQuery file shows the elements of the QuoteRequestDocument
XML document in the Source pane and a String
element in the Target pane.
state
in the Source pane and drag it to String
in the Target pane. A connecting line appears between the state
and String
elements, as shown in the following figure. This line represents a transformation between the two data types.xq
file.
An XQuery file (RequestQuotetaxCalcControlrequestTaxRate.xq
) and a transformation control file (RequestQuoteTransformation.java
) are created. Both files are displayed in the Package Explorer view. In addition, an instance of the transformation control is created and shown under transformations in the Data Palette (Controls folder).
The interaction between the business process and the tax calculation control is asynchronous, which means that the business process can continue performing other work while the tax calculation service prepares its response. The tax calculation service notifies the business process when the response is ready.
In the preceding section, you designed a call to the tax calculation web service (through a control).
To add the logic in your business process for receiving the tax rate returned by the tax calculation control, complete the following steps:
void returnTaxRate(float taxRate_arg)
method from the Data Palette to the Design view and drop it in the Sales Tax Calculation Needed? node immediately below the requestTaxRate node.
A Control Receive node is created representing an asynchronous response from the tax calculation web service control. The name of the node is the same as the name of the method (returnTaxRate
) that you selected from the Data Palette.
The node builder opens in the General Settings tab. The control instance and target methods are already selected: taxCalculation
and returnTaxRate(float taxRate_arg)
respectively.
The Control Returns field indicates the data type and name of the parameter returned by the returnTaxRate()
method of the taxCalculation control.
The Create Variable dialog box is displayed.
taxRate
.0
(zero). This initializes the value of taxRate
to zero.The new variable to which the sales tax rate is assigned at run time is created and shown as a Java variable under Variables in the Data Palette view.
You have now finished designing the returnTaxRate node and the activities to be performed by the business process when the condition in the Decision node evaluates to true.
In the Design view, the business process appears as shown in the following figure.
Note: | The start node icon changed from (indicating a stateless business process) to (stateful) after you added the asynchronous call to the web service control. |
Note: | To see whether the process is stateless or stateful, select the start node, and look for the stateless property in the JPD Configuration view. |
Note: | For more information about stateful and stateless business processes, see “Building Stateless and Stateful Business Processes” in Guide to Building Business Processes. |
Note: | To understand why the property of the process changed from stateless to stateful, see “Transaction Boundaries”. |
No further design is required for this decision node.