首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >蚁群wsdl2java到Maven wsdl2java变换

蚁群wsdl2java到Maven wsdl2java变换
EN

Stack Overflow用户
提问于 2016-12-01 14:17:41
回答 1查看 964关注 0票数 1

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

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

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

代码语言:javascript
复制
TestServiceWSDL_TestServiceV1HttpBindingStub.java
TestServiceWSDL_TestServiceV1HttpService.java
TestServiceWSDL_TestServiceV1HttpServiceLocator.java

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

代码语言:javascript
复制
TestServiceV1_TestServiceWSDLTestServiceV1HttpPort_Client.java
TestServiceV1_TestServiceWSDLTestServiceV1HttpPort_Server.java
TestServiceWSDLTestServiceV1HttpService.java

如何将我的项目转换为使用Maven构建和生成同名的类?

Ant命令使用:

代码语言:javascript
复制
<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插件:

代码语言:javascript
复制
<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>
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-12-01 22:04:02

我无法找到使用cxf-codegen-plugin的解决方案,但现在使用以下方法解决了这个问题:

代码语言:javascript
复制
<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>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40912940

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档