
Creating a Home Loan Processing Application
Contributed and maintained by: Anastasia Koval
Last updated: November 2008
This publication is applicable to NetBeans IDE 6.1 and 6.5.
Contents
The
following scenario is a Loan Processing application which starts when a user applies for a loan by sending in a loan application request. The loan application request then goes through two verification steps:
- verifying the credit worthiness of the applicant
- verifying whether the applicant's house is worth the sum the loan applicant is asking for.
Based on the result of these two responses the loan is either approved or denied.
The result is written to an external file.

In this tutorial you will learn:
- How synchronous BPEL process works
- How asynchronous BPEL process works
- How to use the following BPEL activities:
- Receive
- Reply
- Invoke
- Assign
- If
- Partner Link
- How to use BPEL Correlation mechanism
- How to create test cases and test BPEL Processes
The tutorial consists of three exercises:
Expected duration: 30+45+45 minutes
Tutorial Requirements
Before you proceed, review the requirements in this section.
Prerequisites
This tutorial assumes you have basic knowledge or programming experience with the following technologies:
- web services and SOA
- XML
- Some understanding of WSDLs and HTTP SOAP Binding
To complete this tutorial, you need the following software and resources.
top
Configuring the Environment
- Download, unpack, and open the PlaceHolder project. This project contains an XML Schema you will use to define the message formats.
To open the project:
- Select the Projects window. Right-click in the blank area and select Open Project.
- Find the PlaceHolder project in the file system and click the Open Project button. The project opens in the IDE. Expand the PlaceHolder node and then expand Process Files node. You see HomeLoanApplication.xsd file, later you will copy it to your project.
- The "All" bundle of the NetBeans IDE includes the GlassFish V2 application server. The application server should be running.
To start the GlassFish application server:
- If the Services window is not visible, choose Window > Services.
- In the Services window, expand the Servers node.
The Servers node should contain the GlassFish application server subnode. If the GlassFish application server node does not appear, go to Configuring the GlassFish Application Server.
- Right-click the GlassFish application server node and select Start.
Note: If a green arrow badge appears on the GlassFish application server node, the server is running.
- Expand the GlassFish node and it's subnodes. The Services window appears as follows.

Note the following components:
- under Service Engines node, sun-bpel-engine - this is the engine that executes business processes created in compliance with the WS-BPEL specification
- under Binding Components, sun-http-binding - this component enables the SOAP over HTTP transport protocol for the web services you build in this excercise
- under Binding Components, sun-file-binding - this component enables services which read from and write to a File System
To configure the GlassFish V2 application server:
You might want to use a different version of the application server than the one provided with the NetBeans IDE. For example, you might want to download and install a more current version of the GlassFish V2 application server from the GlassFish Community site.
The following procedure shows how to configure the NetBeans IDE to use an alternate version of the GlassFish V2 application server. It assumes that you have downloaded and installed the alternate version of the application server.
- In the Services window, right-click the Servers node and choose Add Server from the pop-up menu.
The Add Server Instance dialog box opens.
- In the Choose Server page, select GlassFish V2 from the list.
- Click Next.
The Platform Folder Location page opens.
- In the Platform Location field, use the Browse button to navigate to and select the installation location of the application server.
If you installed the GlassFish application server in the default location, use Table 1 as a guide for locating the installation. Otherwise, navigate to the location where you installed the GlassFish V2 application server.
Table 1: Default Application Server Installation Directory
Solaris OS
Linux |
root |
/opt/glassfish-<version number> |
/opt/SUNWappserver |
Solaris OS
Linux |
user |
~/glassfish-<version number> |
~/SUNWappserver |
| Mac OS X |
N/A |
/Applications/NetBeans/glassfish-<version number> |
/Applications/NetBeans/NetBeans 6.5 |
| Windows |
N/A |
C:\Program Files\glassfish-<version number> |
C:\Sun\AppServer |
- Select the Register Local Default Domain radio button and click Next.
Note: If you want to register a non-default existing domain, choose
Register Local Default Domain. If you want to create a new domain,
choose Create Personal Domain. Then follow the wizard instructions.
This tutorial covers the local default domain usage scenario.
- Enter the user name and password for the domain's administrator.
If you accepted the default values during the installation, the user name is admin and the password is adminadmin.
- Click Finish.
top
Exercise 1: Creating a Credit Check Service
Expected duration: 30 minutes
In this exercise you create a synchronous BPEL process, a credit check service, that checks the credit worthiness of the applicant. In this exercise you learn how to use the following BPEL elements:
- Receive
- Reply
- Assign
- If/Else
- Partner Link
Creating a BPEL Process
- Create a new BPEL Module project. Follow the steps:
- From the main menu, choose File > New Project.
- In the Categories list, select the SOA node.
- In the Projects list, select the BPEL Module node and click Next.
- Optionally, click on Browse button to specify a location where you want this project to be created. For this tutorial accept the default location.
- In the Project Name field, type LoanApproval and click Finish.
The BPEL Module project is created.

Figure-01: Creating the LoanApproval BPEL Module project.
- Copy the HomeLoanApplication.xsd schema file from the PlaceHolder project to the newly created project. Follow the steps:
- Right-click the HomeLoanApplication.xsd file under the Process Files node of PlaceHolder project and choose Copy or press Ctrl-C.
- Right-click the Process Files folder under the LoanApproval project's node and choose Paste > Copy.

Figure-02: Copying the HomeLoanApplication.xsd file to the BPEL Module project.
- Create a CreditCheckDefn.wsdl file that will define the terms of the contract implemented by the credit check service. To create a WSDL file, do the following:
- In the Projects window, right-click the Process Files under LoanApproval node and choose New > WSDL Document.
The New WSDL Document wizard appears. (If WSDL Document option does not appear in the New menu, choose New > Other. In the opened dialog box, under Categories select XML, under File Types choose WSDL Document).
- In the File Name field, type CreditCheckDefn and click Next.
In the Abstract Configuration step, notice that the WSDL contract is defined as a portType, and the operation is of the request-response type.
Figure-03: Creating the CreditCheckDefn WSDL file.
- In the Input area, in the Element or Type column, click the Ellipsis (...) button.
The Select Element or Type dialog box opens.
- Scroll all the way up and expand HomeLoanApplication.xsd > Elements and choose LoanInformation. Click OK.

Figure-04: Select elements type.
- In the Output area, click the Ellipsis (...) button in the Element or Type column.
The Select Element or Type dialog box opens.
- Scroll all the way up and expand HomeLoanApplication.xsd > Elements and choose CreditCheckStatus. Click OK.
This specifies a response for the the portType from the HomeLoanApplication.xsd schema file.

Figure-05: Specifying the abstract configuration of CreditCheckDefn.wsdl.
- Click Next.
- In the Concrete Configuration step, select the Document Literal option as Binding Subtype and click Finish.
In the Projects window, the Process Files node now contains the CreditCheckDefn.wsdl file which is opened in the WSDL view.

