1. Web Service Maven Plugin

This section describes the Maven plugin, which is provided for web service clients, and how to create JAX-WS based web services.

1.1. wsgen

The wsgen plugin creates the following from the service endpoint interface classes and Java classes.

  • Portable Artifacts

  • Web service WSDL file (option)

The wsgen plugin is in the JEUS_HOME/lib/client/jeus-ws-maven-plugin.jar file.

Before using the wsgen plugin, the following must be performed.

  1. Install the jeus-ws-maven-plugin.jar file on a local repository.

  2. Add the following to the Maven option in a JDK 7 environment.

    -Djava.endorsed.dirs=JEUS_HOME/lib/endorsed

The following describes the wsgen plugin properties.

Property Description

sei

SEI class name. (Required option, String type)

destDir

Absolute path to the directory in which class files are created.

(Default value: ${project.build.outputDirectory})

resourceDestDir

Used with the genwsdl property. This property configures the location in which WSDL files are created.

(Default value: ${project.build.directory}/generated-sources/wsdl)

sourceDestDir

Directory in which source files are created.

(Default value: ${project.build.directory}/generated-sources/wsgen)

keep

Saves created files. (Default value: true)

verbose

Displays verbose messages. (Default value: false)

genWsdl

Option to create the WSDL file. (Default value: false)

protocol

Used with the genwsdl property. Protocol to be used in the wsdl:binding element. The default value is soap1.1. Xsoap1.2 values can be used with the property extension. (String type)

servicename

Used with the genwsdl property. Name of a specific wsdl:service element of the created WSDL file. (String type)

portname

Used with the genwsdl property. Name of a specific wsdl:portname element of the created WSDL file. (String type)

extension

Allows vendor extensions. This option may cause compatibility and portability issues. (Default value: false)

Example

The following is an example of a pom.xml that executes the wsgen plugin.

  • pom.xml example

    wsgen plugin pom File Example: <pom.xml>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>jeus.webservices.maven.sample</groupId>
        <artifactId>wsgen_sample</artifactId>
        <version>0.0.1</version>
        <packaging>war</packaging>
    
        <name>${project.artifactId}</name>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>jeus.ws</groupId>
                    <artifactId>jeus-ws-maven-plugin</artifactId>
                    <version>0.0.1</version>
                    <executions>
                        <execution>
                            <id>wsgen_test</id>
                            <goals>
                                <goal>wsgen</goal>
                            </goals>
                            <configuration>
                                <sei>jeus.webservices.sample.EchoService</sei>
                                <extension>true</extension>
                                <genWsdl>true</genWsdl>
                                <keep>true</keep>
                                <inlineSchemas>true</inlineSchemas>
                            </configuration>
                        </execution>
                    </executions>
    
                    <dependencies>
                        <dependency>
                            <groupId>com.sun</groupId>
                            <artifactId>tools</artifactId>
                            <version>1.6</version>
                            <scope>system</scope>
                            <systemPath>${java.home}/../lib/tools.jar</systemPath>
                        </dependency>
                        <dependency>
                            <groupId>com.sun.xml.ws</groupId>
                            <artifactId>jaxws-tools</artifactId>
                            <version>2.2</version>
                            <scope>system</scope>
                            <systemPath>${jeus.home}/lib/system/jaxws-tools.jar</systemPath>
                        </dependency>
                    </dependencies>
                </plugin>
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                        <encoding>UTF-8</encoding>
                        <compilerArguments>
                            <endorseddirs>${jeus.home}/lib/endorsed</endorseddirs>
                        </compilerArguments>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    
    </project>
  • Execution example

    $ mvn -Djeus.home=${JEUS_HOME} process-classes
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building wsgen_sample 0.0.1
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ wsgen_sample ---
    [INFO] skip non existing resourceDirectory /jeus/wsgen/src/main/resources
    [INFO]
    [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ wsgen_sample ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO]
    [INFO] --- jeus-ws-maven-plugin:0.0.1:wsgen (wsgen_test) @ wsgen_sample ---
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 3.773s
    [INFO] ------------------------------------------------------------------------

1.2. wsimport

The wsimport plugin creates one of the following from web service WSDL files.

  • Java program stubs for web service clients

  • Java program interfaces for web service servers

The wsgen plugin is in the JEUS_HOME/lib/client/jeus-ws-maven-plugin.jar file. Before using the wsgen plugin, the following must be performed.

  1. Install the jeus-ws-maven-plugin.jar file on a local repository.

  2. Add the following to the Maven option in a JDK 7 environment.

    -Djava.endorsed.dirs=JEUS_HOME/lib/endorsed

