Add a Web Service Reference to Our Web-Based Client Project – Develop Java Web Services to Access Databases

9.7.4  Add a Web Service Reference to Our Web-Based Client Project

Perform the following operations to set up a Web service reference for our client project:

1) Build and deploy our Web Service application project WebAppFaculty built in section 9.5.

2) Right-click on our client project WebClientFaculty _ Select in the Projects window, and select the New > Other item to open the New File wizard.

3) 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.
4) Click on the Browse button for the Project field and expand our Web application project WebAppFaculty, and click on our Web service project WebServiceFaculty to select it. Then click on the OK button to select this Web service. Your finished Web Service Client wizard is shown in Figure 9.40. Click on the Finish button to complete this process.

FIGURE 9.39   The second part of the code for the Java Bean class file.

FIGURE 9.40   The finished New Web Service Client wizard.

Immediately you can see a new node named Web Service References has been created and added into our client project. Expand this node, and you can see the associated Web service port and our Web service operations, QueryFaculty() and QueryImage(), under that node.

Before we can build and run our Web client project to consume our Web Service, the last job we need to do is to set up the startup page, Faculty.jsp, to enable the Java Runner to know the start-ing point. Perform the following operations to complete this job:

1) Right-click on our client project, WebClientFaculty _ Select, in the Projects window, and select the Properties item at the bottom line from the popup menu to open that wizard.
2) In the opened wizard, click on the Run node.
3) Enter ./Faculty.jsp into the Relative URL box on the right to make it our start page.

4) Click on the OK button to complete this process.

Now we are ready to build and run our client project to test its function. However before we can do that, make sure that our Web Service project WebAppFaculty has been built and deployed successfully.