0

这是我的第一篇文章,所以如果我犯了一些错误,我很抱歉。我正在使用 Utgard opc Da Java 库连接到 opc da 服务器。我注意到的是,为了连接到服务器,需要用户名和密码。相反,使用 c#,只需要 url。由于在工作中我们只使用 Java,有没有可能避免插入用户名和密码?那是因为该应用程序将安装到我们不知道任何用户凭据的多台 PC 中。对不起我的英语不好,任何帮助将不胜感激。提前感谢大家

所以,我认为这是可以在短时间内解决的问题。但是,这就是我想要做的:

private final static String host = "localhost";
private final static String domain = "localhost";
private final static String user = "ramserver1";
private final static String password = "ramserver1";
private final static String clsid = "FAFA7034-4C37-401E-BA8E-7162DB0AC278";
private final static String progId = "ThermoElectron.RESULTOPCServerDA.2";
private ConnectionInformation connectionInformation;
private Server server;
public String readValue;
public Group group;

public OpcConnection() throws JIException, UnknownHostException, 
NotConnectedException, DuplicateGroupException {
    this.connectionInformation = new ConnectionInformation();
    this.connectionInformation.setClsid(clsid);
    this.connectionInformation.setDomain(domain);
    this.connectionInformation.setHost(host);
    this.connectionInformation.setUser(user);
    this.connectionInformation.setPassword(password);
    server = new Server(this.connectionInformation, 
    Executors.newSingleThreadScheduledExecutor());
}

基本上,我创建了一个类 OpcConnection:在构造函数中,我初始化了连接所需的参数。我想删除设置用户和密码的行。关于安全性,我将身份验证级别设置为无,如下所示: 身份验证级别

我错过了什么?

4

1 回答 1

0

Utgard 是对 OPC 服务器的 DCOM(通过 JInterop)调用的开源实现,并且因为它不在 Windows 安全上下文中工作,所以它不能使用 Windows 身份验证来进行 DCOM 调用。因此,您应该明确提供 Windows 用户凭据。此外,根据我的经验,Utgard(JInterop) 的 DCOM 实现并不符合所有标准,应谨慎用于生产 OPC 服务器。

于 2021-12-14T07:04:00.913 回答