使用 utgard 读取plc时 出现 org.jinterop.dcom.common.JIException: Access is denied. [0x80070005]

1 篇文章 0 订阅
1 篇文章 0 订阅

在使用utgard通过opcservice读取plc数据时有些opcservice(kingIoservice) 会出现如下错误:

Caused by: org.jinterop.dcom.common.JIRuntimeException: Access is denied.  [0x80070005]
	at org.jinterop.dcom.core.JICallBuilder.readResult(JICallBuilder.java:1077)
	at org.jinterop.dcom.core.JICallBuilder.read(JICallBuilder.java:957)
	at ndr.NdrObject.decode(NdrObject.java:19)
	at rpc.ConnectionOrientedEndpoint.call(ConnectionOrientedEndpoint.java:138)
	at rpc.Stub.call(Stub.java:112)
	at org.jinterop.dcom.core.JIComServer.call(JIComServer.java:870)
	... 6 common frames omitted

解决办法如下:

修改utgard的源码 server.java

 原本的代码如下

 if (this.connectionInformation.getClsid() != null) {
                    this.session = JISession.createSession(this.connectionInformation.getDomain(), this.connectionInformation.getUser(), this.connectionInformation.getPassword());
                    this.session.setGlobalSocketTimeout(socketTimeout);
                    this.comServer = new JIComServer(JIClsid.valueOf(this.connectionInformation.getClsid()), this.connectionInformation.getHost(), this.session);
                } else {
                    if (this.connectionInformation.getProgId() == null) {
                        throw new IllegalArgumentException("Neither clsid nor progid is valid!");
                    }

                    this.session = JISession.createSession(this.connectionInformation.getDomain(), this.connectionInformation.getUser(), this.connectionInformation.getPassword());
                    this.session.setGlobalSocketTimeout(socketTimeout);
                    this.comServer = new JIComServer(JIProgId.valueOf(this.connectionInformation.getProgId()), this.connectionInformation.getHost(), this.session);
                }

修改是只要加上

this.session.useSessionSecurity(true);

修改的代码如下

if ( this.connectionInformation.getClsid () != null )
            {
                this.session = JISession.createSession ( this.connectionInformation.getDomain (), this.connectionInformation.getUser (), this.connectionInformation.getPassword () );
                this.session.setGlobalSocketTimeout ( socketTimeout );
                this.session.useSessionSecurity(true);
                this.comServer = new JIComServer ( JIClsid.valueOf ( this.connectionInformation.getClsid () ), this.connectionInformation.getHost (), this.session );
            }
            else if ( this.connectionInformation.getProgId () != null )
            {
                this.session = JISession.createSession ( this.connectionInformation.getDomain (), this.connectionInformation.getUser (), this.connectionInformation.getPassword () );
                this.session.setGlobalSocketTimeout ( socketTimeout );
                this.session.useSessionSecurity(true);
                this.comServer = new JIComServer ( JIProgId.valueOf ( this.connectionInformation.getProgId () ), this.connectionInformation.getHost (), this.session );
            }

 

评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值