Deploying a Web service to a server using the command line tools
After you have created an EAR file using a Web services command line tool, you can deploy it to a server to create the code that allows your service to be available to others. You can deploy the EAR file to WebSphere Application Server using either Rational Developer products or the WebSphere Administrative Console. To deploy the EAR file and test the Web service using Rational Developer products, you will first need to import the EAR file, and then create, configure, and start the Web server.
Importing an EAR file
To import an EAR file:
- Open a workspace.
- Go to File > Import > EAR file, and click Next.
- Click Browse to select the command line test directory from which you ran the Web services command line tool. Click Open.
- Expand your project directory (specified by -project when you ran the Web services command line tool), and select the EAR file that you created. Click Open.
- In the Import EAR wizard, target the EAR to the appropriate server. J2EE 1.4 EARs must be targeted to a WebSphere Application Server v6, while a J2EE 1.3 EAR can be targeted to WebSphere Application Server v5 or v6. Accept the default settings in the next two windows. Hint: Note the name of the Web project created with the EAR file. If you are importing an EAR file containing an EJB bean, also note the name of the EJB project. You will need this information later to test your Web service. From now on, we will refer to these projects as the imported Web project and the imported EJB project.
- Click Finish.
You have now imported an EAR file and its corresponding project.
Note:
- If you used the WSDL2WebService tool or if your EAR file does not contain EJB deploy code, generate the deployment code. To generate it, switch to the J2EE Perspective (Window > Open Perspective > J2EE). In the J2EE project explorer, right-click the EJB project and select Deploy from your imported EJB project's pop-up menu.
- After you import an EAR containing an EJB Client generated by the command line tools using J2EE 1.4 into the workspace, you will see compilation errors. To fix the errors, right-click the EJB project and select Properties. Go to Java Build Path, and select the Libraries tab. Remove the EJBClientProject/imported_classes(class folder) entry. Add class folder EJBServiceClient/imported_classes/Meta-inf/classess. Click OK.
- After you import an EAR containing an Application Client generated by the command line tools using J2EE 1.4 into the workspace, you will get a ClassNotFoundException error when running the client. To fix the errors, right-click the Application Client project, select Properties. Go to Java Build Path, and select the Libraries tab. Remove the ApplicationClientProject/imported_classes(class folder) entry. Add class folder ApplicationClientProject/imported_classes/Meta-Inf/classess. Click OK.
You can now create and configure the server to deploy the Web service.
Creating and configuring the Web server
A WebSphere v6 server is created automatically when you create a workspace. If you choose to deploy to this server, go to step 4. Alternately you can create a server manually. To create and configure the server to deploy the Web service:
- Select File > New > Other. Select Server and Server and Server Configuration from the lists. Click Next.
- Type a server name. From the Server Type list, expand WebSphere version 5.1 or WebSphere version 6.0. If you want to deploy your EAR file to a Unit Test server, select Test Environment. If you want to deploy to a remote server, select Server. Click Finish.
- Switch to the Server perspective (Window > Open Perspective > Other > Server).
- In the Server Configuration pane, open the pop-up menu of the server you just created. Select Add and Remove projects.
- From the Available projects list, select the EAR file that you imported. Click Add to add it to the list of configured projects.
- Click Finish.
Once you have deployed your Web service to the server, you can test it.
Related Tasks
Creating a Web service with command line tools
Testing a Web service generated by the command line