Book Image

Java EE 7 Development with NetBeans 8

By : David R Heffelfinger
5 (1)
Book Image

Java EE 7 Development with NetBeans 8

5 (1)
By: David R Heffelfinger

Overview of this book

Table of Contents (18 chapters)
Java EE 7 Development with NetBeans 8
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a simple web service


In this section, we will develop a web service that performs a conversion of units of length. Our web service will have an operation that will convert inches to centimeters and another operation to do the opposite conversion (centimeters to inches).

In order to create a web service, we need to create a new web application project; in our example, the project name is UnitConversion. We can create the web service by right-clicking on our project, going to File | New File, then selecting the Web Services category, and finally selecting Web Service as our file type.

After clicking on Next, we need to enter a name and package for our web service in the following window:

After clicking on Finish, our web service is created. The source code for our web service is automatically opened, as shown in the following screenshot:

As you can see, NetBeans automatically generates a simple "Hello World" web service. The class-level @WebService annotation marks our class as a web...