Creating a Loan Processing Composite Application

Last Updated: 14 November 2006
Contributed by Sherry Barkodar, maintained by Alyona Stashkova

This tutorial provides an overview of a simple Loan Requestor composite application and illustrates deploying, executing, and testing of a Composite Application using the NetBeans Enterprise Pack 5.5 bundle with all the necessary runtimes.

The Loan Requestor composite application satisfies the following business use case:

Loanprocessing diagram
Click to enlarge

Prerequisites

This tutorial assumes that you have some basic knowledge of, or programming experience with, the Java language and platform and the NetBeans IDE.

System Requirements

This tutorial assumes that your system meets the requirements specified in the System Requirements topic of the NetBeans Enterprise Pack 5.5 Release Notes.

Software Needed for the Tutorial

Before you begin, you must install the following software on your computer:

Contents

top

Configuring the Tutorial Environment

Before you can deploy your application, the Sun Java System Application Server and JBI runtime must be configured correctly and running.

To configure the tutorial environment:

  1. Click the Runtime tab to open the Runtime window.
  2. In the Runtime window, expand the Servers node.
  3. If the Servers node already contains a Sun Java System Application Server 9 node, then go to step 5.
  4. If the Servers node does not contain a Sun Java System Application Server 9 node, then do the following to add an application server:
    1. Right-click the Servers node and choose Add Server from the pop-up menu.
      The Add Server Instance dialog box opens.
    2. In the Choose Server page, from the Server drop-down list, select Sun Java System Application Server.
    3. (Optional) In the Name field, accept the default value or type the name you want to use to identify the server in the IDE.
    4. Click Next.
      The Platform Location Folder page opens.
    5. In the Platform Location field, use the Browse button to navigate to and select the Application Server installation location.
      If you accepted the default values during the installation, the location is C:\Sun\Appserver.
    6. Select the Register Local Default Domain option.
    7. Click Next.
    8. Supply 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.
    9. Click Finish.
  5. In the Runtime window, right-click the Sun Java System Application Server 9 node and choose Start.
    If the Start option is not available, the server is already running and you can skip the next step.
  6. Wait until the following message appears in the Output window:
    Application server startup complete.
    When the server is running, the IDE displays a green arrow badge on the Sun Java System Application Server 9 node.

Application Server running
Click to enlarge

top

Creating the BPEL Project

In this section, you create a BPEL Module project called LoanRequestor.

To create the LoanRequestor project:

  1. From the IDE's main menu, choose File > New Project.
    The New Project wizard opens.
  2. In the Categories list, select the Service Oriented Architecture node.
  3. In the Projects list, select the BPEL Module node.
  4. Click Next.
  5. In the Project Name field, type LoanRequestor.
  6. (Optional) In the Project Location field, use the Browse button to navigate to and select a different folder where the IDE will store the project files.
  7. Click Finish.
    The Projects window now contains a project node for a BPEL Module project called LoanRequestor.

LoanRequestor Project

top

Creating the XML Schema

In this section, you add a new XML schema file to your BPEL Module project and then add XML schema components to the schema.

To create LoanRequestor.xsd:

  1. In the Projects window, expand the LoanRequestor project node, then right-click the Process Files node and choose New > File/Folder.
    The New File wizard opens.
  2. In the New File wizard, do the following:
    1. In the Choose File Type page, in the Categories list, select the XML node, then in the File Types list, select the XML Schema node and click Next.
    2. In the File Name field, type LoanRequestor.
    3. Click Finish.
    In the Projects window, the Process Files node now contains a subnode labeled LoanRequestor.xsd. The Source Editor contains a tab for the XML schema file, LoanRequestor.xsd, with the Schema view open.
  3. In the Schema view, click the Design button to open the Design view of the XML schema editor.

XML schema editor design view

To add complex types to the XML schema:

  1. In the Palette of the Design view, expand the XML Schema Components section and select the Complex Type icon.
    If the Palette window is not visible, choose Window > Palette from the main menu.
  2. Drag your selection to the schema design area immediately below the Complex Types node.
    The IDE adds a Complex Type node and the name of the complex type (newComplexType) is selected and ready for you to change.
  3. Type processApplication in the new node and press Enter.
    The Design area now shows your new complex type, called processApplication.
  4. Repeat steps 1 to 3 and name another new complex type processApplicationResponse.

