0

I have an HTTPS WSDL URL (https://hostname/MyApp/MyApp.svc?wsdl) that needs to be consumed in a Maven project. The certificate on WSDL is expired and is issued to hostname.company.com.

I have following code in Maven pom.xml

<dependencies>
    <dependency>
        <groupId>com.sun.xml.ws</groupId>
        <artifactId>jaxws-rt</artifactId>
        <scope>compile</scope>
        <version>2.1.3</version>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jaxws-maven-plugin</artifactId>
            <version>1.10</version>
            <executions>
                <execution>
                    <goals>
                        <goal>wsimport</goal>
                    </goals>
                    <configuration>
                        <sourceDestDir>${project.build.directory}/generated-sources/jaxws-wsimport</sourceDestDir>                          
                        <wsdlUrls>
                            <wsdlUrl>https://hostname/MyApp/MyApp.svc?wsdl</wsdlUrl>
                        </wsdlUrls>                           
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

When I do a clean and build, I get following error

[jaxws:wsimport]
Processing: https://hostname/MyApp/MyApp.svc?wsdl
jaxws:wsimport args: [-s, C:\WorkspaceNetBeans\Maven\WSTest\target\generated-sources\jaxws-wsimport, -d, C:\WorkspaceNetBeans\Maven\WSTest\target\classes, https://hostname/MyApp/MyApp.svc?wsdl]
parsing WSDL...

java.security.cert.CertificateException: No name matching hostname found

Failed to read the WSDL document: https://hostname/MyApp/MyApp.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>. 

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.

I added the certificate to keystore using keytool utility. What else do I need to do?

4

2 回答 2

1

您可以从 Web 浏览器本地下载 wsdl,然后在该本地文件上运行 wsimport 以生成您的 Java 模型。

于 2012-12-28T17:08:16.413 回答
0

您有可能的选择:

1) 将服务器的证书导入到信任库中,同时确保服务器证书中显示的 CN 名称与您使用的主机名相同。此链接可能会有所帮助:http://bluefoot.info/howtos/how-to-avoid-java-security-cert-certificateexception-no-name-matching-localhost-found/

2) 使用 Netbeans 或 eclipse 之类的工具,它可以忽略(尽管我对此表示怀疑)服务器的 SSL 方面。

3) 创建一个本地版本的 WSDL,解析所有相关的 XSD 引用并使用该 WSDL。

于 2012-12-28T17:57:20.457 回答