我创建了I JAX-WS客户端来调用远程Web服务。调用是通过ssl隧道执行的,并且有一个中间代理。这是方法调用的代码:
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 = new RemoteWSService(url);. 报告的例外是:
线程“main”中的异常com.sun.xml.internal.ws.streaming.XMLStreamReaderException:XML reader error:javax.xml.stream.XMLStreamException:[row,col]处的ParseError:[14,3] 消息:元素类型“meta”必须由匹配的结束标记“”终止。
它的原因是:
javax.xml.stream.XMLStreamException:[row,col]处的ParseError:[14,3] 消息:元素类型“meta”必须由匹配的结束标记“”终止。
现在我不知道Web服务的部署位置。当我尝试在我的本地计算机上调用它并调用没有ssl隧道和代理时暴露的测试URL时,代码工作正常。
有人可以帮助我吗?答案 0 :(得分:3)
好吧,我解决了。错误是我调用了一个不完整的URL,例如:我调用了'hostname / webservicelocation';但完整的网址是'hostname / webservicelocation / service / RemoteService';.我不明白为什么抓到了com.sun.xml.internal.ws.streaming.XMLStreamReaderException !!!谢谢大家!!!!再见