Tutorial: Designing Your First Business Process

     Previous  Next    Open TOC in new window    View as PDF - New Window  Get Adobe Reader - New Window
Content starts here

Step 4: Invoke a Web Service

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:

 


Create Instance of Web Service Control

  1. Select the Design view.
  2. From the Oracle Workshop for WebLogic menu, choose Window > Show View > Data Palette.
  3. Click Graphical View of Business Process on the Data Palette tab. A drop-down menu of controls, representing the resources with which your business process can interact, is displayed.
  4. Choose Local Control > TaxCalcControl - requestQuote.services.
  5. Accept the default Field Name, and click Finish.
  6. 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.

 


Call Web Service

  1. In the Data Palette, expand the taxCalcControl node.
  2. Drag the 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.
  3. Figure 5-1 Control Send Node


    Control Send 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.
  4. Double-click the requestTaxRate node. The node builder opens on the General Settings tab. The control instance and target methods are already selected: taxCalcControl and void request TaxRate(String stateID_arg) respectively.
  5. Select the Send Data tab.
  6. 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.
  7. Select Transformation.
  8. Click Select Variable to view the variables in your project, and choose requestXML (QuoteRequestDocument), which is the variable you created for the Client Request node at the start of your business process.
  9. Click Create Transformation.
  10. 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.

  11. Select 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.
  12. Figure 5-2 Data Transformation


    Data Transformation

  13. Save the xq file.
  14. 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).

  15. Switch to the process by selecting the RequestQuote.java tab, and revert to the process perspective.
  16. Click Close to close the Request Tax Rate node builder.
  17. You have now finished designing the requestTaxRate node.

 


Receive Tax Rate from Web Service

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:

  1. Switch to the Process perspective.
  2. In the Data Palette, expand the taxCalcControl node to view the list of methods available for the control.
  3. Drag the 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.
  4. 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.

    Figure 5-3 Control Receive Node


    Control Receive Node

  5. Double-click the returnTaxRate node.
  6. 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.

  7. Select the Receive Data tab. The tab opens in the Variable Assignment mode.
  8. The Control Returns field indicates the data type and name of the parameter returned by the returnTaxRate() method of the taxCalculation control.

  9. From the Select variables to assign drop-down list, select Create new variable....
  10. The Create Variable dialog box is displayed.

  11. In the Variable Name field, enter taxRate.
  12. On the Simple tab, expand Primitives and then select float.
  13. In the Default value field, enter 0 (zero). This initializes the value of taxRate to zero.
  14. Figure 5-4 Create Variable Dialog Box


    Create Variable Dialog Box

  15. Click OK.
  16. 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.

  17. Click Close to close the node builder.
  18. 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.

    Figure 5-5 Graphical View of Business Process


    Graphical View of Business Process

    Note: The start node icon changed from Graphical View of Business Process (indicating a stateless business process) to Graphical View of Business Process (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”.
  19. From the Oracle Workshop for WebLogic menu, choose File > Save All.

No further design is required for this decision node.

Related Topics


  Back to Top       Previous  Next