A. Two local variables, update and al, are created first. The first is a Boolean variable used to hold the run result of execution of the Web service operation UpdateCourse(), and the second is an ArrayList instance used to store an updating course record to be updated in the Course Table in our sample database later.
B. The ArrayList instance al is cleaned up by using the clear() method to make sure that the al is empty before it can store any data.
C. A group of add() methods is used to add six pieces of updated course information into the ArrayList instance. The first parameter is a faculty _ name for whom a course record will be updated, and the seventh parameter is a course _ id that will work as a query cri-terion and will not be changed. One point is that the order of the course data must be identi-cal to the order of the data in the ArrayList object cdata in our Web service operation, UpdateCourse(). Refer to that operation to make sure that both orders are identical.
D. A try-catch block is used to call our Web operation UpdateCourse() to update an existing course record via our Web service. First a new Web service instance, service, is created based on our Web service class, WebServiceCourse _ Service. Then a system method, getWebServiceCoursePort(), is executed to get the current port used by our Web service. This port is returned and assigned to a new port instance, port.
E. Our Web Service operation, UpdateCourse(), is executed to try to update the selected course record based on six pieces of updated information. The execution result is a Boolean variable, and it is returned and assigned to the local variable update.
F. If a false is returned, which means that this course data update has failed, the system println() method is used to indicate this situation.
G. The catch block is used to track and display any possible exception during the data update process.
Now we have finished the coding process for our client project to call our Web operation, UpdateCourse(), to update an existing course record in the Course Table based on the selected faculty member. Click on the Clean and Build Main Project button to build our project. Make sure that our Web Service application project, WebAppCourse, has been built and deployed successfully. Then click the Run Main Project button to run our client project to test the data update function.
In the opened client project, keep the default faculty member Ying Bai unchanged and click on the Select button to query all course _ id taught by this selected faculty member. Immediately you can see that all five courses or course _ id taught by this faculty member have been returned and displayed in the Course ID List box. To update an existing course, CSE-549, enter these six pieces of updated course information into the six TextFields:
• | Course ID: | CSE-549 |
• | Course: | Modern Controls |
• | Schedule: | M-W-F: 11:00–11:50 AM |
• | Classroom: | TC-206 |
• | Credit: | 3 |
• | Enrollment: | 18 |
Your finished CourseFrame window is shown in Figure 9.96. Click on the Update button to update this course record on the Course Table in our sample database.

FIGURE 9.96 The updated course information for the course CSE-549.
To test the course record update action, there is more than one way to go. The first way is to retrieve that course, that is, the course _ id, and click on that course _ id from the Course ListBox to get details to confirm the data update action. To do that, just click the Select button again to get all courses (course _ id) taught by the faculty member Ying Bai, then click any other course _ id, such as CSC-132B, from the Course ID ListBox. Now click on CSE-549 to retrieve its details. It can be seen that this course is really updated based on the update information shown in Figure 9.96. Our course data update using our Web Service is successful.
The second way to test the data update action is to connect to our sample database, CSE _ DEPT, and open the Course Table by using the Databases icon in the Services window inside the NetBeans IDE to confirm the data update action.
Generally it is recommended to recover this updated course on the Course Table in our sample database to keep our database neat and clean. However, we will keep this course right now since we need to use this record to perform the course delete action in the following section.