Figure-06: The CreditCheckDefn.wsdl file in the WSDL view.
- Create a BPEL file that represents the logic of our credit check service. Do the following:
- In the Projects window, right-click the Process Files node of the LoanApproval project and select New > BPEL Process.
The new BPEL Process wizard opens. (If BPEL Process option does not appear in the New menu, choose New > Other. In the opened dialog box, under Categories select SOA, under File Types choose BPEL Process).
- In the File Name field, type CreditCheckService and click Finish.
In the Projects window, the Process Files node now contains a subnode labeled CreditCheckService.bpel and the BPEL file is opened in the Design view of the BPEL Designer.

Figure-07: The CreditCheckService.bpel file in the Design view of the BPEL Designer.
- Add a partner link to the BPEL process as follows:
- Make sure that CreditCheckService.bpel is opened in the Design view as shown in Figure-06.
- In the Projects window, expand the LoanApproval project node, then expand the Process Files node and select the CreditCheckDefn.wsdl file.
- Drag your selection (CreditCheckDefn.wsdl) from the Projects window to the pane on the left from the process diagram in the Design view and drop it it onto the placeholder shown as a pair of concentric circles.

Figure-08: Drag and drop the WSDL file from the Projects window.
An icon with the name PartnerLink1 appears on the Design view. This icon corresponds to the WS-BPEL activity Partner Link. Partner Links represent communication links between the process and external services. In other words, a partnerlink describes communication between the process and it's partner service. The left pane of the process diagram shows partner links for services who send data or a request to the process, the partners who initiate communication with the process. The right pane represents partners to whom the process sends messages (the process initiates the communication with the partner). The partner link we created is for the partner who will initiate communication.
- To change the name of the Partner Link, double click the name field of the Partner Link icon (the words PartnerLink1 at the top of the icon), and type CreditCheckPartner.

Figure-09: Adding a partner link to CreditCheckService.bpel
- Now we need to add the Receive and Reply activities to the BPEL process. In BPEL, the Receive-Reply pair is used to implement a request-response operation. When a client (partner) sends a message, the message is handled by the Receive activity, and the Reply activity is used to send the response back to the client.
To add the Receive and Reply activities to the BPEL process and associate them with the CreditCheckPartner partner link, do the following:
- If the BPEL activities Palette is not visible, choose Window > Palette.
- From the BPEL Designer Palette, drag the Receive icon to the process diagram and drop it onto the placeholder between the Process Start and End icons.

Figure-10: Adding a Receive activity to the BPEL process.
- Drag the Reply icon from the BPEL Designer Palette to the process diagram and drop it below the Receive icon.
- To configure the properties of Receive1, do the following:
- Double-click the Receive1 icon. The Property Editor dialog box for Receive1 opens.
- Choose CreditCheckPartner from the Partner Link drop-down list and CreditCheckDefnOperation from the Operation drop-down list.
- Click Create button to create a new variable. The variable associated with the Receive activity holds the XML message that is sent by the client.
- The New Input Variable dialog box appears. The default name of the variable is of the form <operation name>In. The "In" is appended to the name to indicate that the variable is associated with an incoming message, that is, a message received from a partner. In this case, the name of the variable is CreditCheckDefnOperationIn. Note the name of the variable, since we will be using this variable later in the process. You can change the name, but for this exercise accept the default, click OK.
- Click OK to close the Property Editor dialog box. Notice that a connection appears between Receive1 and CreditCheckPartner.

Figure-11: Configuring the Receive1 activity
- To configure the properties of Reply1, do the following:
- Double-click the Reply1 activity. The Property Editor dialog box for Reply1 opens.
- Choose CreditCheckPartner from the Partner Link drop-down list.
- Leave the Normal Response option selected and click Create button to create a new variable.
The variable associated with the Reply activity holds the XML message that will be used as a response to the client.
- Note the name of the variable in this case is CreditCheckDefnOperationOut. "Out" has been suffixed to the operation name and means that the variable will be used for an outgoing message. These are simply conventions and the names can be changed freely. Now, accept the defaults by clicking OK.
- Click OK to close the Property Editor dialog box. Notice that a connection appears between Reply1 and CreditCheckPartner.
- To recap, the message from the client will be received by the Receive activity and the response will be sent to the client by a Reply activity. This behavior represents synchronous message processing.

Figure-12: Configuring the Reply1 activity
- In the previous step you defined activities to receive a request and send back a response to the client. Now we need to do additional processing after receiving the message. We will determine whether the loan applicant is credit-worthy using an If activity and the information contained in the variable associated with the Receive activity. Based on that, we will use an Assign activity to populate the variable for the Reply. When the Reply activity is executed the contents of this variable will be used to send back a response to the client. Create the If and Assign BPEL activities by following these steps:
- In the Palette, expand the Structured Activities node. Drag the If icon and drop it between Receive1 and Reply1.
An If activity is used to perform conditional logic. It can have one If branch, multiple ElseIf branches, and one or no Else branches. In this tutorial you use one If branch and one Else branch.
- Expand the Basic Activities node in the Palette. Drag the Assign icon from the Palette and drop it onto the If branch on the left of the If activity.
- Drag the Assign icon and drop it onto the Else branch on the right of the If activity.
You have created a framework for the process' business logic.

Figure-13: Adding the If and Assign activities.
- To specify the condition for If, do the following:
- In the Design view, double-click the If activity.
The BPEL Mapper window opens.
- In the left tree pane (source pane) of the BPEL Mapper, under Variables, expand CreditCheckDefnOperationIn > part1 > BorrowerInformation. The nodes under part1 represent the message that was sent by the client. Remember, the name of the variable associated with the Receive activty was CreditCheckDefnOperationIn. This variable represents the details of the loan application.
- In the right tree pane (destination pane) of the BPEL Mapper, expand the If node.
The Boolean Condition node appears under the If node.

Figure-14: Expanded view of the BPEL Mapper trees for If1.
- Ensure that the Boolean Condition node is selected and a light blue band appears on the middle pane as shown above. On the menu bar immediately above the BPEL Mapper pane, choose String > Starts With. Notice a Starts With function box appears in the band. On the right pane, select the SSN node and drag it to the upper ingoing connector (small blue square) of the Starts With function box. A connection will appear as shown below.

Figure-15: Creating a mapping for the SSN node of If.
- On the menu bar, choose String> String Literal. A String Literal box appears. Double click in the white area of the String Literal box and enter 6. For convenience, re-position the String Literal box to the left of the Starts With box. Map the String Literal box to the second ingoing connector of the Starts With function box as shown below.

Figure-16: Assigning string literal.
- Connect the Boolean node of the Starts With box with the Boolean Condition node in the right mapper pane as shown in Figure-17 below. You have just created a condition which states "if the SSN starts with 6, then perform the logic in the If branch". A person who have the SSN starting with the number 6 will be deemed credit-worthy. Otherwise, the person will be deemed not credit-worthy, and the activities in the Else branch will be executed.

