INTRODUCTION TO JAVA WEB SERVICES – Develop Java Web Services to Access Databases

9.1   INTRODUCTION TO JAVA WEB SERVICES

Web services are distributed application components that are externally useful and available. You can use them to integrate computer applications that are written in different languages and run on different platforms. Web services are language and platform independent because vendors have agreed on common Web service standards.

Essentially, Web Services can be considered a set of methods installed on a Web server that can be called by computer programs installed on clients through the Internet. Those methods can be used to locate and return the target information required by computer programs. Web Services do not require the use of browsers or HTML, and therefore Web Services are sometimes called appli-cation services.

A complete Web services stack, Metro, developed by Sun Microsystems, covers all of a devel-oper’s needs from simple Java Web services demonstrations to reliable, secure and transacted web services. Metro includes Web Services Interoperability Technologies (WSIT). WSIT supports

enterprise features such as security, reliability and message optimization. WSIT ensures that Metro services with these features are interoperable with Microsoft. NET services. Within Metro, Project Tango develops and evolves the codebase for WSIT.

Several programming models are available to Web service developers. These models can be categorized into two groups, and both are supported by the NetBeans IDE:

  • REST-based:RE presentational State Transfer is a new way to create and communicate with Web services. In REST, resources have uniform resource identifiers (URIs) and are manipulated through HTTP header operations.
  • SOAP/WSDL-based: In traditional Web service models, Web service interfaces are exposed through WSDL documents (a type of XML), which have URLs. Subsequent mes-sage exchange is in SOAP, another type of XML document.

Let’s have a little more discussion of these two kinds of Web services.

9.1.1   REST-Based Web Services

REST-based or RESTful Web services are collections of Web resources identified by URIs. Every document and process is modeled as a Web resource with a unique URI. These Web resources are manipulated by the actions that can be specified in an HTTP header. Neither SOAP, WSDL nor WS-* standards are used. Instead, message exchange can be conducted in any format—XML, JavaScript Object Notation (JSON), HTML and so on. In many cases, a Web browser can serve as the client.

HTTP is the protocol in REST. Only four methods are available: GET, PUT, POST and DELETE. Requests can be bookmarked and responses can be cached. A network administrator can easily fol-low what is going on with a RESTful service just by looking at the HTTP headers.

REST is a suiTable technology for applications that do not require security beyond what is avail-able in the HTTP infrastructure and where HTTP is the appropriate protocol. REST services can still deliver sophisticated functionality. NetBeans IDE Software as a Service (SaaS) functionality lets you use Facebook, Zillow and other third-party-provided services in your own applications.

Project Jersey is the open-source reference implementation for building RESTful Web services.

The Jersey APIs are available as the RESTful Web Services plug-in for NetBeans IDE.

RESTful Web services are services built using the RESTful architectural style. Building Web services using the RESTful approach is emerging as a popular alternative to using SOAP-based technologies for deploying services on the internet, due to its lightweight nature and the ability to transmit data directly over HTTP.

The NetBeans IDE supports rapid development of RESTful Web services using Java Specification Requests (JSR 311), a Java API for RESTful Web Services (JAX-RS) and Jersey, the reference implementation for JAX-RS.

In addition to building RESTful Web services, the NetBeans IDE also supports testing, build-ing client applications that access RESTful Web services and generating code for invoking Web services (both RESTful and SOAP-based.)

Here is the list of RESTful features provided by the NetBeans IDE:

1) Rapid creation of RESTful Web services from JPA entity classes and patterns.

2) Rapid code generation for invoking Web services such as Google Map, Yahoo News Search and StrikeIron Web services by dragging and dropping components from the RESTful component palette.

3) Generation of JavaScript client stubs from RESTful Web services for building RESTful client applications.

4) Test client generation for testing RESTful Web services.

FIGURE 9.1   The architecture of multi-tier Web services.

5) Logical view for easy navigation of RESTful Web service implementation classes in the project.

6) Fully integrated Spring framework, providing Spring transaction handling.

A structure and architecture of using a RESTful model to build a Web service is shown in Figure 9.1.

Next let’s take a look at SOAP-based Web services.

Related Posts

Leave a Reply

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