Rechercher

Ce contenu n'est pas disponible dans la langue sélectionnée.

35.5. Java-to-WSDL Maven Plug-In

download PDF

Overview

To generate a WSDL contract from your SEI, you can use either the java2ws command-line utility or the cxf-java2ws-plugin Maven plug-in. The plug-in approach is ideal for Maven-based projects: after you paste the requisite plug-in configuration into your POM file, the WSDL code generation step is integrated into your build.

Configure the Java-to-WSDL Maven plug-in

Configuring the Java-to-WSDL Maven plug-in is relatively easy, because most of the default configuration settings can be left as they are. After copying and pasting the sample plugin element into your project's POM file, there are just a few basic settings that need to be customized, as follows:
  • CXF version—make sure that the plug-in's dependencies are using the latest version of Apache CXF.
  • SEI class name—specify the fully-qualified class name of the SEI in the configuration/className element.
  • Location of output—specify the location of the generated WSDL file in the configuration/outputFile element.
For example, the following POM fragment shows how to configure the cxf-java2ws-plugin plug-in to generate WSDL from the CustomerService SEI:
<project ...>
  ...
  <properties>
 <cxf.version>3.1.5.redhat-630xxx</cxf.version>
  </properties>
  
  <build>
    <defaultGoal>install</defaultGoal>
    <plugins>
      ...
      <plugin>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-java2ws-plugin</artifactId>
        <version>${cxf.version}</version>
        <dependencies>
          <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>${cxf.version}</version>
          </dependency>
          <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-simple</artifactId>
            <version>${cxf.version}</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>process-classes</id>
            <phase>process-classes</phase>
            <configuration>
              <className>org.fusesource.demo.camelcxf.ws.server.CustomerService</className>
              <outputFile>${basedir}/../src/main/resources/wsdl/CustomerService.wsdl</outputFile>
              <genWsdl>true</genWsdl>
              <verbose>true</verbose>
            </configuration>
            <goals>
              <goal>java2ws</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>

Generated WSDL

When using the Java-first approach to defining a Web service, there are typically other parts of your application (for example, WS clients) that depend on the generated WSDL file. For this reason, it is generally a good idea to output the generated WSDL file to a common location, which is accessible to other projects in your application, using the outputFile configuration element.
If you do not specify the outputFile configuration element, the generated WSDL is sent to the following location, by default:
BaseDir/target/generated/wsdl/SEIClassName.wsdl

Reference

For full details of how to configure the Java-to-WSDL plug-in, see the Maven Java2WS plug-in reference page.
Red Hat logoGithubRedditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez leBlog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

© 2024 Red Hat, Inc.