Java Reference
In-Depth Information
When using the SOAP protocol, web service operations are defined in an XML
document called a Web Services Definition Language ( WSDL ) file. After creating
the WSDL, implementation of web services is done in a proper programming
language such as Java. The process of creating a WSDL is complex and error
prone. Fortunately, when working with Java EE 5, a WSDL can be automatically
generated from a web service written in Java when this web service is deployed to
the application server. Additionally, if we have a WSDL file available, and need to
implement the web service operations in Java, NetBeans can automatically generate
most of the Java code for the implementation, creating a class with method stubs for
each web service operation. All we need to do is implement the actual logic for each
method; all the "plumbing" code is automatically generated.
Building web services using the REST protocol, sometimes referred to as RESTful
web services, is simpler to using the traditional SOAP protocol. When developing
RESTful web services, all that is done is the exchange of messaging through the
HTTP protocol in any format we wish to use, such as HTML, XML, or JSON.
Creating a Simple Web Service
In this section, we will develop a web service that performs 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 it and selecting New | Web Service... . In the resulting wizard, we
need to enter a name and package for our web service.
 
Search WWH ::




Custom Search