Is it possible to generate webservices client code to a special package using apache cxf in maven?
Asked Answered
K

3

5

I am trying to generate the webservices client once i build my project on the fly .. It currently does so but put it in package named based on the namespace of the WS.. so lets assume the name space is google.com , the generated files would be in com.google ..

<plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>2.2.10</version>
            <executions>
                <execution>
                    <id>generate-sources</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <sourceRoot>${basedir}/src/main/java/</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>http://localhost:8080/ProjectName/ProjectWS?wsdl</wsdl>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

I want to generate the files to a different package.. lets call it comWS.gooleClient

Is it possible to do that?

Thanks

Kenogenesis answered 16/9, 2010 at 21:31 Comment(0)
G
8

It is possible using a custom binding or passing the -p extra argument as shown below:

<plugin>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-codegen-plugin</artifactId>
  <version>2.2.10</version>
  <executions>
    <execution>
      <id>generate-sources</id>
      <phase>generate-sources</phase>
      <configuration>
        <sourceRoot>${basedir}/src/main/java/</sourceRoot>
        <wsdlOptions>
          <wsdlOption>
            <wsdl>http://localhost:8080/ProjectName/ProjectWS?wsdl</wsdl>
            <extraargs>
              <extraarg>-p</extraarg>
              <extraarg>com.something.else</extraarg>
            </extraargs>
          </wsdlOption>
        </wsdlOptions>
      </configuration>
      <goals>
        <goal>wsdl2java</goal>
      </goals>
    </execution>
  </executions>
</plugin>
Gritty answered 17/9, 2010 at 7:31 Comment(1)
Thank you very much! I tried <extraarg>-p com.something.else</extraarg> before finding your answer here and this did not work.Ulcer
E
6

I am very late though , but this specification worked for me

<plugin>
     <groupId>org.apache.cxf</groupId>
 <artifactId>cxf-codegen-plugin</artifactId>
 <version>2.7.7</version>
 <executions>
    <execution>
    <id>generate-sources</id>
    <phase>generate-sources</phase>
    <configuration>
         <sourceRoot>${basedir}/src/main/java</sourceRoot>
         <wsdlOptions>
               <wsdlOption>
              <wsdl>wsdl-location</wsdl>
          <extraargs>
            <extraarg>-client</extraarg>
              </extraargs>
        <packagenames> 
                <packagename>desired location</packagename> 
        </packagenames> 
               </wsdlOption>
            </wsdlOptions>                    
       </configuration>
       <goals>
        <goal>wsdl2java</goal>
     </goals>
   </execution>
</executions>
</plugin>
Elderberry answered 8/10, 2013 at 9:11 Comment(0)
M
1

Did you try this for extraarg?

<extraarg><!--namespace-->=<!-- new package name--></extraarg>

Example:

<plugin>
  <groupId>org.apache.cxf</groupId>
  <artifactId>cxf-codegen-plugin</artifactId>
  <version>2.2.10</version>
  <executions>
    <execution>
      <id>generate-sources</id>
      <phase>generate-sources</phase>
      <configuration>
        <sourceRoot>${basedir}/src/main/java/</sourceRoot>
        <wsdlOptions>
          <wsdlOption>
            <wsdl>http://localhost:8080/ProjectName/ProjectWS?wsdl</wsdl>
            <extraargs>
                <extraarg>-p</extraarg>
                <extraarg>http://google.com=comWS.gooleClient</extraarg>
            </extraargs>
          </wsdlOption>
        </wsdlOptions>
      </configuration>
      <goals>
        <goal>wsdl2java</goal>
      </goals>
    </execution>
  </executions>
</plugin>
Mf answered 24/1, 2013 at 1:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.