Chapter 3 Service Endpoint Design
How do these two approaches compare? Starting with Java interfaces and
creating a WSDL document is probably the easier of the two approaches. With
this approach, you need not know any WSDL details because you use vendor
provided tools to create the WSDL description. While these tools make it easy for
you to generate WSDL files from Java interfaces, you do lose some control over
the WSDL file creation.
With the Java to WSDL approach, keep in mind that the exposed service in
terface may be too unstable from a service evolution point of view.
With the Java to WSDL approach, it may be hard to evolve the service inter
face without forcing a change in the corresponding WSDL document, and chang
ing the WSDL might require rewriting the service's clients. These changes, and
the accompanying instability, can affect the interoperability of the service itself.
Since achieving interoperability is a prime reason to use Web services, the insta
bility of the Java to WSDL approach is a major drawback. Also, keep in mind that
different tools may use different interpretations for certain Java types (for exam
might be interpreted as
), resulting in
different representations in the WSDL file. While not common, these representa
tion variations may result in some semantic surprises.
On the other hand, the WSDL to Java approach gives you a powerful way to
expose a stable service interface that you can evolve with relative ease. Not only
does it give you greater design flexibility, the WSDL to Java approach also pro
vides an ideal way for you to finalize all service details from method call types
and fault types to the schemas representing exchanged business documents
before you even start a service or client implementation. Although a good knowl
edge of WSDL and the WS I Basic Profile is required to properly describe these
Web services details, using available tools helps address these issues.
After you decide on the approach to take, you must still resolve other interface
design details, which are described in the next sections.
Choice of the Interface Endpoint Type
In the J2EE platform, you have two choices for implementing the Web service inter
face you can use a JAX RPC service endpoint (also referred to as a Web tier end
point) or an EJB service endpoint (also referred to as an EJB tier endpoint). Using
one of these endpoint types makes it possible to embed the endpoint in the same tier
as the service implementation. This simplifies the service implementation, because