Ant wsdl2java到Maven wsdl2java convertion

时间:2016-12-01 14:17:42

标签: maven wsdl2java

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

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

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

SKScene

当我将其转换为Maven时,我发现它会生成如下的类。

TestServiceWSDL_TestServiceV1HttpBindingStub.java
TestServiceWSDL_TestServiceV1HttpService.java
TestServiceWSDL_TestServiceV1HttpServiceLocator.java

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

使用的Ant命令:

TestServiceV1_TestServiceWSDLTestServiceV1HttpPort_Client.java
TestServiceV1_TestServiceWSDLTestServiceV1HttpPort_Server.java
TestServiceWSDLTestServiceV1HttpService.java

Maven插件:

<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>

1 个答案:

答案 0 :(得分: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>