Blog / Build the Code to Call the DeleteFaculty() Operation – Develop Java Web Services to Access Databases

Build the Code to Call the DeleteFaculty() Operation – Develop Java Web Services to Access Databases

Build the Code to Call the DeleteFaculty() Operation – Develop Java Web Services to Access Databases


9.12.3   Build the Code to Call the DeleteFaculty() Operation

Open our Window-based client project, WinClientFaculty _ UpdtDelt, and double-click on our main class, FacultyFrame.java, to open it. Click on the Design button to open the graphic user interface. In this client project, we need to use the Delete button in this form as a trigger to start the faculty data delete action. Therefore double-click on the Delete button to open its event method, DeleteButtonActionPerformed().

Enter the code shown in Figure 9.61 into this DeleteButtonActionPerformed() event handler. Let’s have a closer look at this piece of code to see how it works.

A. A try catch block is used to call our Web service operation DeleteFaculty() to perform the faculty data delete action. First a new Web service instance service is created based on our Web service class, WebServiceFaculty _ Service. Then the getWebServiceFacultyPort() method is executed to get the current port used by our Web service. This port is returned and assigned to a new port instance, port.

B. The Web service operation DeleteFaculty() is executed with the selected faculty name as the argument of this method. The run result of that operation is returned and assigned to a Boolean variable, delete.

C. If the value of the returned variable delete is false, which means that no row has been deleted from our Faculty Table and the data delete action has failed, the msgDlg instance is used to show this situation. Otherwise, the data delete action is successful.

D. The catch block is used to track and display any possible exception during this Web service operation execution.

FIGURE 9.61   The complete code for the DeleteButtonActionPerformed() method.

At this point, we have completed all code development for our Window-based client project for the data update and delete actions. Now let’s build and run our client project to call and test our Web service to perform faculty data update and delete actions.

Angela Gaffney

  • 0

Leave a Reply

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


                Copyright © 2024 Saucierlight.com. All Rights Reserved.