美文网首页
java调用OPC-DA出现0x00000005错误

java调用OPC-DA出现0x00000005错误

作者: 少泉一郎 | 来源:发表于2019-12-17 12:36 被阅读0次

使用utgard调用OPC时出现如下异常:

Recieved FAULT
15:36:42.441 [main] DEBUG org.jinterop.dcom.transport.JIComTransport - Socket closed... Socket[unconnected] host 192.168.0.210, port 135
Exception in thread "main" org.jinterop.dcom.common.JIException: Access is denied, please check whether the [domain-username-password] are correct. Also, if not already done please check the GETTING STARTED and FAQ sections in readme.htm. They provide information on how to correctly configure the Windows machine for DCOM access, so as to avoid such exceptions. [0x00000005]
at org.jinterop.dcom.core.JIComServer.init(JIComServer.java:654)
at org.jinterop.dcom.core.JIComServer.initialise(JIComServer.java:561)
at org.jinterop.dcom.core.JIComServer.<init>(JIComServer.java:524)
at org.openscada.opc.lib.list.ServerList.<init>(ServerList.java:51)
at org.openscada.opc.lib.list.ServerList.<init>(ServerList.java:81)
at com.jdrx.iot.opc.da.Test.main(Test.java:15)
Caused by: rpc.FaultException: Received fault. (unknown)
at rpc.ConnectionOrientedEndpoint.call(ConnectionOrientedEndpoint.java:147)
at rpc.Stub.call(Stub.java:134)
at org.jinterop.dcom.core.JIComServer.init(JIComServer.java:649)
... 5 more

解决方法如图

maven依赖:

<dependency>
    <groupId>org.openscada.jinterop</groupId>
    <artifactId>org.openscada.jinterop.core</artifactId>
    <version>2.1.8</version>
</dependency>
<dependency>
    <groupId>org.openscada.jinterop</groupId>
    <artifactId>org.openscada.jinterop.deps</artifactId>
    <version>1.5.0</version>
</dependency>
<dependency>
    <groupId>org.openscada.utgard</groupId>
    <artifactId>org.openscada.opc.dcom</artifactId>
    <version>1.5.0</version>
</dependency>
<dependency>
    <groupId>org.openscada.utgard</groupId>
    <artifactId>org.openscada.opc.lib</artifactId>
    <version>1.5.0</version>
</dependency>

测试代码:

public static void main(String[] args)throws Exception{
    ConnectionInformation ci = new ConnectionInformation();
    ci.setHost("192.168.0.210");
    ci.setDomain("");
    ci.setUser("admin");
    ci.setPassword("123456");
    ci.setClsid("2461FC68-1D4E-11D1-A34D-00A024CDD5E5");
    ci.setClsid("2461FC68-1D4E-11D1-A34D-00A024CDD5E5");
    Server server = new Server(ci,Executors.newSingleThreadScheduledExecutor());
    server.connect();

    //或以下获取OPCEnum方法

        ServerList serverList = new ServerList("192.168.0.210","Administrator","123456","");
        Collection<ClassDetails> classDetails = serverList
                .listServersWithDetails(new Category[] {
                        Categories.OPCDAServer10, Categories.OPCDAServer20,
                        Categories.OPCDAServer30 }, new Category[] {});
        for (ClassDetails cds : classDetails) {
            System.out.println(cds.getProgId() + "=" + cds.getDescription());
        }
    }

相关文章

网友评论

      本文标题:java调用OPC-DA出现0x00000005错误

      本文链接:https://www.haomeiwen.com/subject/qojsnctx.html