简体   繁体   English

使用wsdl2java / Apache CXF生成Web服务代理类

[英]Generating web service proxy classes using wsdl2java/Apache CXF

I'm trying to generate a web service proxy using the wsdl2java tool that comes with Apache CXF. 我正在尝试使用Apache CXF附带的wsdl2java工具生成Web服务代理。 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.

So I set out to download and install the 2.2 version of the JAX-WS Api. 所以我开始下载并安装2.2版本的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. 我找到了以下安装手册,解释了如何认可这些新文件: http//dcx.sybase.com/1200/en/dbprogramming/httpserver-jaxws-lesson-two.html我按照本指南的每一步,删除了旧的生成的文件和生成的新文件,但问题仍然存在。

Any tips and/or tricks? 任何提示和/或技巧? (now of course, I'm using the -frontend jaxws21 flag to generate the proxy, but still). (当然,我现在使用-frontend jaxws21标志来生成代理,但仍然如此)。

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

This is how I solved the issue using maven: 这就是我使用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>

EDIT: I've found another way to solve this using maven and cxf version 2.7.3. 编辑:我找到了另一种方法来解决这个使用maven和cxf版本2.7.3。 Add these libraries in your dependencies. 在依赖项中添加这些库。 You now dont have to use the jaxws21 option: 您现在不必使用jaxws21选项:

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

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

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