Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
xml
xml
<repositories>
	<repository>
		<id>apache-snapshots</id>
		<name>Apache SNAPSHOT Repository</name>
		<url>http://people.apache.org/repo/m2-snapshot-repository/</url>
		<snapshots>
			<enabled>true</enabled>
		</snapshots>
	</repository>
	<repository>
		<id>apache-incubating</id>
		<name>Apache Incubating Repository</name>
		<url>http://people.apache.org/repo/m2-incubating-repository/</url>
	</repository>
</repositories>

<pluginRepositories>
	<pluginRepository>
		<id>apache-plugin-snapshots</id>
		<name>Apache Maven Plugin Snapshots</name>
		<url>http://people.apache.org/repo/m2-snapshot-repository</url>
		<releases>
			<enabled>false</enabled>
		</releases>
		<snapshots>
			<enabled>true</enabled>
		</snapshots>
	</pluginRepository>
</pluginRepositories>

Maven Plugin

WSDL2Java

CXF includes a Maven plugin which can generate artifacts from WSDL. Here is a simple example:

...

Other configuration arguments can be include inside the <wsdlOption> element. These pass arguments to the tooling and correspond to the options outlined on the WSDL To Java page.

Example 1: Passing in a JAX-WS Binding file

Code Block
xml
xml
<configuration>
  <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
  <wsdlOptions>
    <wsdlOption>
      <wsdl>${basedir}/src/main/wsdl/myService.wsdl</wsdl>
      <extraargs>
        <extraarg>-b</extraarg>
        <extraarg>${basedir}/src/main/resources/wsdl/async_binding.xml</extraarg>                              
      </extraargs>
    </wsdlOption>
  </wsdlOptions>
</configuration>

In this example we're specifying that we want CXF to use our JAX-WS binding file. Binding files are a way to customize the output of the artifacts that CXF generates. For instance, it allows you to change the package name CXF uses.

Example 2: Specifying a service to generate artifacts for

Code Block
xml
xml
<configuration>
  <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
  <wsdlOptions>
    <wsdlOption>
      <wsdl>${basedir}/src/main/wsdl/myService.wsdl</wsdl>
      <extraargs>
        <extraarg>-sn</extraarg>
        <extraarg>MyWSDLService</extraarg>                                                                 
      </extraargs>
    </wsdlOption>
  </wsdlOptions>
</configuration>

In this example we're specifying that we only want to generate artifacts for the service named "MyWSDLService" in the WSDL.

Java2WSDL

CXF also includes a Maven plugin which can generate WSDL from Java code. Here is a simple example:

Code Block
xml
xml

<plugin>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-codegen-plugin</artifactId>
  <version>2.0</version>
  <dependencies>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-frontend-jaxws</artifactId>
      <version>2.0</version>
    </dependency>
  </dependencies>
  <executions>
    <execution>
      <id>generate-wsdl</id>
      <phase>process-classes</phase>
      <configuration>
        <className>org.example.MyService</className>
      </configuration>
      <goals>
        <goal>java2wsdl</goal>
      </goals>
    </execution>
  </executions>
</plugin>