Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: polishing, added missing cxf-xjc-runtime

...

Code Block
xml
xml
    <configuration>
     <wsdlOptions>
      <wsdlOption>
       <wsdlArtifact>
        <groupId>org.apache.pizza</groupId>
	    <artifactId>PizzaService</artifactId>
	    <version>1.0.0</version>
       </wsdlArtifact>
      </wsdlOption>
     </wsdlOptions>
    </configuration>

...

Standard JAXB command-line customizations can be added via <extraarg> elements, either one per line or comma separated. CXF also offers some JAXB extensions for the code generation. They have to be added as dependencies and then activated by using an extraarg with content -xjc-X<extension id>

artifact id

description

extension id

cxf-xjc-boolean

Adds getters for booleans

boolean

cxf-xjc-bug671

Workaroung for JAXB bug 671

bug671

cxf-xjc-dv

Default value support

dv

cxf-xjc-ts

Adds toString to objects

ts

cxf-xjc-wsdlextension

WsdlExtension support

wsdlextension

jaxb-fluent-api

((warning) not part of CXF:

group id is net.java.dev.jaxb2-commons)

Fluent API for settersfluent-api

An example showing attachment of a JAXB binding file and the CXF toString() extension is below:

Code Block
xml
xml
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
  <execution>
    <id>generate-sources</id>
    <phase>generate-sources</phase>
    <configuration>
      <wsdlOptions>
        <wsdlOption>
          <wsdl>${basedir}/src/main/resources/wsdl/myService.wsdl</wsdl>
          <extraargs>
            <extraarg>-xjc-b,binding.xjb</extraarg>
            <extraarg>-xjc-Xts</extraarg>
          </extraargs> 
        </wsdlOption>
      </wsdlOptions>
    </configuration>
    <goals>
      <goal>wsdl2java</goal>
    </goals>
  </execution>
</executions>
<dependencies>
    <dependency>
        <groupId>org.apache.cxf.xjcplugins</groupId>
        <artifactId>cxf-xjc-ts</artifactId>
        <version>${cxf-xjc.version}</version>
     </dependency>
</dependencies>
</plugin>

In addition you need to add the cxf-xjc-runtime as a dependency to your project:

Code Block
languagexml
<dependency>
   <groupId>org.apache.cxf.xjc-utils</groupId>
   <artifactId>cxf-xjc-runtime</artifactId>
   <version>${cxf-xjc.version}</version>
</dependency>

Example 8 - Using JAXB/JAX-WS 2.2 with Java 6

...