# Tutorial: Designing a Purchase Order Processing System by Using AquaLogic Integrator

# Running the Sample Application

The tutorial application contains the artifacts required to run the sample purchase order processing application.

This section discusses the following topics:

- Creating the Tutorial Environment
- Loading the Sample Application
- Testing the Application

For information about ALINT Installer, see Installing and Using AquaLogic Integrator.

You can download the tutorial sample application from dev2dev.bea.com.

You must extract the contents of this sample application to a directory on your computer. Refer to this directory as {TUTORIAL_ROOT}. There are two sub folders (applications) in this directory: ExternalSystems and UsecaseApp.

Note: | After you have downloaded the sample application, ensure that these two directories are not Read-Only.

## Creating the Tutorial Environment

After you have created the ALINT domain, you must create the environment for the tutorial to design the Purchase Order Processing System sample application.

##### To Create the Tutorial Environment

1. Access the Pointbase Console from`` Start > All Products > BEA > Examples > WebLogic`` Integration > Pointbase Console at the url field of the Connect To Database dialog box that is displayed, type `jdbc:pointbase:server://localhost:9093/weblogic_eval`. Type entries into the username and password fields. For example, enter `weblogic` as the username and password.

Note: | BEA here refers to the BEA HOME directory where you have installed the BEA 10.2 products. Figure 2-6 shows the Start menu, from where you can access the Pointbase Console.

Figure 2-1 Start Menu Structure

2. In the Pointbase Console, run the database scripts in the `usecaseapp-dbscripts.sql` file that is available in the {TUTORIAL_ROOT} folder.
3. Deploy the external services that are used by the sample application, by performing the following steps:

1. Click Start > All Programs > BEA > WorkSpace Studio.
2. Create a new workspace External Systems in WorkSpace Studio. Select File > Import. Expand General, in the Import dialog box, select Existing Projects into Workspace. Click Next.
3. Browse to the directory of External Systems. In the Import Projects dialog box, select all the projects displayed, and click Finish.

Note: | After you have imported the application, you must complete the following steps to disable EAR validation at the workspace level, and clean the ear project:

- Right-click on the EAR (ExtSystem) project, and select Properties.
- In the Validation pane, click Configure Workspace Settings. Clear the EAR Validator check boxes.
- From the BEA WorkSpace Studio menu, click Project > Clean.

1. Expand ExtSystemWeb > src, right-click on CreditCardSystemJPD.java, and select Run As > Run on Server.
2. In the BEA WebLogic Server v10.0 dialog box, browse to the domain directory, and select the ALINT domain you have created. Click Next.

4. In the Add and Remove Projects dialog box, select ExtSystem and ExtServiceAccessConfig, and click Finish.
5. Create the following directory structure under C:\`
   `ALIntApp > PurchaseOrder. Create subfolders - Archive, Error, New and Rejected under the Purchase Order folder. The purchase order processed by the sample application is archived to the file system into these folders.

Figure 2-2 shows the Purchase Order archive directory structure.

Figure 2-2 Purchase Order Archive Directory Structure

## Loading the Sample Application

##### To Load the Sample Application

1. Click Start > All Programs > BEA > WorkSpace Studio, type a new workspace name - `UseCase`, in the Select a workspace dialog box, and click OK.
2. J2EE is the default perspective of Workspace Studio. Switch to Process perspective.
3. From the BEA WorkSpace Studio menu, click File > Import > General > Existing Projects into Workspace. Click Next. The Import dialog box is displayed.
Figure 2-3 Import Projects

4. In the Import Projects dialog box, browse to the {TUTORIAL_ROOT} directory where the sample application is extracted to. Select all the files from the Projects pane:

Figure 2-4 shows the Import Projects dialog box.

Figure 2-4 Import Projects

5. Click Finish.

Note: | The Process perspective contains all the required views like Node Palette, Data Palette, and Package Explorer.

Note: | Similarly, the ALSB perspective contains views related to ALSB, such as Expression Functions, Expression Variables, Target Expression, Constraints, and other views that are required to create a JPD.

6. The selected projects are imported and displayed in the Package Explorer pane. Figure 2-5 displays the Package Explorer pane.

Note: | Clean the Project after you have imported the files. From the Workspace Studio menu, click Project > Clean.

Figure 2-5 Package Explore Pane

Package Explorer contains the following:

- Service Access: ALSB project that comprises Business Services, and Proxy Services.
- Service Access Configuration: ALSB Configuration project.
- UseCase: WebLogic Integration EAR project.
- UseCaseUtil: Utility project.
- UseCaseWeb: Web project that consists of business processes and related artifacts.

Note: | After you have imported the application, you must complete the following steps to disable EAR validation at the workspace level, and clean the ear project:

1. Right-click on the EAR (UseCase) project, and select Properties.
2. In the Validation pane, click Configure Workspace Settings. Clear the EAR Validator check boxes.
3. From the BEA WorkSpace Studio menu, click Project > Clean.

Table 2-1 lists the important artifacts that are in the Package Explorer, after you have imported the project files.

Table 2-1 Important Artifacts in Package Explorer
File Name | Description
`ServiceAccess/ProxyServices/PurchaseOrderProcessingService.proxy` | The WSDL-based ALSB proxy service that forms the facade for the Purchase Order processing application we are building Validates the PurchaseOrder incoming document that splits the incoming PurchaseOrder document and invokes the following services to process the order: `PurchaseOrderAggregatorJPD` and `PurchaseOrderFulfillmentJPD`.
`ServiceAccess/ProxyServices/PurchaseOrderNotificationService.proxy` | The ALSB proxy service that is required to send the PurchaseOrderStatus document as a callback to the client.
ServiceAccess/BusinessServices/PurchaseOrderNotificationServiceBS.biz | The ALSB business Service that is required to send the PurchaseOrderStatus document as callback to the client.
UseCaseWeb/src/alint/process/ServiceProviderAccessControl.java | The ALSB Control that invokes `ServiceProviderAccessProxy.proxy`.
UseCaseWeb/src/alint/process/PurchaseOrderFulfillmentJPD.java | The JPD that handles order fulfillment. This JPD invokes the external inventory and credit card systems using ServiceProviderAccessControl. External systems are invoked in the context of an implicit transaction, and the transaction context is propagated to external systems. The results are published to message broker channels for further processing. In case of any error, a worklist task is created.
UseCaseWeb/src/alint/process/PurchaseOrderAggregatorJPD.java | The JPD that handles purchase order processing. Aggregates the purchase order fulfillment results by subscribing to the message broker channels and confirms the order shipment. Then this JPD sends the PurchaseOrderStatus document as a callback to the client.
ServiceAccess/BusinessServices/ | The business service endpoint for the two JPDs available in the UseCaseWeb folder. These business services use JPD transport.

1. Select UseCaseWeb/alint.client.test/TestClient.java from Package Explorer, right-click, and select Run As > Run on Server to publish UseCase and ServiceAccessConfiguration projects. In the Define a New Server dialog box, select BEA WebLogic Server v10.0, and click Next.
2. In the BEA WebLogic Server v10.0 dialog box, browse to the directory where you have created the ALINT domain, and click Next. In the Add and Remove Projects dialog box, select UseCase and ServiceAccessConfiguration in the Configured Projects pane, and click Finish.

The test browser is displayed with the following URL: `http://localhost:7001/UseCaseWeb/alint/client/test/TestClient.jpd.` The UseCase and Service Applications are now deployed on WebLogic Server.

Note: | When you publish the application, the following warning statements are displayed:

Note: | `org.apache.commons.logging.LogConfigurationException: org.apache.commons.logging`

Note: | `.LogConfigurationException: Invalid class loader hierarchy. You have more than`

Note: | `one version of 'org.apache.commons.logging.Log' visible, which is not allowed. (`

Note: | `Caused by org.apache.commons.logging.LogConfigurationException: Invalid class lo`

Note: | `ader hierarchy. You have more than one version of 'org.apache.commons.logging.L`

Note: | `og' visible, which is not allowed.)`

## Testing the Application

The section describes how to test the sample application.

##### To Test the Sample Application

1. In the test browser `http://localhost:7001/UseCaseWeb/alint/client/test/TestClient.jpd`, click the Test Soap tab.
2. In the `input purchase order` XML file, enter the values as follows:

- PurchaseOrderId (any purchase order id)
- CreditCardNumber (1234567890123456)
- ExpiryDate (08/08)
- ItemId (2)

3. Click clientRequest1.
4. Click Refresh on the browser. The PurchaseOrderConfirmation is received as a callback, as shown in Figure 2-6. The processed purchase order is archived in the `C:\ALIntApp\PurchaseOrder\Archive` folder.
Figure 2-6 Purchase Order Callback