Figure-17: Specifying a condition for If.
- Click Design button on the menu bar or press Alt-D to return to the Design view of the BPEL Editor.
- Create a mapping to populate the content of the Reply variable. Follow the steps:
- In the Design view, double-click the Assign1 element located on the If branch.
The BPEL Mapper window opens.

Figure-18: BPEL Mapper window for Assign1.
- In the left tree pane of the BPEL Mapper, under Variables, expand CreditCheckDefnOperationIn > part1 > BorrowerInformation.
The SSN node appears under the BorrowerInformation node.
- In the right tree pane, under Variables, expand CreditCheckDefnOperationOut > part1.
The SSN node appears under the part1 node.
- Draw a mappping between the SSN node in the left pane and the SSN node in the right pane.

Figure-19: Expanded view of the BPEL Mapper trees for Assign1.
- Select the Status node in the right pane. A blue band should appear. Now, on the menu bar, choose String > String Literal.
- In the function box that appears, type Approved and drag a line to the Status node in the right mapper pane.
This mapping populates the content of the reply variable. The string Approved in the response will indicate to the client that the person is credit-worthy.

Figure-20: Creating a mapping for Assign1.
- Click Design button on the menu bar or press Alt-D to return to the Design view of the BPEL Editor.
- Now create a mapping to populate the content of the Reply variable in case the process execution takes the Else branch. This will happen when the SSN starts not with 6.
Follow these steps:
- In the Design view, double-click the Assign2 element located on the else branch.
The BPEL Mapper window opens.
- In the left tree pane, expand CreditCheckDefnOperationIn > part1 > BorrowerInformation.
- In the right tree pane, expand CreditCheckDefnOperationOut > part1.
- Drag a connection from the SSN node in the left pane to the SSN node in the right pane (for reference, see Figure-19).
- Select the Status node in the right pane. A blue band should appear. Now, on the menu bar, choose String > String Literal.
- In the function box that appears, type Denied and drag a line to the Status node in the right mapper pane.
This mapping populates the content of the reply variable. The string Denied in the response will indicate to the client that the person is not credit-worthy.

Figure-21: Creating a mapping for Assign2.
- Click Design button on the menu bar or press Alt-D to return to the Design view of the BPEL Editor.
- To validate the XML code for the process, do the following:
- In the Design view, click Validate XML button on the toolbar.

Figure-22: The validate button.
- View the validation results in the Output window.
If the window is not visible, choose from the main menu Window > Output > Output.

Figure-23: The output window.
Congratulations! You have created the Credit Check Service! In the steps below, you will deploy and test the service.
Deploying the BPEL Process
To deploy the BPEL Module project, first you must create a Composite Application project. Composite Application projects aggregate BPEL and other modules, and define connectivity for different services that exchange messages. Deploying the Composite Application project makes the service assembly available to the application server, thus allowing its service units to be run.
- To create the Composite Application project, follow these steps:
- From the main menu, choose File > New Project.
The New Project wizard opens.
- In the Categories list, select the SOA node, and in the Projects list, select the Composite Application node and click Next.
- In the Project Name field, type LoanApprovalServiceAssembly and click Finish.
The Projects window now contains a project node for a composite application project called LoanApprovalServiceAssembly.

Figure-24: Creating the LoanApprovalServiceAssembly composite application project.
- To add the LoanApproval BPEL Module project as a JBI module to the composite application, do the following:
- In the Projects window, right-click the LoanApprovalServiceAssembly project node and choose Add JBI Module from the pop-up menu.
- In the Select Project dialog box, navigate to the folder where the LoanApproval project resides, select it and click Add Project JAR Files button.

Figure-25: Adding the LoanApproval project as a JBI module to the composite application.
- Right-click the LoanApprovalServiceAssembly project node and choose Deploy Project.
If a message similar to the following message appears in the Output window, then the deployment has succeeded:
BUILD SUCCESSFUL (total time: 11 seconds)
- Successful deployment can also be visually verified in the Services window. The Service Assemblies subnode of GlassFish server node now includes LoanApprovalServiceAssembly.

Figure-26: The Service Assembly that was deployed
Testing the Credit Check Process
To create a new test case, follow the steps:
- In the Projects window, expand the LoadApprovalServiceAssembly project node, right-click the Test node, and choose New Test Case from the pop-up menu.
The New Test Case wizard opens.
- In the Test Case Name field, type TestCreditCheckService and click Next.

Figure-27: Creating a test case.
- In the next dialog box, expand the LoanApproval-Source Packages node, select CreditCheckDefn.wsdl, and click Next.
- In the Select the Operation dialog box, select CreditCheckDefnOperation and click Finish.
Notice the following: the TestCreditCheckService test case is added under the Test node. The test case contains two files: Input.xml and Output.xml. The Input file contains a message that is sent to the server when the process is run. The output file contains desired output. The output you get at the test run is compared to the one in the Output file. If the received output matches the desired output, the test is marked as Passed.
- Edit the Input.xml file to supply the input data for the test case, enter the Name and SSN in the Input.xml file. Name can be any name; SSN should be a numeric starting with any number from 0 to 9. For example:
<BorrowerInformation> <Name>John Smith</Name> <SSN>666777888</SSN> <Address> <Addr1>?string?</Addr1> <CityState>?string?</CityState> <Zip>?string?</Zip> <Telephone>?string?</Telephone> </Address> </BorrowerInformation>
- In the Projects window, right-click the TestCreditCheckService node and choose Run.
Note: At the first run, the Output.xml file is empty. After the process instance is executed for the first time, a dialog box appears asking whether the received output should be written to the empty Output.xml file. The output you need can be both
"Approved" or "Denied", there are two valid responses, so click No.

Figure-28: A dialog box for you to confirm overwriting the empty output.
- Expand the TestCreditCheckService node and open the file named with the latest current date and time. The "Failed" label simply means that the
output of this run did not match the contents of Output.xml file. The status should be Approved and the SSN number is displayed.

Figure-29:Contents of the Output.xml file.
- Now, let's modify the input data. In the Input.xml file, change the SSN value to start with any number other than 6 and run the test again.
- In the Projects window, under the test case node, click the results of the last test case run (marked with the latest date and time).
The status should be Denied.