Complex types to XML schema added

To add local elements to processApplication and processApplicationResponse:

  1. In the XML Components section of the Palette, select the Element icon and drag your selection onto the processApplication node in the schema design area.
    The IDE adds an element node labeled newElement.
  2. If the Properties window is not visible, choose Window > Properties.
  3. In the Schema design area, select the newElement node.
  4. In the Properties window, select the value field of the Name property to make it editable and type socialSecurityNumber.
  5. In the Properties window, set the value field of the Nillable property to True.
  6. In the Properties window, in the Definition property, click the ellipsis button.
    The Definition dialog box opens.
  7. In the list, expand the Built-in Types node and select the string node.
  8. Click OK.
  9. Repeat steps 1 to 8 to add the following elements:
    Name Nillable Definition
    applicantName True string
    applicantAddress True string
    applicantEmailAddress True string
    applicantAge True int
    applicantGender True string
    annualSalary True double
    amountRequested True double
  10. In the XML Components section of the Palette, select the Element icon and drag your selection onto the processApplicationResponse node in the schema design area.
    The IDE adds an element node labeled newElement.
  11. In the schema design area, select the newElement node.
  12. In the Properties window, select the value field of the Name property to make it editable and type return.
  13. In the Properties window, in the Definition property, click the ellipsis button.
    The Definition dialog box opens.
  14. In the list, expand the Built-in Types node and select the string node.
  15. Click OK.

Local elements to complex types added

To add global elements:

  1. In the XML Components section of the Palette, select the Element icon and drag your selection to the Design area, immediately below the Elements node.
    The IDE adds a newElement component below the Elements nodes in the schema design area.
  2. In the Schema design area of the Design view, select the newElement node.
  3. In the Properties window, select the value field of the Name property to make it editable and type processApplication.
  4. In the Properties window, in the Definition property, click the ellipsis button.
    The Element's definition - Definition dialog box opens.
  5. In the list of types, expand the Complex Types node and select the processApplication complex type node.
  6. Click OK.
  7. Repeat steps 1 to 6 to add the following element:
    Name Complex Types
    processApplicationResponse processApplicationResponse
  8. To save your changes, in the Projects window, select the LoanRequestor project node, and from the IDE's main menu, choose File > Save All.

Global elements to XML schema added

top

Creating the WSDL Document

In this section, you add a WSDL file to your BPEL Module project and then configure the components of the WSDL Document.

To create LoanRequestor.wsdl:

  1. In the Projects window, expand the LoanRequestor project node, then right-click the Process Files node and choose New > WSDL Document.
    The New WSDL Document wizard opens.
  2. In the Name and Location page, do the following:
    1. In the File Name field, type LoanRequestor.
    2. Select the Import XML Schema File(s) checkbox.
    3. In the XML Schema(s) field, click the Browse button.
      The Select Schemas dialog box opens. This dialog box shows the XML schemas in your project.
    4. Select src/LoanRequestor.xsd and click OK.
    5. Click Next.
    The Abstract Configuration page opens.
  3. In the Input area of the Abstract Configuration page do the following:
    1. In the Message Part Name column, double-click the default value to make the field editable.
    2. Type requestLoanMessage and press Enter.
    3. In the Element Or Type column, click the ellipsis button.
      The Select Element Or Type dialog box opens.
    4. Expand the LoanRequestor node, the src/LoanRequestor.xsd node, and the Elements node.
    5. Under the Elements node, select the processApplication node and click OK.
  4. In the Output area of the Abstract Configuration page do the following:
    1. In the Message Part Name column, double-click the default value to make the field editable.
    2. Type responsePart and press Enter.
    3. In the Element Or Type column, click the ellipsis button.
      The Select Element or Type dialog box opens.
    4. Expand the LoanRequestor node, the src/LoanRequestor.xsd node, and the Elements node.
    5. Under the Elements node select processApplicationResponse and click OK.
  5. Click Next.
    The Concrete Configuration page opens.
    Note: When you perform the next step, the error message at the bottom of the page disappears.
  6. Under Binding Subtype, select the Document Literal option.
  7. Click Finish.
    In the Projects window, the Process Files node now contains a subnode labeled LoanRequestor.wsdl. The Source Editor contains a tab for the WSDL file, LoanRequestor.wsdl, with the new WSDL view open.

