Developing JAX-WS web services with WSDL files (top down)

When starting with an existing Web Services Description Language (WSDL) file, you can use a top-down approach to developing web services based on the Java™ API for XML-Based Web Services (JAX-WS) programming model.

Before you begin

Best practices: IBM® WebSphere® Application Server supports the Java API for XML-Based Web Services (JAX-WS) programming model and the Java API for XML-based RPC (JAX-RPC) programming model. JAX-WS is a web services programming model that extends the foundation provided by the JAX-RPC programming model. The JAX-WS programming model simplifies development of web services and clients through support of a standards-based annotations model. Although the JAX-RPC programming model and applications are still supported, take advantage of the easy-to-implement JAX-WS programming model to develop new web services applications and clients.

Locate the WSDL file that defines the web service that you want to implement. You can develop a WSDL file or obtain one from an existing web service through email, downloading or a Uniform Resource Locator (URL).

About this task

To develop web services based on the JAX-WS programming model, you can use a bottom-up development approach starting from existing JavaBeans or enterprise beans or you can use a top-down development approach starting with an existing Web Services Description Language (WSDL) file. This task describes the steps when using the top-down development approach.

Considerations when using JavaBeans
  • JavaBeans exposed as JAX-WS web services are supported only over an HTTP transport.
  • JavaBeans may use Contexts and Dependency Injection (CDI). Note that constructor injection is not supported.
Considerations when using enterprise beans
  • The enterprise bean must be a stateless or singleton session bean.
  • Enterprise beans that are exposed as JAX-WS web services must be packaged in EJB 3.0 or higher modules.
  • JAX-WS web service applications containing enterprise beans must be deployed with the endptEnabler command.
  • JAX-WS web services using enterprise beans are supported over an HTTP or Java Message Service (JMS) transport.
  • Enterprise beans may use CDI. Note that constructor injection is not supported.

Procedure

  1. Set up a development environment for web services.
    You do not have to set up a development environment if you are using Rational® Application Developer.
  2. Develop Java artifacts for JAX-WS applications using the wsimport command-line tool.
    The wsimport tool processes a WSDL file and generates portable Java artifacts that are used to create a web service.
  3. (optional) Enable MTOM for JAX-WS web services.
    You can use SOAP Message Transmission Optimization Mechanism (MTOM) to optimize the transmission of binary attachments such as images or files along with web services requests.
  4. (optional) Enforce adherence to WSDL bindings in JAX-WS web services.
    You can use the RespectBindingFeature to control whether a JAX-WS implementation is required to respect the contents of a wsdl:binding that is associated with an endpoint.
  5. (optional) Develop and configure a webservices.xml deployment descriptor for JAX-WS applications.
    You can optionally use the webservices.xml deployment descriptor to augment or override application metadata specified in annotations within your JAX-WS web services.
  6. Complete the implementation of your web service application.
  7. (Optional) Customize URL patterns in the web.xml file.
    When JavaBeans are exposed as JAX-WS endpoints, you can optionally customize the URL patterns within the web.xml deployment descriptor contained in the web application archive (WAR) file.
  8. Assemble the artifacts for your web service.
  9. Deploy the EAR file into the application server.
    You can now deploy the EAR file that has been configured and enabled for web services onto the application server.
  10. Test the web service to make sure that the service works with the application server.

Results

You have created a JAX-WS web service by starting with an existing WSDL file.