Figure-30: Results of the second test run (SSN is greater than 6).
Summary:
In this excercise you created a service that checks the credit worthiness of loan applicants. You created a synchronous BPEL process and configured its activities, you also designed a WSDL file required for this process. Then, you created a composite application, and deployed it to the application server. You also learned how to test the process.
top
Exercise 2: Creating the Loan Approval Service
Expected duration: 45 minutes
In this exercise, you create and test a simple version of the Loan Service. A client sends a loan application request to the Loan Service. The Loan Service receives the message and sends a request to the Credit Check Service to determine the credit worthiness of the applicant. The Credit Check Service processes the request and returns an approval or denial. Depending upon the status received, the Loan Service sends a message to the Loan Application Status partner to indicate whether the loan was approved or denied. The Loan Application Status partner represents a file in the file system. This exercise teaches you how to use the following activities:
- Invoke in one-way and two-way communications
- Receive in one-way communication
- Open the LoanApproval BPEL Module project created in Exersise1.
- Create a new WSDL file LoanApproveDefn.wsdl. Do the following:
- In the Projects window, expand the LoanApproval project node, then right-click the Process Files node and choose New > WSDL Document.
The New WSDL Document wizard opens.
- On the Name and Location page, type the name for the new file, LoanApproveDefn, and click Next.
- On the Abstract Configuration page, do the following:
- Choose the One-Way Operation item as Operation Type.
- In the Element or Type column, click the Ellipsis (...) button.
The Select Element Or Type dialog box opens.
- Scroll up and expand By File > LoanApproval > src/HomeLoanApplication.xsd > Elements. Under the Elements node, select the LoanInformation node and click OK.
The completed Abstract Configuration page should look like the one shown below. Click Next.

Figure-01: The Abstract Configuration page for LoanApproveDefn.wsdl
- On the Concrete Configuration page, select the Document Literal option as Binding Subtype.

Figure-02: The Concrete Configuration page for LoanApproveDefn.wsdl
- Click Finish.
In the Projects window, the Process Files node now contains a subnode labeled LoanApproveDefn.wsdl.
The Source Editor contains a tab for LoanApproveDefn.wsdl with the WSDL view open.
- Choose the Source tab. Review the code that was generated.
- Create a new BPEL file LoanApproveService.bpel by following these steps:
- In the Projects window, under LoanApproval, right-click the Process Files node and choose New > BPEL Process.
The New BPEL Process wizard opens.
- In the File Name field, type LoanApproveService and click Finish.
In the Projects window, the Process Files node now contains a subnode labeled LoanApproveService.bpel. The Editor contains a tab for the BPEL process, LoanApproveService.bpel, with the Design view of the BPEL Designer open.
- Start developing the process diagram by adding the Receive and Invoke activities:
- From the Web Service section of the Palette window, drag the Receive icon to the process diagram, and drop it on the placeholder, between the Process Start and the Process End activities.

Figure-03: Adding the Receive activity.
- In the same way, drag the Invoke activity from the Palette to the process and drop it below the Receive activity.
- Double-click on the string Invoke1 and change the name to CreditCheck.
- In the Structured Activities section of the Palette, select the If element, drag and drop it below the Invoke activity.
- Drag an Invoke activity from the Palette to the placeholder on the main branch of the If element and rename it Approved.
- Drag another Invoke activity from the Palette to the the Else branch of If element and change it's name to Denied.
The process diagram should look as follows. Red warning labels mean that the activities are not configured properly, the designer has a real-time validation that checks the source code in a real-time mode. You will configure these activities later, so don't worry now about the error marks.
Figure-04: Loan Approve process. The activities are not configured yet.
- Add a Partner Link to the diagram by following these steps:
- In the Projects window, expand the LoanApproval project node, then expand the Process Files node and select the LoanApproveDefn.wsdl node.
- Drag your selection (LoanApproveDefn.wsdl) from the Projects window
to the left edge of the process diagram.
The IDE adds a box for the Partner Link to the design area. You added the partner link to the left pane, that means, this partner link represents a partner, who initiates communication with the process.
- Double-click the Partner Link name (PartnerLink1) and change it to LoanApprovePartner.
The diagram appears as follows.

Figure-05: LoanApprovePartner partner link is added to the diagram.
- To configure the properties of Receive1 activity , do the following:
- On the diagram, double-click the Receive1 activity.
The Property Editor window opens.
- Specify the Partner Link as LoanApprovePartner. The operation should be LoanApproveDefnOperation.
- Click Create to create an input variable. Leave all the settings for the input variable as they are (see the figure below).

Figure-06: New input variable is created for Receive1 activity.
- Click OK.
The Property Editor for Receive1 looks like the one below.

Figure-07: Final view of Receive1 Property Editor.
- Click OK.
The Receive activity consumes the message that the client sends to the Loan Service. Note that you did not use a Reply activity as in the first exercise because the operation is a request-only operation. The Loan Service writes a response to a file.
- Configure the Invoke activity to call the Credit Check Service:
- In the Projects window, expand the LoanApproval project node, then expand the Process Files node and select the CreditCheckDefn.wsdl node.
- Drag your selection (CreditCheckDefn.wsdl) from the Projects window to the right side of the diagram. The IDE adds a box for the Partner Link to the design area. The right pane shows services with which the process initiates communication. This partner link represents a communication link between the Loan Service and the Credit Check Service, initiated by the Loan Service.
- Right-click the Partner Link, choose Edit. In the Name field, type a new name for the Partner Link, CreditCheckServicePartner, and click OK.
- To configure the properties of the CreditCheck Invoke activity, do the following:
- In the Design view, double-click the CreditCheck Invoke activity. The Property Editor window opens.
- ChooseCreditCheckServicePartner from the Partner Link drop-down list and CreditCheckDefnOperation from the Operation drop-down list.
- To create an input variable, click the Create button for the Input Variable field.
The contents of the input variable will be used to send a message to the Credit Check Service.
- In the New Input Variable window, leave the settings as they are and click OK.
The variable name appears in the Input Variable field. Note the name CreditCheckDefnOperationIn of the input variable. The variable is to contain the message to be sent to the Credit Check Service.
- To create an output variable, click the Create button for the Output Variable field.
The output variable is used to store a response from the Credit Check Service.
- In the New Output Variable window, leave the settings as they are and click OK.
The variable name appears in the Output Variable field. Note the name CreditCheckDefnOperationOut of the output variable. We will use this variable to read the response status (Approved or Denied) from the Credit Check Service.

Figure-08: Final view of the Property Editor for CreditCheck Invoke activity.
- Click OK.
A connection between the Invoke activity and the partner service appears as follows.

Figure-09: CreditCheck Invoke activity is connected with the corresponding partner link.
- Add an Assign activity to the process by following these steps:
- In the Basic Activities section of the Palette, select the Assign icon.
- Drag your selection to the design area and drop between the Receive1 activity and CreditCheck Invoke activity.
This action places an Assign activity called Assign1 in the Design view.
Figure-10.1: The Loan Approval process. Assign1 activity added.
- Double-click the Assign1 activity. The BPEL Mapper opens.
- In the source tree pane (the left pane) of the BPEL Mapper, under Variables, expand the LoanApproveDefnOperationIn node. Part1 node appears under the LoanApproveDefnOperationIn node.
- In the destination tree pane (the right pane) of the BPEL Mapper, under Variables, expand CreditCheckDefnOperationIn.
The part1 node appears under the CreditCheckDefnOperationIn node.
- In the source tree pane, select the part1 node and drag your selection to the part1 node in the destination pane.

