使用wsdl2java / Apache CXF生成Web服务代理类 [英] Generating web service proxy classes using wsdl2java/Apache CXF

查看:125
本文介绍了使用wsdl2java / Apache CXF生成Web服务代理类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Apache CXF附带的wsdl2java工具生成Web服务代理。生成本身似乎很好,但生成的文件中存在一些错误,调用不存在的构造函数。

I'm trying to generate a web service proxy using the wsdl2java tool that comes with Apache CXF. The generation itself seems to go just fine, but there are some errors in the generated files, a non-existing constructor is called.

该文件提供了一个解决方案:

The file offers a solution:

//This constructor requires JAX-WS API 2.2. You will need to endorse the 2.2
//API jar or re-run wsdl2java with "-frontend jaxws21" to generate JAX-WS 2.1
//compliant code instead.

所以我开始下载并安装2.2版本的JAX-WS Api。我找到了以下安装手册,解释了如何认可这些新文件: http://dcx.sybase.com/1200/en/dbprogramming/httpserver-jaxws-lesson-two.html 我按照本指南的每一步,删除了旧生成的文件并生成了新文件,但是问题依然存在。

So I set out to download and install the 2.2 version of the JAX-WS Api. I found the following installation manual explaining how to endorse these new files: http://dcx.sybase.com/1200/en/dbprogramming/httpserver-jaxws-lesson-two.html I followed every step of this guide, removed the old generated files and generated new ones, but the problem persists.

任何提示和/或技巧?
(当然,我现在使用-frontend jaxws21标志生成代理,但仍然)。

Any tips and/or tricks? (now of course, I'm using the -frontend jaxws21 flag to generate the proxy, but still).

推荐答案

<defaultOptions>
    <frontEnd>jaxws21</frontEnd>
</defaultOptions>

这就是我使用maven解决问题的方法:

This is how I solved the issue using maven:

        <plugin>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-codegen-plugin</artifactId>
            <version>2.5.2</version>
            <executions>
                <execution>
                    <id>generate-sources2</id>
                    <configuration>
                        <sourceRoot>${basedir}/target/generated-sources/cxf</sourceRoot>
                        <defaultOptions>
                            <frontEnd>jaxws21</frontEnd>
                        </defaultOptions>
                        <wsdlOptions>
                            <wsdlOption>
                                <wsdl>...</wsdl>
                            </wsdlOption>
                        </wsdlOptions>
                    </configuration>
                    <goals>
                        <goal>wsdl2java</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

编辑:我找到了另一种方法来解决这个问题,使用maven和cxf版本2.7.3。在依赖项中添加这些库。您现在不必使用jaxws21选项:

I've found another way to solve this using maven and cxf version 2.7.3. Add these libraries in your dependencies. You now dont have to use the jaxws21 option:

    <dependency>
        <groupId>javax.xml.ws</groupId>
        <artifactId>jaxws-api</artifactId>
        <version>2.2.9</version>
    </dependency>
    <dependency>
        <groupId>javax.xml.bind</groupId>
        <artifactId>jaxb-api</artifactId>
        <version>2.2.7</version>
    </dependency>

这篇关于使用wsdl2java / Apache CXF生成Web服务代理类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