我正在嘗試訪問我正在處理的項目的Web服務。我正在使用JAX-WS,並且該應用程序部署在weblogic上。當我嘗試訪問WS,我得到下面的異常:javax.xml.ws.WebServiceException:無法訪問WSDL。迴應:'401:未經授權'
javax.portlet.PortletException: javax.xml.ws.WebServiceException: Failed to access the WSDL at: http://xxx.xxxx.ro:40000/idm/ws/cup?wsdl. It failed with:
Response: '401: Unauthorized' for url: 'http://xxx.xxxx.ro:40000/idm/ws/cup?wsdl'.
at com.bea.portlet.container.PortletStub.processAction(PortletStub.java:346)
at com.bea.portlet.container.AppContainer.invokeProcessAction(AppContainer.java:678)
........
我通過有關問題很多帖子的閱讀,我嘗試了不同類型的權威性的。我試圖在不同的用例中使用BindingProvider,basicHTTPAuth,禁用HostnameVerifier等,但仍然沒有結果。
下面是我的代碼片段,作爲最後的嘗試版本:
Authenticator.setDefault(new Authenticator() {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(
username,
password.toCharArray());
}
});
ComputeUserProfileImplService computeUserProfileImplService = new ComputeUserProfileImplService(
new URL(null, endpointURL, new sun.net.www.protocol.http.Handler()),
new QName("http://xxx.xx.xxxxx.xxxxx.com/",
"ComputeUserProfileImplService"));
ComputeUserProfileImpl computeUserProfile = computeUserProfileImplService
.getComputeUserProfileImplPort();
的ComputeUserProfileImplService代碼如下所示:
private final static URL COMPUTEUSERPROFILEIMPLSERVICE_WSDL_LOCATION;
private final static Logger logger = Logger.getLogger(com.xxxxx.xxxxx.xx.xxxxx.cup.ComputeUserProfileImplService.class.getName());
static {
URL url = null;
try {
URL baseUrl;
baseUrl = com.xxxxx.xxxxx.xx.xxxxx.xxx.ComputeUserProfileImplService.class.getResource("");
url = new URL(baseUrl, "http://xxxx.xxxxx.ro:40000/idm/ws/cup?wsdl");
} catch (MalformedURLException e) {
logger.warning("Failed to create URL for the wsdl Location: 'xxxxxxxxxxxxxxxx', retrying as a local file");
logger.warning(e.getMessage());
}
COMPUTEUSERPROFILEIMPLSERVICE_WSDL_LOCATION = url;
}
對不起更換的聯繫,但我不認可張貼他們,因爲它是一個非常知名的組織。如果你能幫助我一些建議,我將不勝感激。我一直在尋找解決方案,但我卡住了..我無法弄清楚。它應該是適用於我的這個weblogic問題的解決方法......但我無法找到它。如果你需要它,我會發布一些其他片段。希望我對此很清楚。
在此先感謝!