This topic explains how to assemble a Web archive (WAR) file that
is enabled for Web services from Java code with an assembly tool.
Before you begin
You can assemble Java-based Web services modules with assembly tools provided with WebSphere Application Server.
You must configure
the assembly tool before you can 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.
About this task
Assemble a Web services-enabled WAR file from Java code by following
the actions in the steps for this task section.
Procedure
- Start
an assembly tool. The Eclipse assembly tools provide a graphical
interface for developing code artifacts, assembling the code artifacts into
various archives or modules and configuring related J2EE Version 1.2, 1.3
or 1.4 compliant deployment descriptors.
- If
you have not done so already, configure the assembly tool for work
on J2EE modules. Ensure that J2EE and Web capabilities are
enabled.
- Click File > Import to import
the WAR file into the assembly tool.
- Open the J2EE perspective by clicking Windows >Open
Perspective > Other > J2EE.
- Switch to the Navigator pane by clicking the Navigator tab.
- Locate the project for the WAR file you just
imported in the Navigator pane.
- Expand the WebContent directory so
that the WEB-INF directory is displayed. Expand the WEB-INF directory.
- 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:
- Double-click Web Deployment Descriptor.
- In the Web Deployment Descriptor editor, click the Servlets tab
at the bottom of the editor window.
- Enter the full path name of the Java bean class that implements
the Web service in the Servlet class field.
- Close the editor window to save your changes.
- Right-click the WEB-INF directory
and click New > Folder. Create a subfolder named wsdl in
the WEB-INF directory.
- 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.
- Copy the JAX-RPC mapping file, as specified
by the <jaxrpc-mapping-file> element of the webservices.xml file.
- Copy webservices.xml,ibm-webservices-bnd.xmi and ibm-webservices-ext.xmi files
into the WEB-INF subdirectory in the same manner.
- 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.
Results
The artifacts required to enable the Web module for Web services are
added to the WAR file.