Blog / BUILD A WEB-BASED CLIENT PROJECT TO CONSUME THE WEB SERVICE – Develop Java Web Services to Access Databases

BUILD A WEB-BASED CLIENT PROJECT TO CONSUME THE WEB SERVICE – Develop Java Web Services to Access Databases

BUILD A WEB-BASED CLIENT PROJECT TO CONSUME THE WEB SERVICE – Develop Java Web Services to Access Databases


9.13  BUILD A WEB-BASED CLIENT PROJECT TO CONSUME THE WEB SERVICE

We can still use the Web-based client project WebClientFaculty _ Insert we built in Section 9.10 to consume our Web service to perform the faculty data updating and delete action. But we prefer to modify that project and make it our new Web-based client project, WebClientFaculty _ UpdtDelt. Let’s copy that project and change it to our new project. Perform the following steps to create our new project, WebClientFaculty _ UpdtDelt:

1) In the Projects window, right-click on the project WebClientFaculty _ Insert and select the Copy item from the popup menu to open the Copy Project wizard.

2) Enter our new project name, WebClientFaculty _ UpdtDelt, 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 _ UpdtDelt, is generated and added into our Projects window. Some errors may be involved in our Java Bean class, FacultyMBean. java, and this is due to the updated Web Service we built by adding two new operations, UpdateFaculty() and DeleteFaculty(). To solve this error, we need to update or refresh our Web Reference in our new project.

Now let’s modify the Web service reference to our Web-based client project to allow it to use our updated Web service operations.

9.13.1  Refresh the Web Service Reference for Our Web-Based Client Project

Perform the following operations to refresh the Web service reference:

1) Build and deploy our Web Service project, WebAppFaculty, first to make it ready.
2) Expand the folder Web Service References under our new project, right-click on the WebServiceFaculty and select the Delete item to remove this old reference.

3) Right-click on our Web-based client project, WebClientFaculty _ UpdtDelt, and select the New > Web Service Client item to open the New Web Service Client wizard.
4) 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 class, WebServiceFaculty, by clicking on it, and click on the OK button.

5) Click on the Finish button to complete the adding Web service reference process.

Now build our new project, and the related error should have disappeared.

At this point, we have refreshed our Web service reference to our Web-based client project, WebClientFaculty _ 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. The main code is inside the Java Bean class file, FacultyMBean.java.

First let’s take care of the data update operation UpdateFaculty().

Angela Gaffney

  • 0

Leave a Reply

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


                Copyright © 2024 Saucierlight.com. All Rights Reserved.