首先,我将概述情况。我不会列出我项目的每一类,只列出我认为相关的那些。如果您觉得缺少某些内容,请告诉我,我会添加。
2个项目:
WS
Client
5个类(它们属于WS):
Main.java
User.java
ModuleMain
ModuleSecondary.java
ModuleEmergency.java
User 类具有以下字段:
String username
String password
ModuleMain main
ModuleSecondary secondary
ModuleEmergency emergency
每个“模块”类都有 3 个布尔字段,它们是访问模块的权限。他们是:
boolean canMonitor
boolean canAdd
boolean canRemove
这是 WS 类。此类是发布端点的类:
Endpoint endpoint = Endpoint.create(new UserWs());
//UserWs would be a WebService.
SSLContext ssl = SSLContext.getInstance("SSLv3");
TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
KeyStore jks = KeyStore.getInstance("PKCS12");
jks.load(new FileInputStream(path), pwField.getText().toCharArray());
kmf.init(jks, pwField.getText().toCharArray());
KeyManager[] keyManagers = kmf.getKeyManagers();
tmf.init(jks);
TrustManager[] trustManagers = tmf.getTrustManagers();
ssl.init(keyManagers, trustManagers, new SecureRandom());
HttpsConfigurator configurator = new HttpsConfigurator(ssl);
server = HttpsServer.create(new InetSocketAddress("localhost", 443), 443);
server.setHttpsConfigurator(configurator);
HttpContext context = server.createContext("/ws");
server.start();
endpoint.publish(context);
运行 WebService 后,我使用 wsimport 工具将类导入Client
项目。
wsimport -verbose -Xdebug -keep -p ws.api https://localhost:443/ws?wsdl
这些是我得到的一些课程:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "user", propOrder = {
"moduleMain",
"moduleSecondary",
"moduleEmergency",
"sessionKey",
"username"
})
public class User {
protected ModuleMain main;
protected ModuleSecondary secondary;
protected ModuleEmergency emergency;
protected String username;
//...getters and setters for those fields...//
}
如您所见,密码字段已关闭。但这真的不是问题,问题是生成的Module
类:
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "main")
public class ModuleMain {
}
就是这样。其他Module
类是一样的。他们没有任何方法,所以我无权访问权限字段。我不知道是什么问题,可能是 WSDL,但我不知道如何解决这个问题。
任何帮助是极大的赞赏。抱歉语法错误。