gpt4 book ai didi

java - 网比 : How to create a web service client that consumes a SSL protected Metro service?

转载 作者:行者123 更新时间:2023-11-30 09:45:07 27 4
gpt4 key购买 nike

我正尝试在 NetBeans 7.0.1 中向我的应用程序添加 Web 服务引用。 Metro 网络服务受 SSL 保护,并托管在我要运行客户端的同一台计算机上。我正在使用“新 Web 服务客户端”向导,但是当我提交受 SSL 保护的 WSDL 时,我收到以下错误消息:

Problem with downloading wsdl or schema file.

Check the URL, proxy settings, or whether the server is running.

URL: https://192.168.0.200:8181/MyApp/myService?wsdl

Metro 用户指南 - To Secure the Example Web Service Client Application (SSL)状态:

In the step where you are directed to cut and paste the URL of the web service that you want the client to consume into the WSDL URL field, type https :// fully-qualified-hostname:8181 /CalculatorApplication/CalculatorWSService?wsdl (changes indicated in bold) to indicate that this client should reference the web service using the secure port. The first time you access this service, accept the certificate (s1as) when you are prompted. This is the server certificate popping up to confirm its identity to the client.

In some cases, you might get an error dialog telling you that the URL https:// fully-qualified-hostname :8181/CalculatorApplication/CalculatorWSService?wsdl couldn't be downloaded. However, this the correct URL, and it does load when you run the service. So, when this error occurs, repeat the steps that create the Web Service Client using the secure WSDL. The second time, the web service reference is created and you can continue creating the client.

无论我尝试多少次,我仍然会收到相同的错误消息(没有设置代理并且服务器正在运行并部署了服务)。接受证书后,WSDL 将显示在浏览器中。如果我输入基本的 WSDL URL(没有 HTTPS 的那个),向导会接受它并生成客户端。我需要做什么才能完成这项工作?

更新

如果我在不同的机器上运行客户端和服务,这同样适用。我正在使用默认的开发证书。检索器输出:

Error: An I/O error occured. sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target`

我必须在 VMargs 中设置 keystore 和信任库吗?如果我想在包含 Web 服务的同一 Web 应用程序中引用此服务怎么办?

最佳答案

已找到答案 here :

您必须使用以下选项运行 NetBeans:

<NETBEANS_HOME>/bin/netbeans.exe
-J-Djavax.net.ssl.trustStore=<AS_HOME>/domains/domain1/config/cacerts.jks
-J-Djavax.net.ssl.keyStore=<AS_HOME>/domains/domain1/config/keystore.jks
-J-Djavax.net.ssl.trustStorePassword=changeit
-J-Djavax.net.ssl.keyStorePassword=changeit

我实际上在 <NETBEANS_HOME>/etc/netbeans.conf 中设置了那些, 在 netbeans_default_options .但是我仍然遇到错误,这只是导致我能够为受 SSL 保护的服务生成客户端代码。运行一个简单的 WS 调用会导致:

重要编辑 只有在您使用较旧的 JAX-WS 库时才会发生以下情况!

Exception in thread "main" javax.xml.ws.WebServiceException: Cannot find 'https://localhost:8181/myApp/myService?wsdl' wsdl. Place the resource correctly in the classpath.

这可以通过设置客户端 DATASTOREWS_WSDL_LOCATION 来解决。具有如下方法的属性:

private static URL getURL() {
try {
return new URL("https://localhost:8181/myApp/myService?wsdl");
} catch (MalformedURLException ex) {
Logger.getLogger(DataStoreWS_Service.class.getName()).log(Level.SEVERE, null, ex);
return null;
}
}

仅当您为简单的 Java 应用程序生成它时才需要,因为生成的客户端代码因 Java Web 应用程序而异。此外,我无法使用完全限定的主机名(例如我的本地 IP)来使用它。唯一有用的是本地主机。一件重要的事情:不要忘记捆绑与服务端相同的 Metro 库! NB bug report .

关于java - 网比 : How to create a web service client that consumes a SSL protected Metro service?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7583722/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com