9.12 BUILD A WINDOW-BASED CLIENT PROJECT TO CONSUME THE WEB SERVICE
We can still use the Window-based client project WinClientFaculty _ Insert we built in Section 9.9 to consume the Web service to perform faculty data update and delete actions. One point to be noted is that although a Web reference to our Web service was established in Section 9.9, we still need to refresh this Web reference since our Web service project has been modified by adding two more operations, UpdateFaculty() and DeleteFaculty(). Otherwise, we would still use the old Web service that does not include these two operations.
To make things clear, we can copy the project WinClientFaculty _ Insert and rename it to our new Windows-based client project WinClientFaculty _ UpdtDelt and use this project to consume our Web Service to perform data update and delete actions to the Faculty Table in our sample database. Perform the following operations to rename the project:
1) Right-click on our original Windows-based client project, WinClientFaculty _ Insert, and select the Copy item from the popup menu to open the Copy Project wizard.
2) Change the project name to WinClientFaculty _ UpdtDelt in the Project Name box, and click on the Copy button to complete the project copy operation.
Now you may find that our copied project contains some errors with red error indicators. The rea-son for that is because our Web Service has been modified and we need to update our Web Service Reference for this new project, WinClientFaculty _ UpdtDelt.
9.12.1 Refresh the Web Service Reference for Our Window-Based Client Project
In order to call the UpdateFaculty() and DeleteFaculty() operations in our Web Service project, WebServiceFaculty, we need to refresh the Web reference in our client project to use the updated Web service project. Perform the following operations to refresh the Web service reference:
1) Build and deploy our Web Service application project, WebAppFaculty, first to make it ready as our Web Reference project.
2) Open our Window-based client project, WinClientFaculty _ UpdtDelt, and expand the Web Service References node under our current project.
3) Right-click on our Web service, WebServiceFaculty, and choose the Delete item to remove this old Web reference.
4) Right-click on our Window-based client project, WinClientFaculty _ UpdtDelt, and select the New > Web Service Client item to open the New Web Service Client wizard.
5) In the opened wizard, click on the Browse button next to the Project field and expand our Web application, WebAppFaculty. Then choose our Web service, WebServiceFaculty, by clicking on it, and click on the OK button.
6) Click on the Finish button to complete the Web service reference refreshing process.
Now that we have refreshed the Web service reference for our Window-based client project, WinClientFaculty _ UpdtDelt, next let’s develop the code in our client project to call the Web service operations UpdateFaculty() and DeleteFaculty() to perform faculty data update and delete actions. First let’s concentrate on the data update action.