Figure-10.2: A mapping for Assign1.
This assignment copies the data from one variable to another. In this case, we copy the contents of the request that was received by the Loan Service and send it to the Credit Check Service.
- On the menu bar, click the Design tab which will take you back to the process diagram or press Alt-D.
- Now, let's define a conditional block for checking the response of the Credit Check Service.
To define the condition for the If activity, do the following:
- In the Design view, double-click the If activity.
The BPEL Mapper window opens.
- In the menu bar, choose String > String Literal.
A function box appears in the middle pane.
- Double-click the box and type Approved.
- In the menu bar, choose Operator > Equal.
- Connect the String Literal box outgoing connector to the lower ingoing connector of the Equal box.
- In the source tree pane (the left pane) of the BPEL Mapper, under Variables, expand CreditCheckDefnOperationOut > part1 node. Remember, CreditCheckDefnOperationOut is the output variable of the Invoke that calls the Credit Check Service and contains the response from the Credit Check Service.
- Connect the Status node to the upper ingoing connector of the Equal box.
- Now connect the outgoing connector of the Equal box to the Boolean Condition node on the right pane.
You created a condition which states: "if CreditCheckDefnOperationOut/part1/Status='Approved' then the boolean value is true". In other words, if the response from the Credit Check Service is "Approved", then execute activities in the If branch, else execute activities in the Else branch. In the Mapper, the condition looks as follows:

Figure-11: The condition is defined.
On the menu bar, click the Design tab which will take you back to the process diagram or press Alt-D.
Writing a Response to a File
Now you need to write the decision about the loan approval or denial to a text file. To accomplish this, use a one-way Invoke activity. Before configuring the Invoke, create a WSDL file with a portType and a request-only operation.
- Create a new WSDL file LoanApplicationStatusDefn.wsdl by following these steps:
- In the Projects window, expand the LoanApproval project node, then right-click the Process Files node and choose New>WSDL Document.
The New WSDL Document wizard opens.
- On the Name and Location page, type the name for the new file, LoanApplicationStatusDefn, and click Next
- On the Abstract Configuration page, choose the One-Way Operation as Operation Type and click Next.

Figure-12: Creating new LoanApplicationStatusDefn.wsdl. Abstract configuration page.
- On the Concrete configuration page, select the FILE option as the Binding Type.

Figure-13: Creating new LoanApplicationStatusDefn.wsdl. Concrete configuration page.
- Click Finish.
In the Projects window, the Process Files node now contains a subnode labeled LoanApplicationStatusDefn.wsdl. The Source Editor contains a tab for the WSDL file, LoanApplicationStatusDefn.wsdl, with the WSDL view open.
- Go to the Source view and review the code
- Add one more Partner Link to the Loan Approve process by following these steps:
- In the Projects window, double-click the LoanApproveService.bpel file. The file opens in the Design view.
- From the Projects window, drag the LoanApplicationStatusDefn.wsdl file and drop on the right side, below the existing Partner Link. A new Partner Link appears.
- Double-click the Partner Link name, change it to LoanStatusPartner.
- Connect the Invoke activity to the Partner Link as follows:
- Double-click the Approved Invoke activity in the If block of the If element. The Property Editor window opens.
- Select LoanStatusPartner from the Partner Link drop-down menu and specify the operation as LoanApplicationStatusDefnOperation.
- Click Create button to create a new input variable.
The New Input Variable window opens. Note the default name LoanApplicationStatusDefnOperationIn of the input variable. This variable will contain the loan approval or denial message to be written to the file system.
- Leave the settings as they are and click OK.
- Similarly configure Denied Invoke activity of the Else branch in the If element:
- Double-click the Denied Invoke activity in the Else block of the If element. The Property editor window opens.
- Select LoanStatusPartner from the Partner Link drop-down menu and specify the operation as LoanApplicationStatusDefnOperation.
- Click Browse instead of Create button to select an existing input variable. It is important to note that you did not create a new variable here andreuse the one previously created. Both the Approved and Denied invoke activities will use the same variable.
- In the Input Variable Chooser window, choose the input variable that was created during configuring the Approved Invoke activity (LoanApplicationStatusDefnOperationIn).
- Click OK.
- From the Palette, drag two Assign activities (one after another) and place them on both branches of the If element.
These Assign activities will be used to produce a message that will be written to the text file.
Note: The Assign activities should be placed above the Invoke activities. Your BPEL canvas should have the following new elements by now.

Figure-14: Loan Approve process. New Partner Link and Assign activities are added.
- Create the message to inform the client whether the loan was approved or denied. Concatenate the approval or denial with the name of the person to personalize the message:
- Double-click the Assign activity in the If branch of the If element.
The BPEL Mapper opens.
- In the right Mapper pane, expand Variables > LoanApplicationStatusDefnOperationIn. Select the part1 node.
A blue band should appear.
- In the Mapper menu bar, choose String > Concat. The Concat function box appears.
- In the left Mapper pane, expand Variables > LoanApproveDefnOperationIn > part1 > BorrowerInformation. The Name node should be visible.
- Connect the Name node to the first String node on the left side of the Concat box.
- In the menu bar, choose String > String literal.
Another function box appears in the middle pane (blue band).
- Double-click the box and type the string ' your loan has been approved'.
Notice that there is a space at the beginning of the string. While typing do not enter the quotes. Re-position the String Literal box to the left of the Concat box for convenience.
- Connect the String Literal box to the second String node on the left of the Concat box.
- Now connect the String node on the right side of the Concat box to the part1 node under LoanApplicationStatusDefnOperationIn in the right Mapper pane as shown below.
- Click the Design tab, it will take you back to the process diagram.

