Assembling a WAR file that is enabled for Web services from Java code

This topic explains how to assemble a WAR file that is enabled for Web services from Java code with an assembly tool.

 

Before you begin

We can assemble Web Services for J2EE modules with assembly tools provided with WebSphere Application Server.

You must configure the assembly tool before use it. You need the following artifacts that are generated by the WSDL2Java command-line tool to complete this task:

  • An assembled WAR file that contains the web.xml file, but is not enabled for Web services.

  • The Java class for the service endpoint interface

  • A Web Services Description Language (WSDL) file

  • The complete webservices.xml,ibm-webservices-bnd.xmi, and ibm-webservices-ext.xmi deployment descriptors, and the Java API for XML-based remote procedure call (JAX-RPC) mapping file classes that are generated by the WSDL2Java command.

 

Overview

Assemble a Web services-enabled WAR file from Java code by following the actions in the steps for this task section.

 

Procedure

  1. Start an assembly tool. The assembly tools, Application Server Toolkit (AST) and Rational Web Developer, provide a graphical interface for developing code artifacts, assembling the code artifacts into various archives (modules) and configuring related J2EE V1.2, 1.3 or 1.4 compliant deployment descriptors.

  2. Click File > Import to import the WAR file into the assembly tool.

  3. Open the J2EE perspective by clicking Windows >Open Perspective > Other > J2EE.

  4. Switch to the Navigator pane by clicking the Navigator tab.

  5. Locate the project for the WAR file you just imported in the Navigator pane.

  6. Expand the WebContent directory so that the WEB-INF directory is displayed. Expand the WEB-INF directory.

  7. Confirm that the WEB-INF/web.xml deployment descriptor for the Web module contains a <servlet-class> element that indicates the Java bean class that is implementing the service:

    1. Double-click Web Deployment Descriptor.

    2. In the Web Deployment Descriptor editor, click the Servlets tab at the bottom of the editor window.

    3. Enter the full path name of the Java bean class that implements the Web service in the Servlet class field.

    4. Close the editor window to save your changes.

  8. Right-click the WEB-INF directory and click New > Folder. Create a subfolder named wsdl in the WEB-INF directory.

  9. Copy the WSDL file to the WEB-INF\wsdl directory by right-clicking the wsdl directory and click Import > File system. Browse the WSDL file for this Web service and click Finish.

  10. Copy the JAX-RPC mapping file, as specified by the <jaxrpc-mapping-file> element of the webservices.xml file.

  11. Copy webservices.xml,ibm-webservices-bnd.xmi and ibm-webservices-ext.xmi files into the WEB-INF subdirectory in the same manner.

  12. Import the service endpoint interface class so that the service endpoint interface package begins in the JavaSource directory. When you import the source file, it is automatically compiled.

 

Result

The artifacts required to enable the Web module for Web services are added to the WAR file.

 

What to do next

Now one can assemble the WAR file that is enabled for Web services into an EAR file.


 

Related Tasks


Assembling a Web services-enabled WAR into an EAR file
Assembling a Web services-enabled WAR file from a WSDL file