9.10 BUILD A WEB-BASED CLIENT PROJECT TO CONSUME THE WEB SERVICE
We can still use the Web-based client project we built in Section 9.7, WebClientFaculty _ Select, to consume our Web service to perform the faculty data insertion action. But we prefer to modify that project and make it our new Web-based client project WebClientFaculty _ Insert. Let’s copy that project and make it our new project. Perform the following steps to create our new project, WebClientFaculty _ Insert:
1) In the Projects window, right-click on the project WebClientFaculty _ Select and select the Copy item from the popup menu to open the Copy Project wizard.
2) Enter our new project name, WebClientFaculty _ Insert, into the Project Name box; browse to the default project folder, C:\Class DB Projects\Chapter 9, as the Project Location; and click on the Copy button.
A new project, WebClientFaculty _ Insert, is generated and added into our Projects window.
First let’s add a Web service reference to our Web-based client project to allow it to use our Web service operations.
9.10.1 Refresh the Web Service Reference for Our Web-Based Client Project
In order to call the InsertFaculty() operation in our Web service project, WebAppFaculty, we need to refresh the Web reference in our Web-based client project, WebClientFaculty _ Insert, 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.
2) Open our Web-based client project, WebClientFaculty _ Insert, and expand the Web Service References node.
3) Right-click on our Web service, WebServiceFaculty, and choose the Delete item to remove this old Web reference.
4) Right-click on our Web-based client project, WebClientFaculty _ Insert, 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 project, 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 or updated the Web service reference for our Web-based client proj-ect, WebClientFaculty _ Insert, next let’s develop the code in our client project to call the Web service operation InsertFaculty() to perform faculty data insertion.