LoanRequestor.wsdl created
Click to enlarge

top

Partner Services

The Loan Application communicates with its partner services via their public interfaces. These interfaces are defined in partner-specific WSDL files.
This tutorial includes a zipped J2EE project called LoanProcessor and instructions for creating the EJB from scratch in the Appendix. The LoanRequestor project contains a very basic EJB implementation of a partner service.
The partner web service must be deployed to the bundled Sun Java Application Server before you can test run the LoanRequestorCompositeApp.

This implementation is only meant to serve as a test harness for the Loan Service process.

To open the LoanProcessor project:

  1. In your file system, create a directory named LoanTut.
  2. Download the loanejb.zip file and extract it into the LoanTut directory.
  3. From the IDE's main menu, choose File > Open Project.
    The Open Project wizard opens.
  4. Navigate to the LoanTut directory that you just created, select the LoanProcessor project, and click Open Project Folder.
    A progress dialog box appears, and then the project appears in the Projects window.

LoanProcessor project added

To deploy the LoanProcessor project:

  1. Right-click the LoanProcessor and choose Deploy Project.
  2. Wait until the BUILD SUCCESSFUL message appears in the Output window.
  3. To verify that the LoanProcessor enterprise application is successfully deployed, switch to the Runtime window.
  4. Expand the Sun Java System Application Server node, the Applications node, and the EJB Modules node.
    The LoanProcessor node must be added.

LoanProcessor project deployed

top

Creating the BPEL Process

To create LoanRequestor.bpel:

  1. In the Projects window, expand the LoanRequestor project node, right-click the Process Files node and select New > BPEL Process.
    The new BPEL Process wizard opens.
  2. In the File Name field, type LoanRequestor.
  3. Click Finish.
    In the Projects window, the Process Files node now contains a subnode labeled LoanRequestor.bpel.
    The Source Editor contains a tab for the BPEL process, LoanRequestor.bpel, with the Design view of the BPEL Designer open.

LoanRequestor.bpel created

To add partner links:

  1. In the Projects window, expand the LoanRequestor project node, then expand the Process Files node and select the LoanRequestor.wsdl node.
  2. Drag your selection (LoanRequestor.wsdl) from the Projects window to the Design view.
    The Partnerlink1[Partner Link] - Property Editor opens.
  3. In the Name field, type BpelImplementation.
  4. Accept the defaults and click OK.
  5. In the Projects window, expand the LoanProcessor project node, then expand the Web Services node and select the LoanProcessor web service node.
  6. Drag your selection (LoanProcessor web service node) from the Projects window to the Design view.
    The Partnerlink1[Partner Link] - Property Editor opens.
  7. In the Name field, type EjbImplementation.
  8. Accept the defaults and click OK.
  9. In the Projects window, under Process Files, the Partners folder is created.
  10. Expand the Partners node, this folder contains the LoanProcessor node that includes LoanProcessor.wsdl and LoanProcessorService_schema1.xsd files.

Partner links added

To add a Receive activity:

  1. In the Web Service section of the Palette, select the Receive icon and drag your selection to the Design area between the Process Start activity and the Empty activity.
    The IDE provides you with visual clues to show you where you can drop the selection.
    This action places a Receive activity called Receive1 in the Design view.
  2. Double-click the Receive1 activity.
    The Receive1[Receive] Property Editor opens.
  3. Change the value in the Name field to ReceiveFromCustomer.
  4. From the Partner Link drop-down list, select BpelImplementation.
    The IDE fills in the Operation field.
  5. Create a new input variable by doing the following:
    1. Click the Create button next to the Input Variable field.
      The New Input Variable dialog box opens.
    2. Change the value in the Name field to requestLoanInput.
    3. Click OK.
  6. Click OK to close the Receive1 [Receive] - Property Editor.
    The Receive activity is now labeled ReceiveFromCustomer in the Design view.

