Java Reference
In-Depth Information
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 us-
ing 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 ser-
vices 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.
This chapter assumes that you're familiar with web services, so in-depth coverage of web
service development isn't provided. Entire topics have been devoted to this subject and it
would be impossible to replicate those efforts within the span of a single chapter. For an in-
troduction and deep-dive coverage of REST and SOAP, consult Restlet in Action by Jerome
Louvel (Manning, 2012) and SOA Patterns by Arnon Rotem-Gal-Oz (Manning, 2012). In
this chapter we'll start off by reviewing the basics of web services—both SOAP and REST.
We'll then tie this understanding back in to Enterprise Java and specifically to stateless
EJBs. Along the way, we'll put web services to use in ActionBazaar and discuss best prac-
tices for using web services effectively.
Search WWH ::




Custom Search