简体   繁体   English

从 wsdl 生成 java

[英]Generate java from wsdl

IntelliJ IDEA 2022.1.3 (Community Edition IntelliJ IDEA 2022.1.3(社区版

In my java project I use Ant to build project.在我的 java 项目中,我使用Ant来构建项目。 To generate java files from wsdl file I use this Ant's target:要从 wsdl 文件生成 java 文件,我使用这个 Ant 的目标:

<!-- 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.但我想迁移到 Gradle。 And the question is:问题是:

How I can generate java files from wsdl file by Gradle ?如何通过Gradle从 wsdl 文件生成 java 文件?

You can use CXF Codegen Gradle to do this since you are already using org.apache.cxf.tools.wsdlto.WSDLToJava .您可以使用CXF Codegen Gradle来执行此操作,因为您已经在使用org.apache.cxf.tools.wsdlto.WSDLToJava The plugin provides a DSL over the CLI options of the tool.该插件通过工具的 CLI 选项提供 DSL。

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.注意:我是插件的作者。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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