Deploy and Test the Web Service on the Selected Container – Develop Java Web Services to Access Databases

9.3.4  Deploy and Test the Web Service on the Selected Container

The NetBeans IDE provides a server test client to help us test our Web service after it has been successfully deployed. Perform the following operations to deploy our Web service to our Web container, GlassFish:

1) Click on the Clean and Build Main Project button on the top to build our proj-ect. Then right-click on our project, WSTestApp, in the Projects window and choose

FIGURE 9.9  The finished Add Operation dialog.

FIGURE 9.10  The opened visual designer.

the Deploy item. The NetBeans IDE will start the application server, build the applica-tion and deploy the application to the server. You can follow the progress of these opera-tions in the WSTestApp (run-deploy) and the GlassFish server in the Output window.

2) If everything is fine, a successful deploy result should be obtained and displayed in the Output window, as shown in Figure 9.12.

We can use the GlassFish Test Service client to test our service to confirm its function. To test our Web service, perform the following operations:

1) In the opened Projects window, expand the Web Services node under our project; right-click on our target Web service output file, WSTest; and choose the Test Web Service item.

FIGURE 9.11  The code created for the new added operation.

FIGURE 9.12  The deployment result.

2) The NetBeans IDE will display a test page in your browser, which is shown in Figure 9.13, if everything is fine.

To test our Web service project, enter 6 and 3 in the two input boxes, and click on the add but-ton. You can see that a successful run result of our Web service is displayed with an addition result
of 9, which is shown in Figure 9.14.
If you encounter a WS00041 Service Exception, refer to Appendix K to solve it.

One point to be noted is that if you are using the Tomcat Web server as your application server, you will not find this tester page; only a testing successful page is displayed without any page test

FIGURE 9.13  The Web Service testing page.

FIGURE 9.14  The Web Service test result.

function available. Also, if you are deploying a Web service built with the EJB module, you cannot find a test page either, since the NetBeans IDE 12.0 does not support a test function for any EJB module.

Next let’s build a Web service-consuming project to consume our Web service.

Related Posts

Leave a Reply

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