NetBeans:如何创建使用 SSL 保护的 Metro 服务的 Web 服务客户端?
我正在尝试向 NetBeans 7.0.1 中的应用程序添加 Web 服务引用。 Metro Web 服务受 SSL 保护,并托管在我要运行客户端的同一台计算机上。我正在使用“新建 Web 服务客户端”向导,但是当我提交受 SSL 保护的 WSDL 时,收到以下错误消息:
下载 wsdl 或架构文件时出现问题。
检查 URL、代理设置或服务器是否正在运行。
网址:https://192.168.0.200:8181/MyApp/myService?wsdl
用户指南 - 为了保护示例 Web 服务客户端应用程序 (SSL) 指出:
在指示您将希望客户端使用的 Web 服务的 URL 剪切并粘贴到 WSDL URL 字段的步骤中,键入 https://complete-qualified-hostname:8181 /CalculatorApplication/CalculatorWSService? wsdl(以粗体表示的更改)指示该客户端应使用安全端口引用 Web 服务。首次访问此服务时,请在出现提示时接受证书 (s1as)。这是弹出的服务器证书,用于向客户端确认其身份。
在某些情况下,您可能会收到一个错误对话框,告诉您无法下载 URL https:// full-qualified-hostname :8181/CalculatorApplication/CalculatorWSService?wsdl。但是,这是正确的 URL,并且在您运行服务时它会加载。因此,当发生此错误时,请重复使用安全 WSDL 创建 Web 服务客户端的步骤。第二次创建 Web 服务引用,您可以继续创建客户端。
无论我尝试多少次,我仍然收到相同的错误消息(没有设置代理,并且服务器正在运行部署的服务)。接受证书后,WSDL 将显示在浏览器中。如果我输入基本 WSDL URL(不带 HTTPS 的 URL),向导会接受它并生成客户端。我需要做什么才能完成这项工作?
更新
如果我在不同的计算机上运行客户端和服务,这同样适用。我正在使用默认的开发证书。检索器输出:
错误:发生 I/O 错误。 sun.security.validator.ValidatorException:PKIX 路径构建失败:sun.security.provider.certpath.SunCertPathBuilderException:无法找到请求目标的有效证书路径`
我是否必须在 VMargs 中设置 keytore 和 truststore?如果我想在包含 Web 服务的同一个 Web 应用程序中拥有此服务引用,该怎么办?
I am trying to add a web service reference to my application in NetBeans 7.0.1. The Metro webservice is protected with SSL and is hosted on the same computer that I want to run the client on. I am using the 'New Web Service Client' wizard, but when I submit an SSL protected WSDL, I get the following error message:
Problem with downloading wsdl or schema file.
Check the URL, proxy settings, or whether the server is running.
Metro User Guide - To Secure the Example Web Service Client Application (SSL) states:
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.
No matter how many times I try I still get the same error message (there are no proxies set and the server is running with the services deployed). The WSDL gets displayed in browser after accepting the certificate. If I enter the basic WSDL URL (the one without HTTPS), the wizard accepts it and generates the client. What do I need to do to get this work?
UPDATE
The same applies if I run client and service on different machines. I am using the default development certificate. Retriever output:
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`
Do I have to set keytore and truststore in VMargs? What if I want to have this service reference in the same web application that contains the web services?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
此处找到答案:
您必须使用以下选项运行 NetBeans:
我实际上在
/etc/netbeans.conf
中设置了这些选项,在netbeans_default_options
中。不过,我仍然遇到错误,这只是导致我能够为 SSL 保护的服务生成客户端代码。运行一个简单的 WS 调用会产生以下结果:编辑重要 仅当您使用较旧的 JAX-WS 库时才会发生以下情况!
这可以通过使用如下方法设置客户端
DATASTOREWS_WSDL_LOCATION
属性来解决:仅当您为简单的 Java 应用程序生成它时才需要这样做,因为生成的客户端代码与 Java Web 应用程序不同。另外,我无法让它使用完全限定的主机名(例如我的本地 IP)。唯一有效的是本地主机。一件重要的事情:不要忘记捆绑与服务端相同的 Metro 库! 注意错误报告。
Answer found here:
You have to run NetBeans with the following options:
I actually set those in
<NETBEANS_HOME>/etc/netbeans.conf
, innetbeans_default_options
. I still got an error though, this just resulted that I am able to generate client code for SSL protected services. Running a simple WS call results in this:EDIT IMPORTANT The following only happens if you are using the older JAX-WS libraries!
This can be solved by setting the clients
DATASTOREWS_WSDL_LOCATION
property with a method like this:This is needed only if you generate it for a simple Java Application, because the generated client code differs for Java Web Application. Also, I just couldn't get it working with a fully qualified hostname, like my local IP. The only thing that worked was localhost. One important thing: Don't forget to bundle the same Metro libraries as on the service side! NB bug report.