uCosminexus Application Server, Web Service Development Guide

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

14.1 cjwsimport command

The cjwsimport command follows the mapping rules defined in the JAX-WS 2.2 specifications and performs the mapping of a WSDL file to Java. If you execute the cjwsimport command, the Java source required for implementing Web Services and Web Service clients will be generated and compiled from WSDL files.

This subsection describes the format and the specified contents when executing the cjwsimport command.

Organization of this section
(1) Format
(2) List of options
(3) Specifying the WSIMPORT_OPTS environment variable
(4) Generated files
(5) Operations during processing
(6) End code
(7) Action for abnormal termination

(1) Format

The specification format of the cjwsimport command is as follows:

cjwsimport [Options] URL-or-file-path-of-the-WSDL-file

Example of specification
  • Specifying the local WSDL file using the relative path (wsdl/input.wsdl)
    cjwsimport -d generated wsdl/input.wsdl
  • Specifying the local WSDL file using the absolute path (/tmp/wsdl/input.wsdl)
    cjwsimport -d generated /tmp/wsdl/input.wsdl
  • Specifying the local WSDL file using a URL (file:///tmp/wsdl/input.wsdl)
    cjwsimport -d generated file:///tmp/wsdl/input.wsdl
  • Specifying the remote WSDL file using a URL (http://example.com:8080/fromjava/test?wsdl)
    cjwsimport -d generated http://example.com:8080/fromjava/test?wsdl

Notes for executing the cjwsimport command
You cannot assume a current directory with the characters such as %, &, and ^ to execute the cjwsimport command. If you assume such a current directory, the operations will not be guaranteed.

Notes for specifying a WSDL file
  • Specify one file path (relative path or absolute path) for a WSDL file or the URL to WSDL in the argument. If a file other than the WSDL file is specified, an error message will be output in the standard error output as well as log and the processing will end (KDJW51200-E).
  • When you specify WSDL using the file path, do not use the characters & and ^ in the file path. If such characters are used, the operations might not function properly. Also, if you are specifying a file path containing a blank space, enclose the entire file path within double quotation marks (""). If you do not enclose the entire file path within double quotation marks (""), the operations are not guaranteed.
  • When you specify a WSDL using a URL, use the characters defined in the RFC 2396 specifications and the strings complying with the rules in the RFC 2396 specifications. Additionally, in accordance with the rules of the RFC 2396 specifications, you must perform the percent encoding for the character strings with the UTF-8 format. If you do not follow the rules of the RFC 2396 specifications or if you specify the characters and character strings that are not encoded, the operations might not function properly.
  • You cannot specify a WSDL by using the jar protocol. If you specify a WSDL by using the jar protocol, the operation is not guaranteed.
  • When you specify the WSDL file using the file path or a URL to WSDL, specify the correct file path or URL. If you specify a wrong WSDL file path or WSDL URL and if the WSDL file cannot be found, an error message will be output in the standard error output and log and the processing will end (KDJW51180-E or KDJW51189-E).
  • The extension of the WSDL file specified in the argument is optional (you might specify an extension other than .wsdl).
  • The WSDL file is not case sensitive.
  • The length of the string to be specified is not limited. However, an error occurs when you exceed the limit set for the OS.
  • If you specify a WSDL file for which you do not have access permission, a JDK error occurs and the processing ends.

(2) List of options

You can specify the options listed in the following table as the options for the cjwsimport command:

Table 14-1 List of options for the cjwsimport command

Options Set items Specified contents
-d directory Output destination directory of the class file Specifies the output destination directory of the compiled class file (*.class).
For details about the values that you can specify, see Notes for specifying the -d option and the -s option described outside the table.
If this option is not specified, the class file will be output in the current directory.
-keep None Specified for generating the source file (*.java).
-s directory Output destination directory of the source file Specifies the output destination directory to output the source file (*.java).
For details about the values that you can specify, see Notes for specifying the -d option and the -s option described outside the table.
The output destination directory changes depending on the specification of the -d option and the -s option. For details about the specification of options and the output destination, see Table 14-3.
-verbose None Specified to output the detailed processing passage when the command is executed.
-b path Path of the external binding file Specifies the path of the external binding file when the external binding file is used.
For details about the values that you can specify, see Notes for specifying the -b option described outside the table.
-p package Package name of the Java code Specifies the package name of the Java source.
When you specify this option, the customization of the package name specified in the binding declaration and the generation algorithm for the default package name defined in standard specifications is overwritten.
-generateService Generating the Web Service Implementation Class Specified when the Web Service Implementation Class (skeleton class) is generated.
For details about the generated files, see 14.1(4) Generated files.
-help None Specified for displaying help.
When you specify this option, the specification of all options except -version is ignored; help is displayed and terminated.
-version None Specified for displaying the version information.
When you specify this option, the specification of other options is ignored; the version information is displayed and terminated.
-wsdllocation Values to be specified in the wsdlLocation element of the javax.xml.ws.WebServiceClient annotation Specifies the values to be specified in the wsdlLocation element of the javax.xml.ws.WebServiceClient annotation.
-catalog file Catalog file path Specifies the values for using the catalog functionality. For details on the values you can specify, see Notes for specifying the -catalog optiongiven below this table.

Creating a directory for generating a file
When you execute the cjwsimport command, a directory corresponding to the package name of the generated file will be created in the specified output destination directory and the file will be output in that directory.
The following is an example of command specification and output destination (for a request bean) when http://example.com/sample is coded in the namespace URI of Type referenced by the wrapper element of the request message for the WSDL file (test.wsdl):
  • Example of command specification
    cjwsimport -d ./output -keep input/test.wsdl
  • Output destination (Request bean)
    The compiled class file and source file of the request bean will be output in the following directory:
    ./output/com/example/sample/

Take the following precautions for the specified values of the options such as the values that can be specified for the option and the operations when the specification is omitted:

Common precautions for options
The following precautions are common to all the options:
  • The specification order for the options and arguments is optional. The specification order for each option is also optional.
  • Make sure that you specify the argument for the options with arguments. If the argument is not specified, an error message will output in the standard error output and log and the processing will end (KDJW51001-E).
  • When you specify the same option more than once, except for the -catalog option, the option specified at the end will be enabled.
  • The specification of the option is case sensitive.
  • The length of the string to be specified is not limited. However, an error occurs when you exceed the limit set for the OS.
  • Do not use the character strings containing & and ^ in the option specifying the path. If you use such character strings, the operations are not guaranteed. Also, if you specify a file path containing a blank space, enclose the entire file path within double quotation marks (""). If you do not enclose the entire file path within double quotation marks (""), the operations are not guaranteed.
  • If you specify an option that cannot be specified, an error message will output in the standard error output and log and the processing will end (KDJW51001-E).

Notes for specifying the -d option and the -s option
Take the following precautions for the values specified for the -d option and the -s option:
  • The specified value is not case sensitive.
  • If the specified output destination directory does not exist, an error message will output in the standard error output and log and the processing will end (KDJW51181-E).
  • If the file is specified in the wrong output destination directory, an error message will output in the standard error output and log and the processing will end (KDJW51182-E).
  • If you specify a WSDL file without access permission, a JDK error occurs and the processing ends.

Specification of -d, -s, and -keep options and file output destination
The output destination directory of the compiled class file and source file differs depending on the specification of the -d option, -s option, and the -keep option.
The following table describes whether the option is specified and the output destination directory of the compiled class file:

Table 14-2 Presence or absence of option specification and the output destination directory of the compiled class file

Presence or absence of option specification Presence or absence of source file output and output destination directory
-d -s -keep
Y -- -- Output in the directory specified in the -d option.
N -- -- Output in the current directory.

Legend:
Y: Indicates that the option is specified.
N: Indicates that the option is not specified.
--: Indicates that the presence or absence of option specification does not affect the output destination directory.

The following table describes the presence or absence of option specification and the output destination directory of the source file:

Table 14-3 Presence or absence of option specification and the output destination directory of the source file

Presence or absence of option specification Presence or absence of source file output and output destination directory
-d -s -keep
Y Y -- Output in the directory specified in the -s option.
Y N Y Output in the directory specified in the -d option.
Y N N Not output.
N Y -- Output in the directory specified in the -s option.
N N Y Output in the current directory.
N N N Not output.

Legend:
Y: Indicates that the option is specified.
N: Indicates that the option is not specified.
--: Indicates that the presence or absence of the option specification does not affect the output destination directory.

Notes for specifying the -b option
Take the following precautions for the values specified for the -b option:
  • The specified value is not case sensitive.
  • Specify the external binding file using the file path. The operations might not function properly if the file is specified using the URL format.
  • If the specified external binding file does not exist, an error message is output in the standard error output and log and the processing ends (KDJW51184-E).
  • If a file other than the external binding file is specified, the operations might not function properly.
  • If a directory is specified by mistake, an error message is output in the standard error output and log and the processing ends (KDJW51185-E).
  • If you specify a WSDL file without access permission, a JDK error occurs and the processing ends.
  • Specify the file same as the WSDL file to be customized by the specified external binding file and the WSDL file to be customized specified in the argument of the cjwsimport command. If the files are not the same, an error message is output in the standard error output and log and the processing ends (KDJW51190-E).
  • The specification of the extension of the external binding file (.wsdl) is optional.

Notes for specifying the -p option
Take the following precautions for the values specified in the -p option:
  • Specify the package name using one-byte alphanumeric characters (0 to 9, A to Z, a to z), underscore (_), and period (.). If other characters are used, the operations might not function properly.
  • For each label (xxx, yyy, zzz) that is separated using periods (.) such as xxx.yyy.zzz, specify strings that can be used with Java identifiers. If you specify characters that cannot be used, an error message will output in the standard error output and log and the processing will end.

Notes for specifying the -wsdllocation option
  • Specify the -wsdllocation option with the URI format. If you specify this option in any other format, the operations are not guaranteed.
  • You cannot specify the jar protocol for the values to be specified in the -wsdllocation option. If you specify the jar protocol, the operation is not guaranteed. When you specify the jar protocol as a URL for pointing to the WSDL, use the constructor that acquires the URL in a parameter while generating a service class.

Notes for specifying the -catalog option
Take the following precautions for specifying the values in the -catalog option:
  • If you specify the -catalog option more than once, the operation is not guaranteed.
  • The value to be specified is not case-sensitive.
  • Specify the file path of the catalog file. Follow the java.io.File class specifications for the specification format. If you specify the URL of the catalog file, the operation is not guaranteed.
  • Specify the file path for the catalog file by using single-byte alphanumeric characters (0 to 9, A to Z and, a to z), spaces, periods (.), underscores (_), colons (:), slashes (/), and \. If you use any other characters to specify the file path, the operation is not guaranteed.
  • You can specify any name for the catalog file.
  • If the specified catalog file does not exist, a warning message (KDJW51219-W) is output to the standard error output and log. The catalog functionality is disabled and the processing continues.
  • If you specify a file other than the catalog file, the operation is not guaranteed.
  • If a directory is specified by mistake, a warning message (KDJW51220-W) is output to the standard error output and log. The catalog functionality is disabled and the processing continues.
  • If the specified catalog file is coded in an unsupported syntax, a warning message (KDJW51221-W) is output to the standard error output and log. The catalog functionality is disabled and the processing continues.
  • If a catalog file that does not require access permission is specified, a JDK error occurs, the catalog functionality is disabled and the processing continues.

Operations, when a value is specified for an ignored value
Among all the values specified for the command, if a value is specified for values that are ignored even if specified, an error might occur in the processing performed later.

(3) Specifying the WSIMPORT_OPTS environment variable

If you specify an option character string in the WSIMPORT_OPTS environment variable, you can add the option with the java command that starts the cjwsimport command. By default, nothing is specified in the WSIMPORT_OPTS environment variable, so specify any character string, as and when required.

For example, by using the WSIMPORT_OPTS environment variable, you can specify the JDK system properties required for the SSL communication to enable execution of the cjwsimport command for WSDLs that you could not access before unless you used HTTPS. The following is an example.

> set WSIMPORT_OPTS=-Djavax.net.ssl.trustStore=trust-store -Djavax.net.ssl.trustStorePassword=trust-store-password
> "%COSMINEXUS_HOME%\jaxws\bin\cjwsimport.bat" https://securehost:443/fromwsdl/TestJaxWsService?wsdl

(4) Generated files

The following table describes the files generated when the cjwsimport command is executed:

Table 14-4 List of files generated for the cjwsimport command

No. Java code Contents Output by the -generateService option
Specified Not specified
1 Request bean class This is the JavaBean class corresponding to the type referenced by the wrapper element of the request message.
If the specified WSDL file does not have a wrapper style, the request bean class is not output.
Y Y
2 Response bean class This is the JavaBean class corresponding to the type referenced by the wrapper element of the response message.
If the specified WSDL file does not have a wrapper style, the response bean class is not output.
Y Y
3 Fault bean class This is the JavaBean class corresponding to the type referenced by the fault message.
If a fault is not defined in the specified WSDL file, the fault bean class is not output.
Y Y
4 Wrapper exception class This is the wrapper exception class of the fault bean class. Y Y
5 ObjectFactory class This is the factory class of the JAXB 2.2 specifications. Y Y
6 Other classes in the JAXB 2.2 specifications These are other classes in the JAXB 2.2specifications. These are the Java interfaces and Java classes corresponding to the various elements, types coded in the syntax of the XML Schema specification. Y Y
7 package-info class This is the package information. Y Y
8 SEI This is the service end point interface. Y Y
9 Skeleton class This is the skeleton class implementing SEI. Implementation is added in this class. Y --
10 Service class This class is used for accessing the Web Service. -- Y

Legend:
Y: Indicates that the file is output.
--: Indicates that the file is not output.

Precautions for generating a file
If a file with the same name as the skeleton class exists in the output destination directory of the generated file, a warning message is output in the standard error output and log (KDJW51203-W). At this time, the processing continues without the output of the skeleton class.
Also, apart from the Web Service Implementation Class, if a file with the same name exists in the output destination directory of the generated file, the file will be overwritten.

Output of the Javadoc header information
In the generated file, the Cosminexus-related information is output in the header information as Javadoc.

(5) Operations during processing

When you execute the cjwsimport command, the message (KDJW50001-I) indicating command execution will output in the standard output and log and the Java source generation and compilation processing will be performed. The following is a description of the processing:

Java source generation processing
When the Java source generation starts, a message indicating the start of generation is output in the standard output and log (KDJW50004-I). If an attempt to generate the Java source fails, the error message that causes the error is output in the standard error output and log (KDJW50005-E).

Java source compilation processing
When the Java source compilation starts, a message indicating the start of compilation is output in the standard output and log (KDJW50006-I). If an attempt to compile the Java source fails, the error message that causes the error is output in the standard error output and log (KDJW50007-E).

(6) End code

The following is the end code of the cjwsimport command:

0: Normal termination
If an error due to which processing cannot continue is not detected in the middle of the processing, a message indicating that the processing has finished is displayed in the standard output and log and the processing ends (KDJW50002-I).

1: Abnormal termination
If even a single error due to which processing cannot continue is detected in the middle of processing, an error message is displayed in the standard output and log and the processing ends (KDJW50003-E). For details about the action for abnormal termination, see 14.1(7) Action for abnormal termination.

If a negligible error is detected due to which processing cannot continue is detected in the middle of the processing, a warning message is output and the processing continues.

Note that sometimes a log is not output depending on the specified output level (importance). For details on the settings for the output level of a log, see 10.1.2 Settings for the common definition file.

(7) Action for abnormal termination

If an abnormal termination occurs during the execution of the cjwsimport command, an error message will output and the processing ends. In this case, remove the cause of the error that is output and re-execute the cjwsimport command.

Even for multiple errors, the error detected first is displayed. In this case, execute the cjwsimport command repeatedly and remove each of the causes of the displayed errors.