Managing a Purchase Order

A purchase order moves through a set of operations including submission, verifying status, calculating price, and managing faults. This sample shows the processes used to manage these operations.

Prerequisites

Note: To run the sample you can either use TIBCO ActiveMatrix BusinessWorks 6.x client or TIBCO ActiveMatrix BusinessWorks 5.x as a client.

Procedure

Configure the Server

  1. In the samples directory, select binding > soap > http > PurchaseOrder and double-click tibco.bw.sample.binding.soap.http.PurchaseOrder. For more information, see Accessing Samples.
  2. In Project Explorer expand the tibco.bw.sample.binding.soap.http.PurchaseOrder project.
  3. Set the default ApplicationProfile to match the OS you are running on. For more information, see Setting the Default Application Profile.
  4. Copy the ShippingCosts.xml and PriceBook.xml files from TIBCO_HOME\bw\n.n\samples\binding\soap\http\PurchaseOrder to the directory given for the INPUT_DIRECTORY property.
  5. Click Run > Debug Configurations.
  6. At the left hand tree of Debug Configuration wizard, expand BusinessWorks Application and select BWApplication.
  7. Click the Applications tab and then click the Deselect All button if you have multiple applications. Select the check box next to tibco.bw.sample.binding.soap.http.PurchaseOrder.application.
  8. Click Debug.
    This executes the sample in Debug mode.

Configure the ActiveMatrix BusinessWorks 5.x Client

  1. Extract the ActiveMatrix BusinessWorks 5.x client project bw5\tibco.bw.sample.binding.soap.http.PurchaseOrder.Client.zip into a temporary directory.
  2. Start TIBCO Designer and import the ActiveMatrix BusinessWorks 5.x client project from the temporary directory.
  3. In TIBCO Designer verify the output file, Host, and Port global variables.
    Note: If you change the module properties in the project, you must regenerate the concrete WSDL and import it into the 5.x client project.
  4. In TIBCO Designer, click Tools > Tester > Start.
  5. In TIBCO Business Studio™ for BusinessWorks™, click the Terminate icon to stop the process.

Result

See the following output:

Purchase ID 1234 is not valid

Submit PurchaseOrder Successful

Status PurchaseOrder :Pending

Status PurchaseOrder: Processed

Understanding the Configuration

The SellerService main process implements the submitPurchaseOrder and checkStatusPurchaseOrder operations. The submitPurchaseOrder operation returns a purchase order ID. A buyer uses this ID to check status when invoking the checkStatusPurchaseOrder operation. Each operation calls subprocesses:
  • The SubmitPOExecute subprocess is called from the submitPurchaseOrder operation and initiates the purchase order submission by calling the SubmitProcessOrder sub process and then generates the purchase order ID.
  • The SubmitProcessOrder subprocess calls the GetPriceForItem and CalculateShippingCosts sub processes to calculate item prices and shipping costs respectively. After these calculations complete, the purchase order changes to processed status, from pending status.
  • The GetPriceForItem subprocess reads data from PriceBook.xml and returns the price for an item.
  • The CalculateShippingCosts subprocess reads data from ShippingCosts.xml and returns the shipping costs based on region.
  • The CheckStatus subprocess is called from the checkStatusPurchaseOrder operation and returns the status of purchase order, either pending or processed.