Generating WSDL2Java from Maven with CXF

user1448458 picture user1448458 · Mar 8, 2013 · Viewed 10.8k times · Source

For e.g. I have cxf-codegen-plugin like this:

        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>${cxf.version}</version>
            <dependencies>
                <dependency>
                    <groupId>org.apache.cxf</groupId>
                    <artifactId>cxf-rt-bindings-soap</artifactId>
                    <version>${cxf.version}</version>
                </dependency>
            </dependencies>
            <executions>
                <execution>
                    <id>generate-jaxb</id>
                    <phase>generate-sources</phase>
                    <configuration>
                        <additionalJvmArgs>-Dfile.encoding=UTF8</additionalJvmArgs>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>src/main/resources/wsdl/MyWsdl.wsdl</wsdl>
                                <extraargs>
                                    <extraarg>-wsdlLocation</extraarg>
                                    <extraarg></extraarg>
                                    <extraarg>-client</extraarg>
                                </extraargs>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

It is working just fine when my WSDl is stored in my local project:

src/main/resources/wsdl/MyWsdl.wsdl

What I am trying to achieve is to download the WSDL from remote Maven repository and pass it somehow to the <wsdl> element.

Something like:

<wsdl>
 <dependency>...</dependency>
</wsdl>

I can't find any information about how to do this. Does the option like this even exists? Or it should be done somehow differently then trying to pass the WSDL in the <wsdl> element?

Please advice.

Answer

Anders R. Bystrup picture Anders R. Bystrup · Mar 8, 2013

You can use the <wsdlArtifact> to load the WSDL from maven:

<configuration>
    ...
    <wsdlOptions>
        <wsdlOption>
            <wsdlArtifact>
                <groupId>your.group.id</groupId>
                <artifactId>YourWSDLService</artifactId>
                <version>0.1.2-SNAPSHOT</version>
            </wsdlArtifact>
        </wsdlOption>
    </wsdlOptions>
    ...
</configuration>