Apache CXF WSDL FileNotFoundException

时间:2012-01-31 16:07:07

标签: java wsdl cxf

这是我用来通过maven和cxf的wsdl2java codegen插件从WSDL生成java代码的插件命令:

<plugin>
    <groupId>org.apache.cxf</groupId>
    <artifactId>cxf-codegen-plugin</artifactId>
    <version>${cxf.version}</version>
    <executions>
        <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <configuration>
                <sourceRoot>${basedir}/target/srcgen</sourceRoot>
                <wsdlOptions>
                    <wsdlOption>
                        <wsdl>${basedir}/src/main/resources/wsdl/ProjectService_1.0.wsdl</wsdl>
                        <serviceName>${ProjectService}</serviceName>
                        <extraargs>
                            <extraarg>-verbose</extraarg>
                            <extraarg>-autoNameResolution</extraarg>
                            <extraarg>-server</extraarg>
                            <extraarg>-impl</extraarg>
                            <extraarg>-p</extraarg>
                            <extraarg>com.company.project</extraarg>

                        </extraargs>
                    </wsdlOption>
                </wsdlOptions>
            </configuration>
            <goals>
                <goal>wsdl2java</goal>
            </goals>
        </execution>
    </executions>
    <dependencies>

        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.8.1</version>
        </dependency>
    </dependencies>
</plugin>

这是我得到的错误:

Caused by: java.io.FileNotFoundException: /C:/workspace/wsdl2java/src/main/resources/wsdl/ProjectService_1.0.wsdl (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(Unknown Source)
    at java.io.FileInputStream.<init>(Unknown Source)
    at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
    at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
    at com.sun.org.apache.xerces.internal.impl.XMLVersionDetector.determineDocVersion(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
    at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)

我做错了什么?是在代码生成命令中还是我需要使用CXF做一些事情来为它提供WSDL?

2 个答案:

答案 0 :(得分:0)

WSDL文件是否存在于此位置?

<wsdl>${basedir}/src/main/resources/wsdl/ProjectService_1.0.wsdl</wsdl>

ie。,C:/workspace/wsdl2java/src/main/resources/wsdl/ProjectService_1.0.wsdl

如果没有,请将WSDL复制到此位置或更改“&lt; wsdl&gt;”值指向WSDL文件。

答案 1 :(得分:0)

解决方案是编辑CXF bean文件中引用的Impl对象,并确保它没有WSDL的硬编码路径。