BUILD A WINDOW-BASED CLIENT PROJECT TO CONSUME THE WEB SERVICE – Develop Java Web Services to Access Databases

9.6  BUILD A WINDOW-BASED CLIENT PROJECT TO CONSUME THE WEB SERVICE

To save time and space, we can use the Window-based project OracleSelectFaculty we developed in Section 6.3 in Chapter 6 to build our new client project, WinClientFaculty _ Select. That project can be found in the folder Class DB Projects\Chapter 6, which is located in the Students folder on the CRC Press ftp site (refer to Figure 1.2 in Chapter 1).

9.6.1  Copy the FacultyFrame and MsgDialog Components as GUIs

Perform the following operations to create a GUI for our Window-based client project,
WinClientFaculty _ Select, to consume our Web service:

1) Launch NetBeans IDE 12.0 and choose File > New Project.
2) Select Java with Ant and Java Application from the Categories and
Projects lists, respectively. Click on the Next button.
3) Name the project WinClientFaculty _ Select and select a desired folder to save this project. Uncheck the Create Main Class checkbox. Your finished Name and Location wizard should match the one shown in Figure 9.31. Click on the Finish button to create this project.

FIGURE 9.31   The finished Name and Location wizard.

FIGURE 9.32   The finished Copy Class wizard.

4) Go to the Students folder on the CRC Press ftp site and load and open the project OracleSelectFaculty from the folder Class DB Projects\Chapter 6.
5) In the opened project, right-click on the Faculty Frame file FacultyFrame.java under the project package node, and select the Refactor > Copy item to copy this form file.

Copy Class—FacultyFrame wizard, select our new project,
WinClientFaculty _ Select, from the Project combo box and remove the 1 FacultyFrame from the New Name field. Your finished Copy Class wiz-6)Intheopenedafterthe ard is shown in Figure 9.32.
7) Click on the Refactor button to make a refactored copy of the frame file.
8) Return to our new project, WinClientFaculty _ Select, and you can see that a copied FacultyFrame.java file has been pasted in the default package in our project.
Perform a similar Refactor operation to copy the MsgDialog.java file and paste it into our new client project. Next let’s develop the code to call our Web service to perform the faculty data query. However, before we can begin the coding process, we must first setup or create a Web service reference for our WinClientFaculty _ Select project to enable our project to recognize the Web service and call it when it is instructed to do so.

Leave a Reply

Your email address will not be published. Required fields are marked *