Java Reference
In-Depth Information
ferent than exposing an EJB via RMI—you use @WebService instead of @Remote . A
stateless/singleton bean can be exposed both as a web service and also via RMI. Exposing
core business logic has never been easier.
Table 8.1 compares EJB-backed web services versus POJO web services. There are some
distinct advantages to EJB web services versus POJO web services.
Table 8.1. Feature comparison of Java web services to EJB web services
Feature
POJO web service
EJB web service
POJO
Yes
Yes
Dependency injection including re-
sources, persistence units, and so on
Yes
Yes
Lifecycle methods
Yes
Yes
Declarative transactions
No
Yes
Declarative security
No
Yes
Now that we've reviewed the basics of SOAP web services and also discussed where
they're appropriate, let's take a look at how ActionBazaar uses web services.
8.2.4. SOAP web service for ActionBazaar
Let's dive into two EJB 3 examples demonstrating how EJBs can be exposed as web ser-
vices. We'll use two different examples to demonstrate the combination of EJB 3 and JAX-
WS. The first example will provide a simple introduction with the container automatically
generating the WSDL. In the second example, we'll show you how to write the WSDL as
well as the JAXB schema file, generate JAXB beans, and write code that implements the
WSDL. You can use these examples as a starting point for further exploration. The second
one will definitely be useful as you dig deeper.
PlaceBid service
In the first example you'll expose the PlaceBid bean as a web service. This will enable
clients written in other languages to submit bits. This EJB will be exposed as an RPC-
encoded SOAP web service. The WSDL will be automatically generated by the JAX-RS
runtime.
 
Search WWH ::




Custom Search