Web Services Development: Generating Client Code

This document describes the following:

1. Generating Client Code From a WSDL File

Using OEPE, you can generate the client code for the following types of projects:
  • Web service project

  • Dynamic Web project

  • EJB project
Note that there is currently no support for generating client code in Eclipse Java projects.

To generate the client code for your Web service, do the following:

  1. Create new, or obtain an existing WSDL file for your target Web service project.
    For more information, see the following:

  2. Create another Web service project, which will be your client project.

  3. Copy the WSDL file (from step 1) located in the WebContent folder of your target Web service into the WebContent folder of your client project (from step 2).

  4. Generate the client code as follows:
    • In the Project Explorer, right-click your client project's WSDL file, and then select WebLogic Web Services > Generate Web Service Client from the drop-down menu, as Figure 1 shows. This will open the New Web Service Client dialog that Figure 2 shows.

      Figure 1.
      Create Web Service Client

      Figure 2.
      New Web Service Client Wizard - Generated Artifacts

    • On the New Web Service Client dialog, specify the service name, the output location of the generated JAR file, as well as Ant script generation options, and then click Next.
    • On the next New Web Service Client > Customization Options screen, shown in Figure 3, you may choose to specify additional options, and then click Finish.

      Figure 3.
      New Web Service Client Wizard - Customization Options

Upon completion of the preceding procedure, Eclipse does the following:

  • Creates the client JAR file in your client Web service project's WebConent/WEB-INF directory, as Figure 4 shows.

    Figure 4.
    Generated Client JAR File

  • Modifies properties of your target Web service project, as necessary (sets the project facet, classpath, and so on).

If you deploy and run both your target and client Web service projects, your generated client code will successfully call your target Web service.

Note that nondeployment-based applications, such as Java applications, may require additional manual configuration.

You can reference the client from the target Web service using the template-based code snippets.

2. Related Information

2.1 Alternative Ways to Generate the Client Code

There are alternative entry points to the client code generation wizard. Instead of right-clicking your client project's WSDL file, and then selecting WebLogic Web Services > Generate Web Service Client from the drop-down menu, shown in Figure 1, you may choose to right-click the Project Explorer area, select New > Other > WebLogic Web Services > Web Service Client, and then click Next. This will open the ClientGen Wizard > WSDL File dialog, as Figure 5 shows.

Figure 5.
New Web Service Client Wizard - WSDL File Selection

Using this dialog, select the WSDL file from which you want to generate the Web service client indicating if this file is local or remote (in this case, enter a remote URL), and then proceed with your other settings.

2.2 Deploying Java Web Service Applications to Oracle WebLogic Server

Typically, Eclipse builds your files automatically and you can deploy your application at any time. Note that in order to deploy, you must have a successful build completed.

You can start Oracle Weblogic Server in either development or production mode: in development mode, the server behaves in ways that make it easier to iteratively develop and test applications (for example, the server automatically deploys the current application in an exploded format and relaxes certain security restrictions on deployment); in production mode, WebLogic Web Service test client is not deployed. For more information, see Testing Web Services.

Application deployment consists of the following three steps:

  1. Compilation of the Web service.
  2. Publishing the files to the server.
  3. Running the application.

Usually these steps are done seamlessly, by explosion of the WAR file.

When you deploy, all open projects associated with the server are deployed. To undeploy a project or prevent it from being deployed, remove it from the server. Alternatively, you can close projects by selecting Project > Close Projects from the menu. You can also specify working sets (see Eclipse help system in the Workbench User Guide) to control how many artifacts to build and deploy.

However, even though an entire application or group of projects was deployed, only the file or folder that you clicked on to trigger the deployment will display its results. When you deploy your Web service, the test client page for that Web service will run in a new tab in the editor area - you can use it to specify the parameters to an operation and make a request to that operation. The response from the operation is displayed in the same tab. If the page flow or Web service relies on other Web services to run correctly, it will still work because all components are deployed.

To deploy your Web service application, perform one of the following:

  • Right-click your project in the Project Explorer and select Run As > Run on Server from the drop-down menu to start the server in normal mode (if it has not been started). This will deploy the application to its associated server; if the project is not associated with a server, make a server selection using the displayed dialog, and then run the application.

  • Right-click your project in the Project Explorer and select Debug As > Debug on Server from the drop-down menu to start the server in debug mode (if it is not already started), and run the application.

If you wish to simply publish your files to the server, you can use the Servers view by selecting Window > Show View > Servers from the main menu. Note that this view also lets you undeploy applications from the server.

After you deploy your application, the Servers view is displayed automatically.