wsimport无法工作

16

当我尝试从命令提示符使用以下命令使用wsimport时,它可以正常工作:

当我尝试使用下面的命令从命令提示符中使用wsimport时,它可以正常工作:

wsimport -d generated C:\Users\generated\wsdlfile.xml

但是,当我尝试使用以下命令wsimport时,它会抛出以下错误:

wsimport -d generated https://example.com/exampleService.svc?wsdl

Failed to read the WSDL document: https://example.com/exampleService.svc?wsdl, because 1) could not find the document; /2) the document could not be read; 3) the root element of the document is not <wsdl:definitions>.

[ERROR] failed.noservice=Could not find wsdl:service in the provided WSDL(s): At least one WSDL with at least one service definition needs to be provided.

        Failed to parse the WSDL.

我可以从浏览器中访问该URL,而且其他系统(来自我的PC)也可以正常工作。可能的原因是什么?

5个回答

16

我已通过禁用所有代理设置来解决 Windows 上的此问题,具体方法如下:

Internet Options > Connections > Lan Settings > Disable all check boxes

注意:仅将本地主机名或我的IP地址添加为代理设置的异常并不适用于我。


这个可以工作,但是有人能解释一下为什么吗?还有其他的解决方法吗? - Twaha Mehmood

4

我遇到了同样的问题,在我的情况下,问题是WSDL文件的编码。

请尝试从浏览器打开https://example.com/exampleService.svc?wsdl。如果可以完全解析,您将看到所有的xml内容。如果不能,至少Firefox会指出问题所在。

希望这对于处于这种状况的人有所帮助。


3

看起来这似乎是您使用的Java版本的问题...

确保您拥有Java版本“1.7.x”以解决此问题。


似乎存在代理问题。 - Kartic

0
尝试将此选项设置为wsimport:-XdisableSSLHostnameVerification,它会在获取wsdl时禁用SSL主机名验证。

0
请使用以下的 pom.xml。
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>2.3</version>
            <configuration>
                <warSourceDirectory>WebContent</warSourceDirectory>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>1.9</version>
            <executions>
                <execution>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <phase>generate-sources</phase>
                </execution>
            </executions>
            <configuration>

                <!-- Keep generated files -->
                <keep>true</keep>
                <!-- Package name -->
                <packageName>org.example.echo.service.skeleton</packageName>
                <!-- generated source files destination -->
                <sourceDestDir>src/main/java</sourceDestDir>

                <wsdlUrls>
                    <wsdlUrl>
                        **http://localhost:8080/soapWebService/services/PersonServiceImpl?wsdl**
                    </wsdlUrl>
                </wsdlUrls>
            </configuration>
        </plugin>
    </plugins>

</build>


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接