ReceiveFromCustomer activity added

To add an Invoke activity:

  1. In the Web Service section of the Palette, select the Invoke icon and drag your selection to the Design area after the Receive activity.
    The IDE provides you with visual clues to show you where you can drop the selection.
    This action places an Invoke activity called Invoke1 in the Design view.
  2. Double-click the Invoke1 activity.
    The Invoke1[Invoke] - Property Editor opens.
  3. Change the value in the Name field to InvokeLoanProcessorEJB.
  4. From the Partner Link drop-down list, select EjbImplementation.
    The IDE fills in the Operation field.
  5. Create a new input variable by doing the following:
    1. Click the Create button next to the Input Variable field.
      The New Input Variable dialog box opens.
    2. Change the value in the Name field to processApplicationInput.
    3. Click OK.
  6. Create a new output variable by doing the following:
    1. Click the Create button next to the Output Variable field.
      The New Output Variable dialog box opens.
    2. Change the value in the Name field to processApplicationOutput.
    3. Click OK.
  7. Click OK to close the Invoke1[Invoke] - Property Editor.
    The Invoke activity is now labeled InvokeLoanProcessorEJB in the Design view.

InvokeLoanProcessorEJB activity added

To add a Reply activity:

  1. In the Web Service section of the Palette, select the Reply icon and drag your selection to the Design area after the Invoke activity.
    The IDE provides you with visual clues to show you where you can drop the selection.
    This action places a Reply activity called Reply1 in the Design view.
  2. Double-click the Reply1 activity.
    The Reply1 [Reply] - Property Editor opens.
  3. Change the value in the Name field to ReplyToCustomer.
  4. Set the Partner link to BpelImplementation.
  5. Create a new output variable by doing the following:
    1. Make sure the Normal Response option is selected.
    2. Click the Create button next to the Output Variable field.
      The New Output Variable dialog box opens.
    3. Change the value in the Name field to requestLoanOutput.
    4. Click OK.
  6. Click OK to close the Reply1 [Reply] - Property Editor.
    The Reply activity is now labeled ReplyToCustomer in the Design view.

ReplyToCustomer activity added

To add the first Assign activity:

  1. In the Design area, select the Empty activity, right-click and choose Delete from the pop-up menu.
  2. In the Basic Activities section of the Palette, select the Assign icon and drag your selection to the Design area between the Receive activity and the Invoke activity.
    The IDE provides you with visual clues to show you where you can drop the selection.
    This action places an Assign activity called Assign1 in the Design view.
  3. Select the Assign1 activity.
  4. In the Assign1 [Assign] - Properties window, select the value field of the Name property to make it editable, type AssignReceiveToEJBInput, and click OK.
  5. If the BPEL Mapper window is not visible, choose Window > BPEL Mapper from the main menu.
  6. In the left pane of the BPEL Mapper, under Variables, expand the requestLoanInput and requestLoanMessage nodes.
    socialSecurityNumber, applicantName, applicantAddress, applicantEmailAddress, applicantAge, applicantGender, annualSalary, amountRequested appear under requestLoanMessage.
  7. In the right pane of the BPEL Mapper, under Variables, expand the processApplicationInput and Parameters nodes.
    socialSecurityNumber, applicantName, applicantAddress, applicantEmailAddress, applicantAge, applicantGender, annualSalary, amountRequested appear under parameters.
  8. Drag socialSecurityNumber from the left pane of the BPEL Mapper to the socialSecurityNumber node in the right pane of the BPEL Mapper.
  9. Repeat step 7 for the following variables:
    applicantName, applicantAddress, applicantEmailAddress, applicantAge, applicantGender, annualSalary, and amountRequested.
  10. To save your changes, in the Projects window, select the LoanRequestor project node, and from the IDE's main menu, choose File > Save All.

AssignReceiveToEJBInput activity added

