Creating a Web service using the Bean2WebService tool

You can use the Bean2WebService tool from a command line to generate a Web service from a Java bean using the IBM WebSphere run-time environment.

Bean2WebService tool reference
You can use the Bean2WebService tool from a command line to generate a Web service from a Java bean using the IBM WebSphere run-time environment.

Java2WSDL tool reference
The Java2WSDL tool maps a Java class to a WSDL document.

 

Parent topic

Creating a Web service with command line tools

Command line setup

Before using the Bean2WebService tool, set up the Web services command line as follows:

  1. From a command prompt, change to Rational Developer products' bin directory. If you are not sure that you are in the correct directory, this directory should contain several Web service batch files.

  2. Run the following batch script:

    • Windows: setupenv.bat

    • Linux: . setupenv.sh

  3. Change to the directory where you want to create your 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 Bean2WebService tool to create a Web service.

Creating a Web service

Note: There are two versions of the Bean2WebService tool. If you run the Bean2WebService command, the command will use J2EE 1.4. Alternately you can use the Bean2WebService13 command which will use J2EE 1.3. For any of the commands below you can substitute Bean2WebService13 instead of Bean2WebService if you want to create a Web service that uses J2EE 1.3.

To create a Web service with the Bean2WebService tool, enter the following in the command prompt:

  • Windows: Bean2WebService [<optional arguments>] -cp <Classpath> -project <ProjectName> <BeanName>

  • Linux: Bean2WebService.sh [<optional arguments>] -cp <Classpath> -project <ProjectName> <BeanName>

Note: <BeanName> must be the final argument. See The Bean2WebService tool for a list of mandatory and optional 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 Bean2WebService tool:

Bean2WebService -host localhost:9080 -cp c:\Working\src -project MyBean
com.ibm.wsdk.MyBean

The main output of the Bean2WebService tool is a file called <ProjectName>EAR.ear in the root of the generated directory structure. The WEB-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.

Related Tasks
Creating a Web service with command line tools
Testing a Web service generated by the command line

Related Reference
Bean2WebService tool reference
Java2WSDL tool reference