Designing a Service's Interaction Layer
sion bean. A JAX RPC service endpoint, on the other hand, does not have a
facility for declaring method level access constraints, requiring you to do this
programmatically. See Chapter 7 for more information.
HTTP session access considerations
A JAX RPC service endpoint,
because it runs in the Web container, has complete access to an
object. Access to an
object, which can be used to embed cookies
and store client state, may help you build session aware clients. An EJB
service endpoint, which runs in the EJB container, has no such access to Web
container state. However, generally HTTP session support is appropriate for
short duration conversational interactions, whereas Web services often
represent business processes with longer durations and hence need additional
mechanisms. See Correlating Messages on page 359 for one such strategy.
Granularity of Service
Much of the design of a Web service interface involves designing the service's oper
ations, or its methods. You first determine the service's operations, then define the
method signature for each operation. That is, you define each operation's parame
ters, its return values, and any errors or exceptions it may generate.
It is important to consider the granularity of the service's operations when de
signing your Web service interface.
For those Web services that implement a business process, the nature of the
business process itself often dictates the service's granularity. Business processes
that exchange documents, such as purchase orders and invoices, by their nature
result in a Web service interface that is coarse grained. With more interactive Web
services, you need to carefully choose the granularity of these operations.
You should keep the same considerations in mind when designing the
methods for a Web service as when designing the methods of a remote enterprise
bean. This is particularly true not only regarding the impact of remote access on
performance but also with Web services; it is important with Web services
because there is an underlying XML representation requiring parsing and taking
bandwidth. Thus, a good rule is to define the Web service's interface for optimal
granularity of its operations; that is, find the right balance between coarse grained
and fine grained granularity.