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

使用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.(JIComServer.java:524)
at org.openscada.opc.lib.list.ServerList.(ServerList.java:51)
at org.openscada.opc.lib.list.ServerList.(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依赖:


    org.openscada.jinterop
    org.openscada.jinterop.core
    2.1.8


    org.openscada.jinterop
    org.openscada.jinterop.deps
    1.5.0


    org.openscada.utgard
    org.openscada.opc.dcom
    1.5.0


    org.openscada.utgard
    org.openscada.opc.lib
    1.5.0

测试代码:

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 = 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错误)