To add the second Assign activity:

  1. In the Basic Activities section of the Palette, select the Assign icon and drag your selection to the Design area between the Invoke activity and the Reply activity.
    This action places an Assign activity called Assign1 in the Design view.
  2. Select the Assign1 activity.
  3. In the Assign1 [Assign] - Properties window, select the value field of the Name property to edit it, type AssignEJBOutputToReply, and click OK.
  4. If the BPEL Mapper window is not visible, choose Window > BPEL Mapper from the main menu.
  5. In the left pane of the BPEL Mapper, under Variables, expand the processApplicationOutput and parameters nodes.
    return appears under parameters.
  6. In the right pane of the BPEL Mapper, under Variables, expand the requestLoanOutput and responsePart nodes.
    return appears under responsePart.
  7. Drag return from the left pane of the BPEL Mapper to the return node in the right pane of the BPEL Mapper.
  8. To save your changes, in the Projects window, select the LoanRequestor project node, and from the IDE's main menu, choose File > Save All.

AssignEJBOutputToReply activity added
Click to enlarge

To Build the LoanRequestor BPEL Project:

  1. In the Projects window, right-click the LoanRequestor project node and choose Clean and Build Project.
  2. If the BUILD SUCCESSFUL message appears in the Output window, then the Build has succeeded.

LoanRequestorBPEL project BUILD SUCCESSFUL message
Click to enlarge

top

Creating and Deploying the Composite Application

Before you deploy the BPEL Module project, you must add the JBI module to the deployment project. Deploying the project makes the service assembly available to the application server, thus allowing its service units to be run.

To create the Composite Application project and add the JBI module:

  1. From the IDE's main menu, choose File > New Project.
    The New Project wizard opens.
  2. In the Categories list, select the Service Oriented Architecture node.
  3. In the Projects list, select the Composite Application node.
  4. Click Next.
  5. In the Project Name field, type LoanRequestorCompositeApp.
  6. Click Finish.
    The Projects window now contains a project node for a Composite Application project called LoanRequestorCompositeApp.
  7. In the Projects window, right-click the LoanRequestorCompositeApp project node and choose Add JBI Module from the pop-up menu.
    The Select Project dialog box opens.
  8. Select the LoanRequestor project you created earlier in this tutorial and click Add Project JAR Files.
    The Select Project dialog box closes.
  9. In the Projects window, expand the LoanRequestorCompositeApp project node and then expand the JBI Modules node.
    Notice that a LoanRequestor.jar node has been added.

LoanRequestor.jar node added

To deploy the Composite Application:

LoanRequestorCompositeApp project BUILD SUCCESSFUL message
Click to enlarge

top

Testing the Composite Application

You can enhance the Composite Application project by adding test cases, binding to the operation, supplying input, and then using the Tester.

