2011-09-28 42 views
2

我想在NetBeans 7.0.1中的應用程序中添加一個Web服務引用。 Metro web服務使用SSL進行保護,並託管在我想運行客戶端的同一臺計算機上。我現在用的是「新的Web服務客戶端」嚮導,但是當我提交SSL保護的WSDL,我收到以下錯誤信息:NetBeans:如何創建使用SSL保護的Metro服務的Web服務客戶端?

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的URL),該向導會接受它並生成客戶端。我需要做些什麼才能完成這項工作?

UPDATE

同樣的,如果我在不同的機器上運行客戶端和服務應用。我正在使用默認的開發證書。 Retriever輸出:

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中設置keytore和truststore嗎?如果我想在包含Web服務的相同Web應用程序中使用此服務引用,該怎麼辦?

+0

我懷疑服務器證書不在客戶端信任存儲區,並且ssl握手失敗。 – Zaki

+0

@ Zaki'第一次訪問此服務時,請在提示時接受證書(s1as)。「這不會發生,我收到錯誤消息。我在.NET中創建了一個工作的客戶端,並且在嚮導中輸入WSDL URL後它確實提示。 –

回答

2

答發現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一起工作。唯一有效的是localhost。一件重要的事情:不要忘記捆綁與服務端相同的Metro庫! NB bug report