我创建了 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); 处失败。报告的异常是:
线程“主”com.sun.xml.internal.ws.streaming.XMLStreamReaderException 中的异常:XML 阅读器错误:javax.xml.stream.XMLStreamException:ParseError at [row,col]:[14,3] 消息:元素类型“meta”必须以匹配的结束标签“”结束。
这是由于:
javax.xml.stream.XMLStreamException: ParseError at [row,col]:[14,3] 消息:元素类型“meta”必须由匹配的结束标记“”终止。
现在我不知道 Web 服务部署在哪里。当我尝试在本地机器上调用它并调用没有 ssl 隧道和代理的测试 url 时,代码工作正常。
有人能帮助我吗?