简体   繁体   中英

Generate java from wsdl

IntelliJ IDEA 2022.1.3 (Community Edition

In my java project I use Ant to build project. To generate java files from wsdl file I use this Ant's target:

<!-- CXF -->
    <property name="cxf.home" location="c:/Programs/apache-cxf-3.1.7" />

    <path id="cxf.classpath">
        <fileset dir="${cxf.home}/lib">
            <include name="*.jar" />
        </fileset>
    </path>

    <target name="cxfWSDLToJava">
        <java classname="org.apache.cxf.tools.wsdlto.WSDLToJava" fork="true">
            <arg value="-client" />
            <arg value="-d" />
            <arg value="src" />
            <arg value="c:\temp\wsdl\Sign.wsdl.xml" />
            <classpath>
                <path refid="cxf.classpath" />
            </classpath>
        </java>
    </target>

It's work fine.

But I want to migrate to Gradle. And the question is:

How I can generate java files from wsdl file by Gradle ?

You can use CXF Codegen Gradle to do this since you are already using org.apache.cxf.tools.wsdlto.WSDLToJava . The plugin provides a DSL over the CLI options of the tool.

Minimum example:

tasks.register("sign", io.mateo.cxf.codegen.wsdl2java.Wsdl2Java::class) {
    toolOptions {
        wsdl.set(file("path/to/Sign.wsdl"))
    }
}

See the docs for full list of supported options .


Note: I am the author of the plugin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM