Bhuvan
Bhuvan

Reputation: 2229

Not able to generate client code with wsdl2java and maven using CXF

I'm using maven cxf-codegen-plugin to generate client files from wsdl but not able to do so.

I want that all the wsdl files in the folder src/main/wsdl should be scanned and corresponding clients should be generated in separate folders. Please help.

My pom.xml is :

<build>
    <finalName>someFileName</finalName>
    <pluginManagement>
        <plugins>
            <plugin>
                 <groupId>org.apache.cxf</groupId>
                 <artifactId>cxf-codegen-plugin</artifactId>
                 <version>2.2.3</version>
                 <executions>
                     <execution>
                        <id>generate-sources</id>
                        <phase>process-resources</phase>
                         <configuration>
                             <sourceRoot>src/main/java</sourceRoot>
                             <wsdlRoot>${basedir}/src/main/wsdl</wsdlRoot> 
                        </configuration>
                         <goals>
                             <goal>wsdl2java</goal>
                         </goals>
                     </execution>
                 </executions>
             </plugin>
         </plugins>
    </pluginManagement>
</build>

Upvotes: 2

Views: 17575

Answers (3)

Mamuka Arabuli
Mamuka Arabuli

Reputation: 74

I put plugins tag inside pluginManagement tag and error disappeared:

<pluginManagement>
   <plugins>
        <plugin>

            ..........................

        </plugin>
   </plugins> 
</pluginManagement>

Upvotes: 0

code4kix
code4kix

Reputation: 4187

I realize this is an old question, but I just ran into this, so I wanted to reply for the benefit of others. You are right on commenting out the <pluginManagement> tag see here. However for the error in Eclipse that says:

Plugin execution not covered by lifecycle configuration

You will need to install the m2e connector for build-helper-maven-plugin (click on the error, and Eclipse should guide you to install it)

Upvotes: 2

chami
chami

Reputation: 41

here's how I'm doing it with version 2.7.4, and having the generated code created in different packages :

<build>
    <plugins>
        <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>
                        <sourceRoot>${project.build.directory}/generated/src/main/java</sourceRoot>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>${basedir}/src/main/wsdl/MyWsdl1.wsdl</wsdl>
                                <extraargs>
                                    <extraarg>-client</extraarg>
                                    <extraarg>-verbose</extraarg>
                                    <extraarg>-p</extraarg>
                                    <extraarg>urn:mycompany:myproduct1:v1_0=com.my.project.product1</extraarg>
                                    <extraarg>-p</extraarg>
                                    <extraarg>http://www.w3.org/2001/XMLSchema=com.my.project.common</extraarg>
                                </extraargs>
                            </wsdlOption>
                            <wsdlOption>
                                <wsdl>${basedir}/src/main/wsdl/MyWsdl2.wsdl</wsdl>
                                <extraargs>
                                    <extraarg>-client</extraarg>
                                    <extraarg>-verbose</extraarg>
                                    <extraarg>-p</extraarg>
                                    <extraarg>urn:mycompany:myproduct2:v1_0=com.my.project.product2</extraarg>
                                    <extraarg>-p</extraarg>
                                    <extraarg>http://www.w3.org/2001/XMLSchema=com.my.project.common</extraarg>
                                </extraargs>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>

Here's where you can find out more about the extra-args : http://cxf.apache.org/docs/wsdl-to-java.html

For an automatic scan of the wsdl folder, this works good too :

<configuration>
                        <sourceRoot>${project.build.directory}/generated/src/main/java</sourceRoot>
                        <wsdlRoot>${basedir}/src/main/wsdl</wsdlRoot>
<includes>
    <include>**/*.wsdl</include>
</includes>
</configuration>

Hope it helps!

Upvotes: 4

Related Questions