2012-06-26 122 views
1

我仍然認爲自己對Java web服務不熟悉,並且遇到了一個我無法克服的真正障礙。無狀態Web服務在GlassFish 3.1的HTTPS中不起作用

我想部署一個@Stateless Web服務並通過https訪問它的WSDL。每當我試圖訪問它,我得到在瀏覽器中出現以下錯誤:

Error generating artifacts for the following WSDL https://localhost:8181/TestService/Test?WSDL 

Possible causes can be invoking https when the application is not configured for security 

該控制檯顯示以下錯誤:

INFO: parsing WSDL... 

WARNING: Invalid request scheme for Endpoint Test. Expected http . Received https 
INFO: [ERROR] Premature end of file. 
INFO: line 1 of https://localhost:8181/TestService/Test?WSDL 
WARNING: Invalid request scheme for Endpoint Test. Expected http . Received https 
WARNING: MEX0008:Failed to parse metadata returned from server at https://localhost:8181/TestService/Test?WSDL using protocol SOAP_1_2. Continuing attempts. 
WARNING: Invalid request scheme for Endpoint Test. Expected http . Received https 
WARNING: MEX0008:Failed to parse metadata returned from server at https://localhost:8181/TestService/Test?WSDL using protocol SOAP_1_1. Continuing attempts. 
WARNING: Invalid request scheme for Endpoint Test. Expected http . Received https 
WARNING: MEX0008:Failed to parse metadata returned from server at https://localhost:8181/TestService/Test?WSDL/mex using protocol SOAP_1_2. Continuing attempts. 
WARNING: Invalid request scheme for Endpoint Test. Expected http . Received https 
WARNING: MEX0008:Failed to parse metadata returned from server at https://localhost:8181/TestService/Test?WSDL/mex using protocol SOAP_1_1. Continuing attempts. 
INFO: [ERROR] Premature end of file. 
Failed to read the WSDL document: https://localhost:8181/TestService/Test?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>. 
INFO: [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. 
INFO: Failed to parse the WSDL. 
INFO: Invoking wsimport with https://localhost:8181/TestService/Test?WSDL 
SEVERE: wsimport failed 

再次,這是ONLY發生訪問過當HTTPS 。普通的HTTP很好。但是,如果我要刪除@Stateless註釋,則它可以在https上正常工作。當我添加@Stateless註釋時失敗。

我需要@Stateless註釋,因爲我將使用JMS隊列,並且在執行此操作時需要它。

下面是我的類代碼:

package service.test; 

import javax.ejb.Stateless; 
import javax.jws.WebMethod; 
import javax.jws.WebService; 

@Stateless 
@WebService 
public class Test 
{ 
    public String hello() 
    { 
     return "Hello!"; 
    } 

    @WebMethod 
    public int addNumbers(int number1, int number2) 
    { 
     return number1 + number2; 
    } 
} 

到目前爲止,在這一點上,我從來不需要使用任何網頁的描述。我所做的一切都是默認在Eclipse中自動處理的。我需要對描述符文件做什麼特別的事嗎?如果是這樣,哪些?

謝謝

回答

0

這是我從來沒有真正想通了事業的奇怪問題。奇怪的是,這個問題最終不需要@Stateless

0

默認情況下Https使用端口443。如果您的web服務正在偵聽端口8181,它將不會看到https請求。

+0

默認情況下,web服務的HTTPS組件設置爲在端口8181上偵聽。 – Phanto

0

只是瘋狂的猜測:你的信任存儲中有你的服務器證書頒發者嗎?這可能是一個醜陋的問題。 (雖然這工作沒有@Stateless其實那種違背了我的理論)

只是一個猜測...

+0

我正在使用自簽名證書。我有一個與我的常規密鑰庫相同的信任庫。奇怪的是,我能夠使用JMS隊列而不需要'@ Stateless',這很奇怪,因爲我過去總是需要它...... – Phanto