Figure-15: Loan Approve process. A mapping for Assign2.
- Double-click the Assign activity in the Else branch of the If element. The steps below are identical to the steps above (in 16.1), except that the text in the String Literal box is different.
- In the right Mapper pane, expand Variables > LoanApplicationStatusDefnOperationIn. Select the part1 node.
A blue band should appear.
- In the Mapper menu bar, choose String > Concat.
The Concat function box appears.
- In the left Mapper pane, expand Variables > LoanApproveDefnOperationIn > part1 > BorrowerInformation. The Name node should be visible.
- Connect the Name node to the first String node on the left side of the Concat box.
- In the menu bar, choose String > String Literal. Another function box appears in the middle pane (blue band).
- Double-click the box and type the string ' your loan has been denied'.
Notice that there is a space at the beginning of the string. While typing do not enter the quotes. Re-position the String Literal box to the left of the Concat box for convenience.
- Connect the String Literal box to the second String node on the left of the Concat box.
- Now connect the String node on the right side of the Concat box to the part1 node under LoanApplicationStatusDefnOperationIn in the right mapper pane as shown above.
- Click the Design tab which takes you back to the process diagram.
- Our process is complete. To validate the XML code for the process, do the following:
- In the Design view, click Validate XML on the toolbar.
- View the validation results in the Output window.
If the window is not visible, choose from the main menu Window > Output > Output.
Congratulations, you have created the first version of the Loan Service! If validation shows no errors or warnings you can test how the project works.
Testing the project:
- In the Projects window right-click the LoanApproval ServiceAssembly project node and choose Clean and Build.
Notice a message similar to the following message appears in the Output window:
BUILD SUCCESSFUL (total time: 2 seconds)
If the Output window is not visible, choose Window > Output > Output in the main menu.
- Right-click the LoanApprovalServiceAssembly project node and choose Deploy.
Notice a message similar to the following message appears in the Output window:
[start-service-assembly] Starting a service assembly... host=localhost port=4849 name=LoanApprovalServiceAssembly run: BUILD SUCCESSFUL (total time: 2 seconds
- Let's test the process. First create a test case.
- In the Projects window, expand the LoadApprovalServiceAssembly project node, right-click the Test node, and choose New Test Case from the pop-up menu. The New Test Case wizard opens.
- For Name, enter TestLoanApprovalProcess and click Next.
- Expand LoanApproval-Source Packages, select LoanApproveDefn.wsdl, and click Next.
- Select LoanApproveDefnOperation and click Finish.
Notice in the project tree, under Test, new folder TestLoanApprovalProcess is created, containing two files: Input and Output.
- Double-click the Input.xml and modify its content as follows:
<BorrowerInformation> <Name>John Smith</Name> <SSN>666777888</SSN> <Address> <Addr1>?string?</Addr1> <CityState>?string?</CityState> <Zip>?string?</Zip> <Telephone>?string?</Telephone> </Address> </BorrowerInformation>
- To run a test case:
- In the Projects window, navigate to the LoanApprovalServiceAssembly > Test > TestLoanApprovalProcess directory.
- Right-click the TestLoanApprovalProcess project node, and choose Run from the pop-up menu.
Notice this message in the JUnit Test Results window: Test TestLoanApprovalProcess\Concurrent.properties Passed.
The output message in our case should be written to a file.
- For Windows systems, go to My Computer, C:\Temp\
For Unix based systems, the file should be in the user home directory.
This is the default directory for the external output file.
- Open the test.xml file with a text editor. The file should contain text like this: "John Smith your loan has been approved".
- In the IDE's Projects window, navigate to the LoanApprovalServiceAssembly > Test > TestLoanApprovalProcess directory.
- Double-click the Input file and change the contents of the <SSN> string to 555666777.
The string should look like <SSN>555666777</SSN>
- Run the test case again.
- When the test case is performed and you got a message Test passed, open the test.xml file once again.
It should contain a message: "John Smith your loan has been denied"
Summary:
In this exercise you have created a simple version of the Loan Service. You learned how to build and use request only and request-response web service operations using BPEL activities (one-way and two-way Invoke activity). You also learned how to create and perform a test run of the process.
top
Exercise 3: Creating Home Appraisal Service and calling it from the Loan Appraisal Service
Expected duration: 45 minutes
In this exercise you will create a Home Appraisal Service, enhance the Loan Service to call the Appraisal Service and to incorporate the result returned by the Appraisal Service. You will study asynchronous business processes and how BPEL correlations is used in such processes.
- Create a new WSDL file HomeAppraisalDefn.wsdl by following these steps:
- In the Projects window, expand the LoanApproval project node, then right-click the Process Files node and choose New > WSDL Document.
The New WSDL Document wizard opens.
- On the Name and Location page, type the name for the new file, HomeAppraisalDefn.Click Next.
- On the Abstract Configuration page, do the following:
- Choose the One-Way Operation item as Operation Type.
- In the Element or Type column, click the Ellipsis (...) button. The Select Element Or Type dialog box opens.
- Scroll up and choose By File > LoanApproval > src/HomeLoanApplication.xsd > Elements > LoanInformation node and click OK.
- Click Finish.
In the Projects window, the Process Files node now contains a subnode labeled HomeAppraisalDefn.wsdl.
The Editor contains a tab for HomeAppraisalDefn.wsdl with the WSDL view open.
- Create a new WSDL file HomeAppraisalCallbackDefn.wsdl by following these steps:
- In the Projects window, expand the LoanApproval project node, then right-click the Process Files node and choose New > WSDL Document.
The New WSDL Document wizard opens.
- On the Name and Location page, type the name for the new file, HomeAppraisalCallbackDefn. Click Next.
- On the Abstract Configuration page, do the following:
- Choose the One-Way Operation item as Operation Type.
- In the Element or Type column, click the Ellipsis (...) button.
The Select Element Or Type dialog box opens.
- Scroll up and choose By File > LoanApproval > src/HomeLoanApplication.xsd > Elements > AppraisalStatus node and click OK.
- Click Finish.
In the Projects window, the Process Files node now contains a subnode labeled HomeAppraisalCallbackDefn.wsdl
The Editor contains a tab for HomeAppraisalCallbackDefn.wsdl with the WSDL view open.
Remember, in Exercise 1 you created one WSDL with a request-reply operation, so that the caller of the operation gets back the response synchronously. But now you created two independent request-only operations. The client calls the first operation to send the request to the Appraisal Service. The Appraisal Service will do the processing and then call the client back using the other request-only operation. Note that this is very similar to how the Loan Service interacts with its client. This is an example of asynchronous messaging and processes like Appraisal Service are called asynchronous business processes.
- Create a new BPEL file HomeAppraisalService.bpel by following these steps:
- In the Projects window, right-click the Process Files node and choose New > BPEL Process.
The New BPEL Process wizard opens.
- In the File Name field, type HomeAppraisalService and click Finish.
In the Projects window, the Process Files node now contains a subnode labeled HomeAppraisalService.bpel. The Editor contains a tab for the BPEL process, HomeAppraisalService.bpel, with the Design view of the BPEL Designer open.
- Develop the HomeAppraisalService process diagram. Drag and drop a Receive activity from the Palette. Place it between Process Start and Process End elements.
- To add a Partner Link to the diagram:
- In the Projects window, expand the LoanApproval project node, then expand the Process Files node and select the HomeAppraisalDefn.wsdl node.
- Drag your selection (HomeAppraisalDefn.wsdl) from the Projects window to the left of the diagram.
The IDE adds a box for the Partner Link to the design area. Remember, the left pane represents partners who send data or request to the process, i.e., initiate communication with the process first.
- Double-click the Partner Link name and change it to AppraisalProvider.
- Click OK.

Figure-01: A Partner Link is added to the HomeAppraisal process diagram.
The Partner Link will describe interaction of the Loan Service and Appraisal Service. The Loan Service is the client (i.e. the sender) and the Appraisal Service is the provider (receiver).
Note that the Receive activity on the diagram has an error mark. The BPEL designer validates generated XML code on a real-time basis. Point at the error mark with a mouse and IDE will provide you information on existing errors. In this case the problem is that for the Receive1 activity necessary attributes are not specified.
- Configure the properties of Receive1 activity as follows:
- Double-click the Receive activity. Property Editor dialogue box opens.
- Specify the Partner Link AppraisalProvider and operation. The operation should be HomeAppraisalDefnOperation.
- Click Create button to create an input variable. Note the default name of the variable is HomeAppraisalDefnOperationIn. Leave all the settings for the input variable as they are and click Ok.
- Click Ok to close the Property Editor. A link appears between the Partner Link and the Receve1 activity. This Receive activity will consume/receive the message sent by the Loan Service and the request message will be stored in the variable HomeAppraisalDefnOperationIn that is created.
- Note that error mark disappeared. You can explicitly invoke validation by clicking Validate XML button on the toolbar. The result of the validation will be shown on the Output window.
- Create another Partner Link:
- Drag and drop the HomeAppraisalCallbackDefn.wsdl file to the right from the diagram. A Partner Link will be created.
- Double click the Partner Link name. Change it to ApprisalCallbackPartner.
- Drag and drop an Invoke activity from the Palette. Place it below the Receive activity.
- Configure the properties of the Invoke activity as follows:
- In the Design view, double-click the Invoke activity. The Property Editor window opens.
- Choose ApprisalCallbackPartner from the Partner Link drop-down list and HomeApprisalCallbackDefnOperation from the Operation drop-down list.
- To create an input variable, click the Create button for the Input Variable field. Note the default name of the variable is HomeApprisalCallbackDefnOperationIn. Leave the settings as they are and click OK.
- Click OK to close the Property Editor.
Note that a connection between the Invoke activity and the partner service appeared.
This Invoke will send an outbound message to the Loan Service. This outbound message serves as a callback mechanism to the Loan Service which initiated the communication. Later you create a new Receive in the Loan Service which consumes the message sent by this Invoke.
The variable we created as the input variable of this invoke, HomeApprisalCallbackDefnOperationIn, will be populated with the response that will be sent to the Loan Service.
- Drag an If activity from the Palette, drop it between the Receive1 and Invoke1 activities.
The process looks as follows:

Figure-02: An If activity is added to the HomeAppraisal process diagram.
- To define the condition for the If activity, do the following:
- In the Design view, double-click the If activity.
The BPEL Mapper window opens.
- In the menu bar, choose Operator > Less or Equal. A function box appears in the middle pane (blue band).
- In the Source tree pane (the left pane) of the BPEL Mapper, under Variables, expand HomeAppraisalDefnOperationIn (i.e., the input variable of the Receive1) > part1 > LoanDetails node.
- Connect the LoanAmount subnode to the top node on the left of the Less or Equal function box.
- Connect the HomePrice subnode to the bottom node on the left of the Less or Equal function box.
- Connect the node on the right of the Less or Equal box to the Boolean Condition node on the right pane.
You created a condition which states "if the loan amount is less than the home price do the logic in the If branch", which is to send the result of home appraisal as Approved. In the mapper, the condition looks as follows:

Figure-03: An If condition is defined using the BPEL mapper (HomeAppraisal process).
- Click on the Design tab or press Alt-D to go back to the process view.
- In the Design view, drag two Assign activities (one after another) from the Palette and place them on both branches of the If block.
- Configure the Assign activities by following the steps:
- Double click an Assign activity on the If branch of the If element. The BPEL Mapper opens.
- In the destination pane (the right tree pane), expand HomeAppraisalCallbackDefnOperationIn > part1. Select the Status node, so that a blue band appears.
- In the Mapper menu bar, choose String > String Literal.
A function box appears in the middle pane. Double-click the box and type Approved.
- Connect the String Literal box to the Status node in the right (destination) tree pane.
- In the source tree pane on the left, expand HomeAppraisalDefnOperationIn (variable associated with the Receive) > part1 > BorrowerInformation
- Connect the SSN node from the left pane to the SSN node in the right pane. The mapping looks as follows:

Figure-04: Assign1 activity is configured using the BPEL mapper (HomeAppraisal process).
This mapping has a special significance. The Loan Service sends a token - the value of SSN - to the Home Appraisal Service. Then the Home Appraisal Service calls back the Loan Service and sends the same value in the SSN field of its response. There could be many instances of the Loan Service active simultaneously and waiting for a response from the Home Appraisal Service, and you need to send a response to the very instance that sent a request. So when a response comes from the Home Appraisal Service, the Loan Service uses the value of the SSN to route the message to the correct Loan Service instance. The value of SSN is used as a mark to establish correlation for two asynchronous message exchanges.
-
Click the Design tab or press Alt-D to go back to the process diagram.
- Double-click an Assign activity on the Else branch of the If element. The BPEL Mapper opens.
- In the right pane, expand HomeAppraisalCallbackDefnOperationIn > part1. Select the Status node, so that a blue band appears.
- In the mapper menu bar, choose String > String Literal.
A function box appears in the middle pane. Double-click the box and type Denied.
- Connect the String Literal box to the Status node in the right destination tree pane.
- In the source tree pane on the left, expand HomeAppraisalDefnOperationIn (variable associated with the Receive) > part1 > BorrowerInformation.
- Connect the SSN node from the left pane to the SSN node in the right pane..
- Go back to the Design view.
- Click Validate XML button on the toolbar to ensure that the process code has no errors.
The Home Appraisal Service is complete.
Now you have to enhance the Loan Service so that it could communicate with the Home Appraisal Service.
- In the Projects window expand LoanApproval > Process files.
- Double click the LoanApproveService.bpel file. The LoanApproveService process diagram opens.
- Drag and drop an Invoke activity from the Palette. Place it below the CreditCheck Invoke activity.
- Double click the name of the activity, Invoke1, and change it to AppraisalRequest.
- Drag and drop a Receive activity to the placeholder between the AppraisalRequest Invoke activity and the If block.
- Double click the name of the Receive activity (Receive2) and change it to AppraisalCallback.
- In the Projects window under Loan Approval > Process Files node select HomeAppraisalDefn.wsdl file.
- Drag it to the right edge of the diagram and drop below two other Partner Links. A new Partner Link appears.
- Double click the name of the new Partner Link and change it to AppraisalProvider.
The process appears as shown below:

Figure-05: LoanApprovalService process is being modified to interact with Home Appraisal Service.
- Configure the properties of the AppraisalRequest Invoke activity as follows:
- In the Design view, double-click the Invoke activity. The Property Editor window opens.
- Choose AppraisalProvider from the Partner Link drop-down list.
- To create an input variable, click the Create button for the Input Variable field.
- In the New Input Variable window, leave the settings as they are and click OK. The variable name appears in the Input Variable field.
- Click OK. Note that a connection between the Invoke activity and the partner service appeared.
- In the Projects window under LoanApproval > Process Files node select HomeAppraisalCallbackDefn.wsdl file.
- Drag it to the left edge of the diagram and drop below the LoanApprovePartner Partner Link. A new Partner Link appears.
- Double click the name of the new Partner Link and change it to AppraisalCallbackPartner.
- Configure the properties of AppraisalCallback Receive activity following the steps:
- On the diagram, double-click the AppraisalCallback Receive activity. The Property Editor window opens.
- Specify the Partner Link as AppraisalCallbackPartner.
- Click Create to create an input variable. Leave all the settings for the input variable as they are and click Ok.
Note that the Loan Service will be blocked on this Receive activity until a message from the Appraisal Service is received.
- Drag an Assign activity from the palette and drop it between the CreditCheck Invoke activity and AppraisalRequest Invoke activity.
- Double click the Assign activity. The BPEL mapper opens.
- In the source tree pane expand LoanApproveDefnOperationIn (input variable of the first Receive), in the destination tree pane expand HomeAppraisalDefnOperationIn (input variable of the AppraisalRequest Invoke) and connect their part1 subnodes (see the figure below).

Figure-06: Assign1 activity is configured using the BPEL mapper (LoanApprovalService process).
- The necessary changes to the loan approval process are made. The final view of the process is like the one below.

Figure-07: Final view of the LoanApprovalService process.
There is still one thing missing! It was already mentioned about using SSN as the value for correlating the request and response that the Loan Service gets from the Home Appraisal Service. So, you need to define WS-BPEL correlation in the Loan Approve Process.
Defining Correlation
To establish correlation in the Loan Service, follow the steps below:
- As you see, the AppraisalCallback Receive activity is marked with a warning label as it requires correlation because of the reasons stated above. Right-click the AppraisalCallback Receive activity and choose Define Correlation. The Define Correlation wizard opens.
- Step1. On the first page of the wizard, select the initiating messaging activity. Initiating activity will initiate correlation so that later it could be used for routing incoming messages. Choose the AppraisalRequest Invoke activity from the drop-down list.

Figure-08: The first page of the Correlation Wizard. Select the initiating messaging activity.
- Step2. On the second page of the wizard you see tree structures of the message passed by the initiating (on the left) and correlating activity (on the right. This is AppraisalCallback Receive activity). On the left pane under Invoke expand HomeAppraisalDefnOperationRequest > part1 > LoanInformation > BorrowerInformation. On the right pane under Receive expand HomeAppraisalCallbackDefnOperationRequest > part1 > Appraisal Status. Map the SSN node from the right pane to the SSN node in the left pane.

Figure-09: The second page of the Correlation Wizard. Define the correlation.
- Click Finish. This action generates all the required BPEL constructs: correlationSet and correlation in the BPEL file, property and propertyAlias in a WSDL file. For the properties and property aliases a new WSDL file WizardCorrelationProperties.wsdl is created automatically. You can see it among the process files of the LoanApproval module in the Projects window. The original WSDL files describing the partner services are imported to the new WSDL. For more information on correlation, properties and property aliases, see Understanding Correlation. Using the Correlation Wizard.
- Modify the If condition in the Loan Approve Service so that it included the status received from the Appraisal Service also:
- Ensure that the LoanApproveService.bpel file is open.
- Double click the If block. The BPEL Mapper with the defined condition opens.
- Modify the condition as follows:
- Select the link outgoing from the Equal box and delete it.
- In the menu bar, choose String > String Literal. A function box appears in the middle pane.
- Double click the box and type Approved.
- In the menu bar, choose Operator > Equal.
- Connect the String Literal box to the lower node of the new Equal Box .
- In the Source tree pane (the left pane) of the BPEL Mapper, under Variables, expand HomeAppraisalCallbackDefnOperationIn (i.e., the variable that is used to receive data from the Home Appraisal Service) > part1 node.
- Connect the Status node to the upper node of the new Equal box.
- In the menu bar, choose Boolean > Logical And.
- Connect nodes on the right of the two Equal boxes to the two nodes of the And box.
- Connect the node on the right of the And box to the Boolean Condition. The mapping looks as follows:

Figure-010: The modified If block ofn the LoanApprovedService process.
- The new condition states: "If both the Status values (the one received from the Credit Check Service and the one received from the Home Appraisal Service) are “Approved”, then the boolean value is true".
- Go back to the design mode and validate the BPEL to ensure you have no errors. Congratulations, you have finished creating the services!
Testing the Loan Approve Service:
- In the Projects window, right click the LoadApprovalServiceAssembly composite application node and choose Clean and Build from the context menu. Notice a message similar to the following message appears in the Output window:
BUILD SUCCESSFUL.
- Now right-click the LoadApprovalServiceAssembly composite application node and choose Deploy. Notice a message similar to the following message appears in the Output window:
BUILD SUCCESSFUL.
- In the Projects window, expand the LoanApprovalServiceAssembly > Test > TestLoanApprovalProcess node.
- Double-click the Input.xmland modify its content as follows:
<BorrowerInformation> <Name>John Smith</Name> <SSN>666777888</SSN> <Address> <Addr1>?string?</Addr1> <CityState>?string?</CityState> <Zip>?string?</Zip> <Telephone>?string?</Telephone> </Address> </BorrowerInformation> <LoanDetails> <LoanAmount>400000</LoanAmount> <HomePrice>500000</HomePrice> <HomeAddress> <Addr1>?string?</Addr1> <CityState>?string?</CityState> <Zip>?string?</Zip> <Telephone>?string?</Telephone> </HomeAddress> </LoanDetails>
- Run a test case:
- In the Projects window, navigate to the LoanApprovalServiceAssembly > Test > TestLoanApprovalProcess directory.
- Right-click the TestLoanApprovalProcess node, and choose Run from the pop-up menu.
Notice this message in the JUnit Test Results window: TestLoanApprovalProcess passed. When you get a prompt, refuse to write the received result to the Output.xml file.
- The output message for this process is written to a file. For Windows-based systems, go to My Computer, C:\Temp\
For Unix based systems to the user home directory.
Theses are the default directories for the external output file.
- Open the test.xml file with a text editor. The loan is approved since the SSN starts with 6 and the Loan Amount is less than the Home Price.
- Now change the Loan Amount in the Input file to 600000 and run the test case again:
- Run the test case again as described above.
- Open the test.xml file with a text editor. The loan is denied: though the SSN starts with 6, the Loan Amount is more than the Home Price, so one of the conditions is not met.
The exercise 3 is completed! Congratulations!
Summary:
In this exercise you created a Home Appraisal Service, modified the Loan Service to call the Appraisal Service and to receive a response from it asynchronously. You also modified the Loan Service to check the result returned by the Appraisal Service. You studied how asynchronous business process works and how BPEL correlation is used.
See Also
top
|
|