【问题标题】:Ant wsdl2java to Maven wsdl2java convertionAnt wsdl2java 到 Maven wsdl2java 的转换
【发布时间】:2017-04-16 05:26:42
【问题描述】:

我正在尝试将构建我的项目从 Ant 转换为 Maven。

我的项目中有一个名为 TestServiceWSDL_TestServiceV1Http_Service.wsdl 的 wsdl。

当我使用 Ant build (axis-wsdl2java) 时,它会生成如下类:

TestServiceWSDL_TestServiceV1HttpBindingStub.java
TestServiceWSDL_TestServiceV1HttpService.java
TestServiceWSDL_TestServiceV1HttpServiceLocator.java

当我将它转换为 Maven 时,我看到它生成了如下类。

TestServiceV1_TestServiceWSDLTestServiceV1HttpPort_Client.java
TestServiceV1_TestServiceWSDLTestServiceV1HttpPort_Server.java
TestServiceWSDLTestServiceV1HttpService.java

如何将我的项目转换为使用 Maven 构建并生成具有相同名称的类?

使用的 Ant 命令:

<target name="wsdl2java">
    <axis-wsdl2java output="${gen.dir}" testcase="false" verbose="false" url="wsdl.url">
        <mapping namespace="namespace.from.wsdl.1" package="package.1" />
        <mapping namespace="namespace.from.wsdl.2" package="package.2" />
    </axis-wsdl2java>
</target>

Maven 插件:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>3.1.0</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>target/generated/src/main/java</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>ws/TestServiceWSDL_TestServiceV1Http_Service.wsdl</wsdl>
                        <extraargs>
                            <extraarg>-client</extraarg>
                            <extraarg>-server</extraarg>
                            <extraarg>-verbose</extraarg>
                            <extraarg>-p</extraarg>
                            <extraarg>namespace.1=package.1</extraarg>
                            <extraarg>-p</extraarg>
                            <extraarg>namespace.2=package.2</extraarg>
                        </extraargs>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
    <configuration>
        <defaultOptions>
            <autoNameResolution>true</autoNameResolution>
        </defaultOptions>
        <extension>true</extension>
        <args>
            <arg>-npa</arg>
        </args>
    </configuration>
</plugin>

【问题讨论】:

    标签: maven wsdl2java


    【解决方案1】:

    我找不到使用 cxf-codegen-plugin 的解决方案,但现在使用:

    <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
            <execution>
                <id>generate-sources</id>
                <phase>generate-sources</phase>
                <configuration>
                    <sourceRoot>target/generated/src/main/java</sourceRoot>
                    <tasks>
                        <taskdef resource="axis-tasks.properties" classpathref="maven.compile.classpath" />
                        <mkdir dir="target/generated/src/main/java" />
                        <axis-wsdl2java output="target/generated/src/main/java" testcase="false"
                            verbose="false"
                            url="ws/TestServiceLookupWSDL_TestServiceLookupV1Http_Service.wsdl">
                            <mapping namespace="namespace.1"
                                package="package.1" />
                            <mapping namespace="namespace.2"
                                package="package.2" />
                        </axis-wsdl2java>
                    </tasks>
                </configuration>
                <goals>
                    <goal>run</goal>
                </goals>
            </execution>
        </executions>
    </plugin>
    

    【讨论】:

      猜你喜欢
      • 2012-06-29
      • 2013-01-06
      • 2014-04-10
      • 1970-01-01
      • 1970-01-01
      • 2015-11-05
      • 1970-01-01
      • 1970-01-01
      • 2011-09-17
      相关资源
      最近更新 更多