I am using CXF (for the the first time) to generate java source code from a WSDL supplied by a vendor I'm working with.

The vendor also supplied a POM.xml file with which to generate java source code from this wsdl for the client I need to build.

I find an annoying pattern in the generated code:

For fields in the data which are required (minOccurs > 0), the generated setters use the expected types (String, etc.) For fields in the data which are optional (minOccurs = 0), the generated setters take a parameter of JAXBElement<String>, etc.

Is there a way around this annoying pattern? Why would the optional fields generate different kinds of setters than the required ones?


pom.xml settings I'm using are below. I've also tried using 2.1.3 without improving the situation.

          <plugins>
               <plugin>
                   <artifactId>maven-compiler-plugin</artifactId>
                   <configuration>
                       <source>1.5</source>
                       <target>1.5</target>
                   </configuration>
               </plugin>
               <plugin>
                   <groupId>org.apache.cxf</groupId>
                   <artifactId>cxf-codegen-plugin</artifactId>
                   <version>2.0.7</version>
                   <executions>
                       <execution>
                           <id>generate-sources</id>
                           <phase>generate-sources</phase>
                           <configuration>
<!--sourceRoot>${basedir}/src/main/java</sourceRoot--> <sourceRoot>${basedir}/target/src/main/generated-java</sourceRoot>
                               <wsdlOptions>
                                   <wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdl/EmergencyProvisioningService.wsdl</wsdl>

                                       <extraargs>
                                           <extraarg>-p</extraarg>
<extraarg>com.whatever.service</extraarg>
                                           <extraarg>-impl</extraarg>
                                           <extraarg>-client</extraarg>
<extraarg>-verbose</extraarg>
                                       </extraargs>
                                   </wsdlOption>
                               </wsdlOptions>
                           </configuration>
                           <goals>
                               <goal>wsdl2java</goal>
                           </goals>
                       </execution>
                   </executions>
               </plugin>
           </plugins>



Reply via email to