The following describes the wsimport plugin properties.

Property Description

wsdlDirectory

Path to WSDL files, which are required to create Java source files. (Default value: ${basedir}/src/wsdl)

wsdlFiles

List of local WSDL files. (String type)

wsdlUrls

List of External WSDL URLs. (String type)

destDir

Absolute path to the directory in which Java files are created.

(Default value: ${project.build.outputDirectory})

Directory in which source files are created. If this property is set, the keep property is automatically set.

sourceDestDir

Directory in which source files are created. If this property is set, the keep property is automatically set.(Default value: ${project.build.directory}/generated-sources/wsimport)

keep

Saves created files. (Default value: true)

verbose

Displays verbose messages. (Default value: false)

bindingDirectory

Path to JAX-WS or JAXB binding files.

(Default value: ${basedir}/src/jaxws)

bindingFiles

List of JAX-WS or JAXB binding files. (String type)

extension

Allows vendor extensions. This option may cause compatibility and portability issues. (Default value: false)

wsdlLocation

If WSDL URI is set in this property, it applies to service end-point interfaces and the @WebServiceClient.wsdlLocation and @WebService.wsdlLocation annotations of the service interfaces.

catalog

External entity reference values like those in TR9401, XCatalog, and OASIS XML Catalog. (String type)

packageName

Java package name for all namespace URIs in WSDL. (String type)

target

Creates code according to the specified version of JAX-WS specifications. (String type)

quiet

Does not display output messages. (Default value: false)

Example

The following is an example of a pom.xml that executes the wsimport plugin.

  • pom.xml example

    wsimport plugin pom File Example: <pom.xml>
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <modelVersion>4.0.0</modelVersion>
    
        <groupId>jeus.webservices.maven.sample</groupId>
        <artifactId>wsimport_sample</artifactId>
        <version>0.0.1</version>
        <packaging>war</packaging>
    
        <name>${project.artifactId}</name>
    
        <build>
            <plugins>
                <plugin>
                    <groupId>jeus.ws</groupId>
                    <artifactId>jeus-ws-maven-plugin</artifactId>
                    <version>0.0.1</version>
                    <executions>
                        <execution>
                            <id>wsimport_test</id>
                            <goals>
                                <goal>wsimport</goal>
                            </goals>
                            <configuration>
                                <packageName>jeus.webservices.sample.test</packageName>
                                <wsdlDirectory>${basedir}/src/wsdl</wsdlDirectory>
                                <wsdlFiles>
                                    <wsdlFile>EchoService.wsdl</wsdlFile>
                                </wsdlFiles>
                            </configuration>
                        </execution>
                    </executions>
    
                    <dependencies>
                        <dependency>
                            <groupId>com.sun</groupId>
                            <artifactId>tools</artifactId>
                            <version>1.6</version>
                            <scope>system</scope>
                            <systemPath>${java.home}/../lib/tools.jar</systemPath>
                        </dependency>
                        <dependency>
                            <groupId>com.sun.xml.ws</groupId>
                            <artifactId>jaxws-tools</artifactId>
                            <version>2.2</version>
                            <scope>system</scope>
                            <systemPath>${jeus.home}/lib/system/jaxws-tools.jar</systemPath>
                        </dependency>
                    </dependencies>
                </plugin>
    
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>2.3.2</version>
                    <configuration>
                        <source>1.6</source>
                        <target>1.6</target>
                        <encoding>UTF-8</encoding>
                        <compilerArguments>
                            <endorseddirs>${jeus.home}/lib/endorsed</endorseddirs>
                        </compilerArguments>
                    </configuration>
                </plugin>
            </plugins>
        </build>
    
    </project>
  • Execution example

    $ mvn -Djeus.home=${JEUS_HOME} generate-sources
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building wsimport_sample 0.0.1
    [INFO] ------------------------------------------------------------------------
    [INFO]
    [INFO] --- jeus-ws-maven-plugin:0.0.1:wsimport (wsimport_test) @ wsimport_sample ---
    [INFO] Processing: file:/jeus/wsimport/src/wsdl/EchoService.wsdl
    [INFO] jaxws:wsimport args: [-keep, -s, /jeus/wsimport/target/generated-sources/wsimport,
    -Xnocompile, -p, jeus.webservices.sample.test, file:/jues/wsimport/src/wsdl/EchoService.wsdl]
    parsing WSDL...
    
    
    
    Generating code...
    
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 2.052s
    [INFO] ------------------------------------------------------------------------