Chapter 8. Exposing EJBs as web services

 

This chapter covers

  • The basics of web services
  • The basics of SOAP (JAX-WS)
  • Exposing EJBs as SOAP web services
  • The basics of REST (JAX-RS)
  • Exposing EJBs as RES web services

In this chapter we’re going to delve into exposing Enterprise Java Beans via web services using either SOAP or REST. Web services have become an industry standard for application-to-application (A2A) and business-to-business (B2B) integration. They’re key to developing software according to SOA principles where functionality is exposed as interoperable services that are loosely coupled.

What do web services have to do with EJB 3? You can think of web services as a way to expose your stateless session beans to clients written in both Java and other programming languages on different platforms. Web services can be thought of as an alternative method of exposing beans to remote applications that doesn’t require RMI or the use of Java. The client could thus have code written in Objective-C on an iPhone, a .NET application running on a server, or a web application written in PHP and JavaScript—the possibilities are endless. Your EJBs are your reusable business services and web services are a technology stack for abstractly defining your services and providing a generic method of invoking the services that’s language and platform-independent.

8.1. What is a web service?

8.2. Exposing EJBs using SOAP (JAX-WS)

8.3. Exposing EJBs using REST (JAX-RS)

8.4. Choosing between SOAP and REST

8.5. Summary