Java Reference
In-Depth Information
Assembling a Service for Deployment
Problem
You are new to web services and want to assemble the pieces you need to create a deployment.
Solution
There are three options here. You can:
▪ Publish a javax.xml.ws.Endpoint . This is the simplest option because you do not need
to create a deployable artifact such as a WAR or an EAR. The Endpoint API takes care of
that for you, and makes the service available in the HTTP server built-in to Java SE 6. It
is suitable for testing, or if you want to allow the creation and publication of a service at
runtime.
▪ Write a servlet decorated with the JAX-WS annotation @WebService and publish it in a
WAR. Include a WSDL and schemas, or allow Glassfish to generate them for you at de-
ployment time according to the values in your annotations. Structure your WAR just as
you would to deploy a regular web application. You must include all of the regular WAR
descriptors such as web.xml.
▪ Write a stateless session EJB decorated with the JAX-WS annotation @WebService and
publish it in an EAR. Structure your EAR just as you would to deploy a regular enterprise
application.
Discussion
There are some options within each of these three basic choices as well, discussed in the fol-
lowing sections.
Web service or provider
You can use the SAAJ @Provider annotation on your service instead of the @WebService
annotation. This gives you the ability to examine incoming and outgoing messages at the raw
XML level, and in this way Provider is the counterpart to Dispatch on the client.
Interfaces
It is good form to write an interface for your stateless session EJB, and it makes your EJB ac-
cessible as a resource from other enterprise resources. For example, your EJB must implement
an interface if you want to invoke it with a context listener in the web tier. Strictly speaking,
Search WWH ::




Custom Search