Chapter 10. Web Services

In this chapter, we will cover:

  • Creating an EJB-based web service using JAX-WS
  • Creating an EJB-based web service using JAX-RS
  • Using an MDB as part of a web service

Introduction

A Web Service is an application which provides functionality for a client. Clients are typically web browsers but can also be standard applications. The communication between a client and a service is facilitated through standard protocols that connect to end-points created for the services. The term, endpoint, refers to a specific location used to access the web service.

From a Java perspective, web services can be divided into two broad categories. The first category is the Java API for XML Web Services (JAX-WS) and is based on XML and the Simple Object Access Protocol (SOAP). The capabilities of a service are published in an XML-based Web Services Description Language (WSDL). It supports message-oriented and remote procedure call type services. This approach is more complex but provides support for applications in terms of transactions, security, and other features.

The second category is Representational State Transfer )(RESTful) web services as supported by JAX-RS. This type of service is useful for simpler applications having less stringent demands placed upon them. It is good for stateless services where caching can be used to improve its performance.

The first two recipes address using JAX-WS and JAX-RS respectively. The third recipe, Using an MDB as part of a web service, examines an approach for using an MDB in support of a web service.

A Java Web Service application called CustomerApplication is used to demonstrate the creation of web services in this chapter. The application simply returns the number of customers in a given region. The session EJB CustomerManager supports this basic functionality. These classes are developed in the first recipe.

There is a lot more to web services than is covered in this chapter. The intent here is to provide examples of web services as they relates to EJBs and many of the commonly used features of web services.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.206.112