Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Custom package names cxf-codegen-plugin

Imagine this scenario.

I have a wsdl file with namespace a/b/c and it imports another wsdl whose namespace is m/n/o. Unfortunately, both of them have same ComplexTypes XYZ defined in them. Now, when I use cxf-codegen-plugin to generate Java code and use custom package name "com.qsrs.uvw", only one class is retained in the final code that is generated. Can someone help me out here?

like image 947
Gopal Avatar asked Sep 26 '12 15:09

Gopal


People also ask

What is CXF codegen plugin?

CXF includes a Maven plugin which can generate java artifacts from WSDL. Here is a simple example: < plugin > < groupId >org.apache.cxf</ groupId > < artifactId >cxf-codegen-plugin</ artifactId >

What is codegen plugin?

hykes. Compatible with IntelliJ IDEA (Ultimate, Community, Educational), WebStorm. GitHub | Issues | JetBrains. This plugin helps you to generate specific template code by create table statement or database .

How do I generate a class from WSDL using Apache CXF?

You will have to make sure that you create an appropriate directory structure for your project and add the earlier shown hello. wsdl file to the specified folder. The wsdl2java plugin will compile this wsdl and create Apache CXF classes in a pre-defined folder.

Which CXF plugin can be used to generate the Java stubs?

There are many ways to generate Java classes from WSDL files – one of them is using the cxf-codegen-plugin, which comes from the Apache Maven CXF.


1 Answers

If you want to generate package depending on the namespace here is the solution:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>2.6.0</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${basedir}/target/generated/src/main/java</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>yourWsdl.wsld</wsdl>
                        <extraargs>
                            <extraarg>-client</extraarg>
                            <extraarg>-verbose</extraarg>
                            <extraarg>-p</extraarg>
                            <extraarg>http://your.namespace/services/=your.package</extraarg>
                            <extraarg>-p</extraarg>
                            <extraarg>http://your.namespace2/services2/=your.package2</extraarg>
                        </extraargs>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
</plugin>

This <extraarg>http://your.namespace2/services2/=your.package2</extraarg> will map your namespace with the package you want.

like image 110
Paulius Matulionis Avatar answered Oct 03 '22 22:10

Paulius Matulionis