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 the development environment or the WebSphere Administrative Console. To deploy the EAR file and test the Web service using the development environment, 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:

  1. Open a workspace.
  2. Go to File > Import > EAR file, and click Next.
  3. Click Browse to select the command line test directory from which you ran the Web services command line tool. Click Open.
  4. 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.
  5. 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 or later, 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.
  6. 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, you must 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 Prepare for Deployment 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

If you already have a serve created, go to step 4. Alternately you can create a server manually. To create and configure the server to deploy the Web service: 

  1. Select File > New > Other. Select Server and Server from the lists. Click Next.
  2. Specify the host name of the server you want to publish on, or accept the default localhost setting. Select the type of server you want to create and click Next.
  3. Select the port you want to use, and accept the other default settings. Click Finish.
  4. Switch to the Servers view (Window > Show view> Other > Servers).
  5. In the Server Configuration pane, right-click your server. Select Add and Remove projects. Select your Web service EAR and add it to the server. Click Finish.

Once you have deployed your Web service to the server, you can test it.


Feedback