Creating a Web service using the EJB2WebService tool
You can use the EJB2WebService tool from a command line to generate a Web service from an EJB bean using the IBM WebSphere run-time environment. Note: The EJB2WebService13 command supports EJB v2.0 and J2EE 1.3, while the EJB2WebService command supports EJB 2.1 and J2EE 1.4.
EJB2WebService tool reference
You can use the EJB2WebService tool from a command line to generate a Web service from an EJB bean using the IBM WebSphere run-time environment. The EJB2WebService13 command supports EJB v2.0 and J2EE 1.3, while the EJB2WebService command supports EJB 2.1 and J2EE 1.4.
Parent topic
Creating a Web service with command line tools
Command line setup
Before using the EJB2WebService tool, set up the Web services command line as follows:
- From a command prompt, change to Rational Developer products' bin directory.
- Run the following batch script:
- Windows:
setupenv.bat
- Linux:
. setupenv.sh
- Change to the directory where you want to create the Web service. We will refer to this directory as the command line test directory. Linux: You must have write-access to this directory.
Now, you can use the EJB2WebService tool to create a Web service with an exported EAR file.
Creating a Web service
Note: There are two versions of the EJB2WebService tool. If you run the EJB2WebService command, the command will use J2EE 1.4. Alternately you can use the EJB2WebService13 command which will use J2EE 1.3. For any of the commands below you can substitute EJB2WebService13 instead of EJB2WebService if you want to create a Web service that uses J2EE 1.3.
To create a Web service using the EJB2WebService tool, enter the following in the command prompt:
- Windows: EJB2WebService [<optional arguments>] -project <ProjectName> -ri <RemoteInterface> <EJB.ear>
- Linux: EJB2WebService.sh [<optional arguments>] -project <ProjectName> -ri <RemoteInterface> <EJB.ear>
Note: <EJB.ear> must be the final argument. See The EJB2WebService tool for a list of optional and mandatory arguments.
Hints:
- It is recommended that you specify the optional argument: -host <hostname:port>. The default port for the command is 6080, but the default WebSphere Application Server port is 9080.
- Note the command line test directory path and the name that you specify for -project. You will need this information to deploy and test your Web service.
Example
This is an example of how to use the EJB2WebService tool:
EJB2WebService -host localhost:9080 -ri MyEJB.remoteInterface -project MyEJBProject MyEJB.earThe main output of the EJB2WebService tool is a modified version of the original EAR file called <ProjectName>EAR.ear in the root of the generated directory structure. The META-INF directory is also generated under <ProjectName>. This directory holds the generated WSDL file, Java classes, and so on. If you do not specify the -server-side-only argument, a client-side directory that contains some extra Java files, including serializer and deserializer classes for your complex types, will also be created.
Once you have generated an EAR file, you can deploy it to a server to make it available to others.
Important: If you select to use the -splitWsdl argument the EAR file will be generated but an exception will occur during server start-up once it is imported to the workspace and deployed to the Unit Test Environment or a remote server. This exception is caused by a missing WSDL in the router Web project. To counteract this error do any of the following:
- Deploy to a stand-alone WebSphere Application Server using the Admin Console.
- Use a monolithic WSDL - that is, do not use the -splitWsdl argument.
- Manually copy all WSDL files under the META-INF/wsdl directory in the EJB project to the WEB-INF/wsdl of the router Web project.
Related Tasks
Creating a Web service with command line tools
Deploying a Web service to a server using the command line tools
Testing a Web service generated by the command lineRelated Reference
EJB2WebService tool reference