To test the LoanRequestorCompositeApp:

  1. In the Projects window, expand the LoanRequestorCompositApp project node, right-click the Test node, and choose New Test Case from the pop-up menu.
    The New Test Case wizard opens.
  2. For Test Case Name, type successTest, and click Next.
  3. In the Select the WSDL Document page, expand the LoanRequestor - Process Files node, select LoanRequestor.wsdl, and click Next.
  4. In the Select the Operation to Test page, select the LoanRequestorOperation and click Finish.
    In the Projects window, under Test, a new successTest node has been added.
    This node contains two subnodes: Input and Output.
    The Source Editor contains a tab for the Input file, Input.xml.
  5. If the Source Editor does not contain a tab for Input.xml, double-click the Input node in the Projects window to open the file.
  6. In the Source Editor tab for the Input.xml file, do the following:
    1. Locate the following line:
      <loan:socialSecurityNumber>?string?</loan:socialSecurityNumber>.
    2. Replace ?string? with 123-45-6789.
      The line should look like this:
      <loan:socialSecurityNumber>123-45-6789</loan:socialSecurityNumber>.
    3. Repeat steps a and b to replace elements in the following lines:
      Line Containing Replace With Resulting Line
      applicantName ?string? Gopalan <loan:applicantName>Gopalan</loan:applicantName>
      applicantAddress ?string? 507 Alberta <loan:applicantAddress>507 Alberta</loan:applicantAddress>
      applicantEmailAddress ?string? gopalan@sun.com <loan:applicantEmailAddress>gopalan@sun.com</loan:applicantEmailAddress>
      applicantAge ?3? 36 <loan:applicantAge>36</loan:applicantAge>
      applicantGender ?string? male <loan:applicantGender>male</loan:applicantGender>.
      annualSalary ?1.051732E7? 100000 <loan:annualSalary>100000</loan:annualSalary>
      amountRequested ?1.051732E7? 1000000 <loan:amountRequested>1000000</loan:amountRequested>.
    4. From the IDE's main menu, choose File > Save All.
  7. Double-click Output to examine its contents.
    Initially, output.xml is empty. Therefore the first test run will populate output.xml with the real output. Subsequent test runs will compare the real output against the contents of output.xml.
  8. In the Projects window, right-click the successTest node and choose Run from the pop-up menu.
    Note: The first run is a special case because Output.xml is empty and the output is written to Output.
    Notice the failed message in the JUnit Test Results window.
    The Overwrite Empty Output? dialog box opens.
  9. Click Yes.
  10. In the Projects window, right-click the successTest node and choose Run from the pop-up menu.
    After the first run, Output is no longer empty. The file's contents are preserved and are not overwritten by the new result.

successTest passed
Click to enlarge

top

 

Creating BPEL Web Service Client

The customer submits the required information through a web service client.

To create the LoanApplicationWebclient web service client application:

  1. From the IDE's main menu, choose File > New Project.
    The New Project wizard opens.
  2. In the Categories list, select the Web node.
  3. In the Projects list, select the Web Application node.
  4. Click Next.
  5. In the Name and Location page, in the Project Name field, type LoanApplicationWebclient.
  6. Click Finish.
    The Projects window now contains a project node for a web service client called LoanApplicationWebclient.
  7. In the Projects window, right-click the LoanApplicationWebclient project node and choose New >File/Folder.
    The New File wizard opens.
  8. In the New File wizard, do the following:
    1. In the Choose File Type page, in the Categories list, select the Web Services node.
    2. In the File Types list, select the Web Service Client node.
    3. Click Next.
    4. In the WSDL and Client Location page, select the Local File option.
    5. Click the Browse button.
    6. In the Open dialog box, navigate to and select the LoanRequestor.wsdl file.
    7. Click Open.
    8. In the Package field, type loanprocesswsclient.
    9. Click Finish.

LoanApplicationWebclient build successful

To create the loanclient.jsp page:

  1. In the Projects window, right-click the LoanApplicationWebclient project node and choose New > File/Folder.
  2. In the New File wizard, do the following:
    1. In the Choose File Type page, in the Categories list, select the Web node
    2. In the Choose File Type page, in the File Types list, select the JSP node
    3. Click Next.
    4. In the JSP File Name field, type loanclient and accept the defaults.
    5. Click Finish.
  3. In the Projects window, expand the LoanApplicationWebclient node and then expand the Web Pages node.
    Notice that a loanclient.jsp node has been added and the loanclient.jsp file is opened in the Source Editor.
  4. In the Source Editor tab for the loanclient.jsp file, right-click to display the pop-up menu and select Web Service Client Resources > Call Web Service Operation.
  5. In the Select Option to Invoke dialog box, expand the LoanApplicationWebClient node and then expand the LoanRequestor node.
  6. Expand the LoanRequestorService node and then expand the LoanRequestorPort node.
  7. Select LoanRequestorOperation and click OK.

loanclient.jsp created
Click to enlarge

