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

fua*_*ark 8 java proxy wsdl web-services cxf

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

该文件提供了解决方案:

//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.
Run Code Online (Sandbox Code Playgroud)

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

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

Jan*_*sen 7

<defaultOptions>
    <frontEnd>jaxws21</frontEnd>
</defaultOptions>
Run Code Online (Sandbox Code Playgroud)

这就是我使用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>
Run Code Online (Sandbox Code Playgroud)

编辑:我找到了另一种方法来解决这个使用maven和cxf版本2.7.3.在依赖项中添加这些库.您现在不必使用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>
Run Code Online (Sandbox Code Playgroud)