O'Reilly logo

Java SOA Cookbook by Eben Hewitt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 deployment 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 following 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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required