To modify the loanclient.jsp file:

  1. In the Source Editor tab for the loanclient.jsp file, add the following code lines under // TODO process result here:
    requestLoanMessage.setSocialSecurityNumber(request.getParameter("ssn"));
    	 requestLoanMessage.setApplicantName(request.getParameter("name"));
    	 requestLoanMessage.setApplicantAddress(request.getParameter("address"));
    	 requestLoanMessage.setApplicantEmailAddress(request.getParameter("email"));
    	 requestLoanMessage.setApplicantAge(Integer.parseInt(request.getParameter("age")));
    	 requestLoanMessage.setApplicantGender(request.getParameter("gender"));
    	 requestLoanMessage.setAnnualSalary(Double.parseDouble(request.getParameter("salary")));
    	 requestLoanMessage.setAmountRequested(Double.parseDouble(request.getParameter("loanamount")));
  2. In the Source Editor tab for the loanclient.jsp file, do the following:
    1. Locate the following line:
      out.println("Result = "+result);
    2. Replace "+result with "+result.getReturn()
      The line should look like this:
      out.println("Result = "+result.getReturn());
    3. Add the code line below under // TODO handle custom exceptions here
      out.println("===>>>Exception : " + ex.toString());
    4. Add the code line below under // <%-- end web service invocation --%><hr/>
      <form action="index.jsp"> <input type="submit" value="Back To Loan Application"/> </form>
    5. To save your changes, in the Projects window, select the loanclient.jsp node, and from the IDE's main menu, choose File > Save.

loanclient.jsp modified
Click to enlarge

