我創建了I JAX-WS客戶端來調用遠程Web服務。該調用通過SSL隧道執行,並有一箇中間代理。這是該方法調用的代碼:Call Web服務後的XMLStreamReaderException響應
RemoteWSCredentials cred = new RemoteWSCredentials();
cred.setUserid("username");
cred.setPassword("password");
URL url = new URL("https://hostname/webservicelocation"); //the exposed url
System.setProperty("https.proxyHost", "ipHostnameProxy"); //set proxy properties
System.setProperty("https.proxyPort", "portProxy");
try {
SSLContext sslContext = SSLContext.getInstance("SSL"); //instance SSLContext
// set up a TrustManager that trusts everything
sslContext.init(null, new TrustManager[]{new X509TrustManager() {
public X509Certificate[] getAcceptedIssuers() {
return null;
}
public void checkClientTrusted(X509Certificate[] certs,
String authType) {
}
public void checkServerTrusted(X509Certificate[] certs,
String authType) {
}
}}, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(
sslContext.getSocketFactory());
HttpsURLConnection.setDefaultHostnameVerifier(new HostnameVerifier() {
public boolean verify(String arg0, SSLSession arg1) {
return true;
}
});
} catch (KeyManagementException ex) {
System.err.println("KeyManagementException: " + ex.getMessage());
} catch (NoSuchAlgorithmException ex) {
System.err.println("NoSuchAlgorithmException: " + ex.getMessage());
}
RemoteWSService ws = new RemoteWSService(url); //instance WS Service
boolean result = ws.exposedService(cred);
代碼失敗在RemoteWSService WS =新RemoteWSService(URL);. 報告的例外是:
Exception in thread "main" com.sun.xml.internal.ws.streaming.XMLStreamReaderException: XML reader error: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[14,3] Message: The element type "meta" must be terminated by the matching end-tag "".
,它的原因是:
javax.xml.stream.XMLStreamException: ParseError at [row,col]:[14,3] Message: The element type "meta" must be terminated by the matching end-tag "".
現在我不知道在哪裏的網絡服務部署。當我嘗試在本地機器上調用它並調用沒有ssl隧道和代理的測試網址時,代碼工作正常。
有人可以幫我嗎?
嗨達維德。如果這解決了你的問題,你應該把它作爲答案並接受它,所以問題被記錄爲答案。回答你自己的問題很好,這可能會幫助那些得到相同例外的人。 (另外,你得到一些代表)。 – joergl 2013-03-11 05:54:57