Assembling a web services-enabled client JAR file into an EAR file
Now that we have generated the application artifacts, we need to assemble these artifacts to create an enterprise archive (EAR) file used in the web services application.
For JAX-WS web service applications, we need the portable artifacts generated by the wsimport command-line tool when starting from a WSDL file to complete this task. The wsimport tool processes a WSDL file as input and generates the following portable artifacts:
- Service Endpoint Interface (SEI)
- Service class
- Exception classes that are mapped from the wsdl:fault class (if any)
- Java Architecture for XML Binding (JAXB) generated type values which are Java classes mapped from XML schema types
- An assembled client module containing the implementation, all of the classes generated by the wsimport command-line tool and the ejb-jar.xml deployment descriptor or the application-client.xml deployment descriptor. This module can be:
- An application client module containing the META-INF/application-client.xml file.
- An EJB module containing the META-INF/ejb-jar.xml file.
For JAX-RPC web service applications, we need the following artifacts that are generated from the WSDL2Java command-line tool to complete this task:
- An assembled client module containing the implementation, all of the classes generated by the WSDL2Java command-line tool and the ejb-jar.xml deployment descriptor or the application-client.xml deployment descriptor. This module can be:
- An application client module containing the META-INF/application-client.xml file.
- An EJB module containing the META-INF/ejb-jar.xml file.
- The WSDL file that we used to develop the client.
- The templates for the ibm-webservicesclient-ext.xmi and ibm-webservicesclient-bnd.xmi deployment descriptor, if used.
- A generated Java API for XML-based remote procedure call (JAX-RPC) mapping deployment descriptor.
Restriction: Do not include a pound sign (#) in the name of files that are packaged within an application archive. Due to internal processing, the application server fails to correctly deploy the application when a pound sign is included in a file name within the application archive. When this failure occurs, an exception might occur when the application is being processed. Also, parts of the application might be missing after the application is deployed. To address this issue, rename any file names within the application archive so that they do not contain a pound sign.
Use assembly tools included with WebSphere Application Server to assemble web services-enabled client applications.
Assemble the client code and artifacts that enable the application client to access a web service with steps provided:
Tasks
- Start an assembly tool. Read about starting the assembly tool in the Rational Application Developer documentation.
- If we have not done so already, configure the assembly tool so that it works on Java EE modules. We need to make sure that the Java EE and Web categories are enabled. Read about configuring the assembly tool in the Rational Application Developer documentation.
- Import the client implementation and the artifacts generated by the command-line tooling into the assembly tool.
- Migrate JAR files created with the Rational Application Developer assembly tool. To migrate files, import your JAR files to the assembly tool. Read about migrating code artifacts to an assembly tool in the Rational Application Developer documentation.
- Assemble the JAR file into an EAR file using typical assembly techniques if the client runs in a container.
We have assembled the artifacts required to enable the client application for web services into an EAR file.
Example
This example of the assembly process uses the AddressBookClient.jar JAR file the AddressBookClient.ear EAR file:
META-INF/MANIFEST.MF ETA-INF/application-client.xml ETA-INF/wsdl/AddressBook.wsdl ETA-INF/AddressBook_mapping.xml com/ibm/websphere/samples/webservices/addr/Address.class com/ibm/websphere/samples/webservices/addr/AddressBook.class com/ibm/websphere/samples/webservices/addr/AddressBookClient.class com/ibm/websphere/samples/webservices/addr/AddressBookService.class ...other generated classes...After assembling the AddressBookClient.jar file into the AddressBookClient.ear file, the AddressBookClient.ear file contains the following files:
META-INF/MANIFEST.MF AddressBookClient.jar ETA-INF/application.xml
What to do next
For JAX-WS applications, we are ready to deploy the web services client application.
For JAX-RPC applications, we need to configure the client deployment descriptor bindings with an assembly tool so that the client can communicate with a web service that is deployed on a server.
Related:
Web services Development and assembly tools Testing web services-enabled clients Task overview: Implementing web services applications Implement static JAX-WS web services clients Implement JAX-RPC web services clients Deploy web services client applications Configure the JAX-RPC web services client deployment descriptor with an assembly tool Artifacts used to develop web services wsimport command for JAX-WS applications WSDL2Java command for JAX-RPC applications