To modify the index.jsp file:

  1. In the Projects window, expand the LoanApplicationWebclient project node, then expand the Web Pages node.
  2. Double-click the index.jsp node.
    The index.jsp file opens in the Source Editor.
  3. Add the following code lines before </body>
    <form action="loanclient.jsp">
    	<table>
    		<tr>
    		   <td>SSN</td>
    		   <td><input type="text" name="ssn" value="123456789"/></td>
    		   <td></td>
    		</tr>
    		<tr>
    		   <td>Name</td>
    		   <td><input type="text" name="name" value="ORCHBank User"/></td>
    		      <td></td>
    		</tr>
    		<tr>
    		   <td>Address</td>
    		   <td><input type="text" name="address" value="16 Network Circle, Menlo Park,CA" /></td>
    		   <td></td>
    		</tr>
    		<tr>
    		   <td>Email</td>
    		   <td><input type="text" name="email" value="orchbankuser@bankmail.com" /></td>
    		      <td></td>
    		</tr>
    		<tr>
    		   <td>Age</td>
    		   <td><input type="text" name="age" value="27" /></td>
    		   <td>Age Limit : Min = 18, Max = 65, (If age exceeds 60 BPEL engine's rule rejects the application)</td>
    		</tr>
    		<tr>
    		   <td>Gender</td>
    		   <td><input type="text" name="gender" value="male" /></td>
    		      <td></td>
    		</tr>
    		<tr>
    		   <td>Salary</td>
    		   <td><input type="text" name="salary" value="56789.10" /></td>
    		   <td>Minimum Salary = 20000.00</td>
    		</tr>
    		<tr>
    		   <td>Loan Amount</td>
    		   <td><input type="text" name="loanamount" value="19500.00" /></td>
    		      <td></td>
    		</tr>
    		<tr>
    		   <td></td>
    		   <td><input type="submit" value="submit" name="Submit Application" /></td>
    		</tr>
    		   <td></td>
    	</table>
    </form>
  4. To save your changes, in the Projects window, select the index.jsp node, and from the IDE's main menu, choose File > Save.

To run the index.jsp file:

  1. In the Projects window, expand the LoanApplicationWebclient node, then expand the Web Pages node.
  2. Expand the WEB-INF node and select index.jsp
  3. Right-click the index.jsp file, and choose Run File from the pop-up menu.
  4. In the Output window, the URL that the index.jsp is browsing and BUILD SUCCESSFUL message appear if the build has succeeded.
  5. A browser appears. If not, launch a browser and type in the URL that is listed in the LoanApplicationWebclient (run) tab of the Output window.
    The JSP Page displays.

    JSP page
    Click to enlarge

  6. In your browser, in the JSP Page, click the submit button.
    Loan Application Status is displayed.

    Loan Application Status

top

----------------------------------------

Appendix

To create EJB project

To create EJB Module:

  1. From the IDE's main menu, choose File >New Project.
  2. Under Categories select the Enterprise node.
  3. Under Projects, select the EJB Module node.
  4. Click Next.
  5. In the Project Name field, type LoanProcessor.
  6. (Optional) In the Project Location field, use the Browse button to navigate to and select a different folder where the IDE will store the EJB project files.
  7. Click Finish.
    The Projects window now contains a project node for an EJB Module project called LoanProcessor.

To create new web services:

  1. In the Projects window, right-click the LoanProcessor node, choose New > Web Service from the context menu.
    The New Web Service wizard opens.
  2. In the New Web Service wizard, do the following:
    1. In the Name and Location page, in the Web Service Name field, type LoanProcessor.
    2. In the Package field, type com.sun.loanprocessor.
    3. Click Finish
  3. In the Projects window, expand the LoanProcessor project node, then expand the Web Services node.
  4. Right-click the LoanProcessor node and choose Add Operation.
    The Add Operation dialog box opens.
  5. In the Name field, type processApplication.
  6. Click the Add button.
    The Enter Method Parameter dialog box opens.
  7. In the Type drop-down list, select String.
  8. In the Name, type socialSecurityNumber.
  9. Click OK.
  10. Repeat steps 6 to 8 to create six other parameters with the following description:
    Type
    Name
    String applicantName
    String applicantAddress
    String applicantEmailAddress
    int applicantAge
    String applicantGender
    double annualSalary
    double amountRequested
  11. Click OK.
  12. In the Projects window, expand the LoanProcessor project node, then expand the Web Services node.
  13. Expand the LoanProcessor web service and double-click the processApplication node.
    Notice that the Source Editor contains a tab with a skeleton for the processApplication method, LoanProcessor.java.
  14. Copy the body of the method below and paste it in the Source Editor tab for the LoanProcessor.java file, immediately under the signature of your automatically generated method, to change the processApplication operation to the following:
    public String processApplication(@WebParam(name = "socialSecurityNumber") String socialSecurity,
    @WebParam(name = "applicantName")String applicantName, @WebParam(name = "applicantAddress") String applicantAddress,
    @WebParam(name = "applicantEmailAddress")String applicantEmailAddress, 
    @WebParam(name = "applicantAge") int applicantAge, @WebParam(name = "applicantGender")String applicantGender,
    @WebParam(name = "annualSalary") double annualSalary, @WebParam(name = "amountRequested")double amountRequested) {
    int MINIMUM_AGE_LIMIT = 18;
    int MAXIMUM_AGE_LIMIT = 65;
    double MINIMUM_SALARY = 20000;
    int AVERAGE_LIFE_EXPECTANCY = 70;

    String result = "Loan Application APPROVED.";

    if(applicantAge < MINIMUM_AGE_LIMIT) {
    result = "Loan Application REJECTED - Reason: Under-aged "+applicantAge+". Age needs to be over "+MINIMUM_AGE_LIMIT+" years to qualify.";
    System.out.println(result);
    return result;
    }

    if(applicantAge > MAXIMUM_AGE_LIMIT) {
    result = "Loan Application REJECTED - Reason: Over-aged "+applicantAge+". Age needs to be under "+MAXIMUM_AGE_LIMIT+" years to qualify.";
    System.out.println(result);
    return result;
    }

    if(annualSalary < MINIMUM_SALARY) {
    result = "Loan Application REJECTED - Reason: Annual Salary $"+annualSalary+" too low. Annual Salary needs to be over $"+MINIMUM_SALARY+" to qualify.";
    System.out.println(result);
    return result;
    }

    int yearsToRepay = AVERAGE_LIFE_EXPECTANCY-applicantAge;
    double limit = annualSalary*yearsToRepay*0.5;
    if(amountRequested > limit) {
    result = "Loan Application REJECTED - Reason: You are asking for too much $"+amountRequested+". Annual Salary $"+annualSalary+", Age "+applicantAge+" years. Your limit is $"+limit;
    System.out.println(result);
    return result;
    }
    System.out.println(result);
    return result;
    }
  15. To save your changes choose File > Save from the IDE's main menu.

top


Copyright and Trademark Notice