我仍然認爲自己對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中自動處理的。我需要對描述符文件做什麼特別的事嗎?如果是這樣,哪些?
謝謝
默認情況下,web服務的HTTPS組件設置爲在端口8181上偵聽。 – Phanto