9.15.1 Update the Web Service Reference for Our Window-Based Client Project
Prior to any code development, we need first to update our Web Service Reference to enable our cli-ent project to use the correct Web Service. Perform the following operations to set up a Web service reference for our client project:
1) Build and deploy our Web Service application project, WebAppCourse, first to make sure that the Web Service is available to our client project.
2) Expand our Web Service References folder and right-click on the existing service file, WebServiceFaculty, and select the Delete item to remove this reference.
3) Right-click on our client project, WinClientCourse _ Select, from the Projects window, and select the New > Other item to open the New File wizard.
4) In the opened New File wizard, select Web Services from the Categories and Web Service Client from the File Types list. Click on the Next button to continue.
5) Click on the Browse button for the Project field and expand our Web application proj-ect, WebAppCourse, and click on our Web service, WebServiceCourse, to select it. Then click on the OK button to select this Web service.
6) Click on the Finish button to complete the Web service reference setup process.
Immediately you can find a new node named Web Service References has been created and added into our client project. Expand this node, and you can find the associated Web service port and our five Web service operations, such as QueryCourse() and QueryCourseID(), under that node.
Now build our new project by clicking on the Clean and Built Project button on the top. Next let’s develop the code for these event handlers to access our Web operations to perform related queries to the Course Table in our sample database.
9.15.2 Develop the Code to Query Course Information from our Web Service
In our Web service class file, WebServiceCourse, we built five operations with five different data actions against the Course Table in our database. Now we need to develop the code in our client proj-ect to call those five operations to access and query the Course Table in our sample database via five buttons in our client project, WinClientCouse _ Select, that is, in the CourseFrame.java class file. Each button has a one-to-one relationship with the related operation, as shown in Table 9.7.
Let’s start our coding process from the Select button, that is, with its event handler or method SelectButtonActionPerformed(), in our client project.