Versions Compared

Key

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

...

Code Block
xml
xml
<dependencies>
	<dependency>
		<groupId>org.apache.cxf</groupId>
		<artifactId>cxf-rt-frontend-jaxws</artifactId>
		<version>2.0.2-incubator<6</version>
	</dependency>
	<dependency>
		<groupId>org.apache.cxf</groupId>
		<artifactId>cxf-rt-transports-http</artifactId>
		<version>2.0.2-incubator<6</version>
	</dependency>
        <!-- Jetty is needed if you're are not using the CXFServlet -->
	<dependency>
		<groupId>org.apache.cxf</groupId>
		<artifactId>cxf-rt-transports-http-jetty</artifactId>
		<version>2.0.2-incubator<6</version>
	</dependency>
</dependencies>

YouFor 2.0.6 and later versions, you don't need to specify any repositories as the artifacts are available in the central repository. For versions prior to 2.0.6, you'll also need to add the Apache Incubator Maven repository:

...

Code Block
xml
xml
<plugin>
	<groupId>org.apache.cxf</groupId>
	<artifactId>cxf-codegen-plugin</artifactId>
	<version>2.0.2-incubator<6</version>
	<executions>
		<execution>
			<id>generate-sources</id>
			<phase>generate-sources</phase>
			<configuration>
				<sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
				<wsdlOptions>
					<wsdlOption>
						<wsdl>${basedir}/src/main/wsdl/myService.wsdl</wsdl>
					</wsdlOption>
				</wsdlOptions>
			</configuration>
			<goals>
				<goal>wsdl2java</goal>
			</goals>
		</execution>
	</executions>
</plugin>

...

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

Java2WSDL (CXF 2.0.x only. Removed in 2.1 and replaced with Java2WS.)

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.2-incubator<6</version>
  <dependencies>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-frontend-jaxws</artifactId>
      <version>2.0.2-incubator<6</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>

...

Code Block
<configuration>
   <className>...</className>
   <classPath>...</classPath>
   <outputFile>...</outputFile>
   <serviceName>...</serviceName>
   <soap12>...</soap12>
   <targetNameSpace>...</targetNameSpace>
   <verbose>...</verbose>
   <quiet>...</quiet>
</configuration>

Java2WS

This plugin will be ready in 2.1 release .Now You can use 2.1-incubator-SNAPSHOT version of this plugin.
This plugin can generate WSDL, server side code used to start web service and client side code from
a java class.
Here is a simple example:

Code Block
xml
xml
<plugin>
	<groupId>org.apache.cxf</groupId>
	<artifactId>cxf-java2ws-plugin</artifactId>
	<version>2.1-incubator-SNAPSHOT<1</version>
	<dependencies>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-frontend-jaxws</artifactId>
			<version>2.1-incubator-SNAPSHOT<1</version>
		</dependency>
		<dependency>
			<groupId>org.apache.cxf</groupId>
			<artifactId>cxf-rt-frontend-simple</artifactId>
			<version>2.1-incubator-SNAPSHOT<1</version>
		</dependency>
	</dependencies>

	<executions>
		<execution>
			<id>generate-test-sources</id>
			<phase>generate-test-sources</phase>
			<configuration>
				<className>org.apache.hello_world.Greeter</className>
				<genWsdl>true</genWsdl>
				<verbose>true</verbose>
			</configuration>
			<goals>
				<goal>java2ws</goal>
			</goals>
		</execution>
	</executions>
</plugin>

...