uCosminexus Application Server, Application Development Guide

[Contents][Glossary][Index][Back][Next]

8.4.1 Developing Web service client using Java applications

This subsection describes how to develop a Web Service client using Java applications.

Organization of this subsection
(1) Flow of Web Service client development using Java applications
(2) Creating a Java project
(3) Acquiring a WSDL file
(4) Generating a Java source
(5) Implementing a Web Service client
(6) Debugging Java applications

(1) Flow of Web Service client development using Java applications

The following figure shows the flow of Web Service client development using Java applications:

Figure 8-3 Flow of Web Service client development using Java applications

[Figure]

An overview of the individual operations is as follows:

  1. Creating a Java project
    Create the Java project to be used for developing a Web Service client. For details, see 8.4.1(2) Creating a Java project.
  2. Acquiring a WSDL file
    Acquire a WSDL file or acquire the URL of a released WSDL file. For details, see 8.4.1(3) Acquiring a WSDL file.
  3. Generating a Java source
    Generate the Java source for implementing the Web Service client. For details, see 8.4.1(4) Generating a Java source.
  4. Implementing a Web Service client
    Use the generated Java source to implement the Web Service client. For details, see 8.4.1(5) Implementing a Web Service client.
  5. Debugging Java applications
    You debug the Java applications. For details, see 8.4.1(6) Debugging Java applications.

The following subsections describe the development of Web Service client using Java applications, according to the above flow.

(2) Creating a Java project

Create a Java project to be used for developing a Web Service client using Java applications. To create a Java project:

  1. From the Eclipse menu bar, choose File - New - Project.
    The New Project dialog box appears.
  2. Choose Java Project, and then click the Next button.
    The Create a Java Project page appears.
  3. Specify the required items, and then click the Finish button.
    A Java project is created.

Note that to use the JAX-WS engine to execute Web Services in Java applications, you must set up an external Jar in the project build path and the VM argument in the execution or debug environment of the Java applications. The setup procedure is as follows:

(3) Acquiring a WSDL file

Acquire the WSDL file that codes the meta information of the Web Services you are trying to invoke, or if the URL of the WSDL file has been released, acquire that URL.

(4) Generating a Java source

Based on the acquired WSDL file, generate the Java source (service class, SEI, and Java Bean (stub)) required for developing and executing the Web Service client. You can generate the Java source from Eclipse. To generate a Java source:

  1. In the Project Explorer view, select the project to be used for developing a Web Service client.
  2. From the Eclipse menu bar, choose File - New - Other.
    The New dialog box appears.

    [Figure]

  3. Choose Cosminexus Web service - Web Service Client and click the Next button.
    The Web Service Client page of the Web Service Client dialog box appears.

    [Figure]

  4. Specify the following items:
    Item name Specified value
    Project Select the Java project name of the workspace.
    WSDL file Specify the WSDL file or WSDL file URL.
    Java source folder Specify the folder for generating the Java source.
    When the following operations or settings are performed and the Web Service Client dialog box appears, the Java source folder selection becomes blank and the subsequent operations can no longer be performed. Therefore, specify a folder other than the project root in Java source folder.
    • When Use project folder as root for sources and class files is selected in Project layout of the New Java Project dialog box for creating the Java project, if a Java project is used for Web Service client development
    • When project root is set up in Source folders on build path in the Source tab on the Java Build Path page in the Properties dialog box of the project used for developing a Web Service client
     
    Also, if the values entered in Project and Java source folder are changed, the values of the following items return to their initial states:
    • If the values in Project are changed
      The values of WSDL file, Java source folder, Java package, Binding file, and WSDL location return to the initial state.
    • If the values in Java source folder are changed
      The values of WSDL file, Java package, Binding file, and WSDL location return to the initial state.
     
    Specify the following items as and when required:
    Item name Specified value
    Java package Specify the package name of the Java source to be generated.
    Binding file Specify the binding file.
    WSDL location Specify the value to be set up in the wsdlLocation element of the javax.xml.ws.WebServiceClient annotation.
    For more details on each item, also see 14.1 cjwsimport command in the manual uCosminexus Application Server Web Service Development Guide.
  5. Click the Finish button.
    A message, indicating that the processing is executed, appears and the Java source is generated.
    Note
    If the WSDL file and binding file of the invoked Web Service are modified and the Java source is regenerated using the Web Service Client dialog box due to the upgrading of Web Service version, make sure that a file with the name same as of the output file does not exist in the folder specified in Java source folder.
    If a service class, SEI, or Java Bean (stub) with the name same as of the output file exists, the service class, SEI, or Java Bean (stub) is overwritten.

(5) Implementing a Web Service client

Use the generated Java source to implement the Web Service client. For the examples of Implementing a Web Service client, see 3.6 Implementing a Web Service client in the manual uCosminexus Application Server Web Service Development Guide.

(6) Debugging Java applications

Debug the created Java applications. Specify the VM argument in the debug configuration of the Java applications and click the Debug button. For details on setting up the VM argument in the debug configuration of Java applications, see the subsection 8.4.1(2) Creating a Java project.