Professional OPC
Development Tools


Checking if node exists on server

16 Aug 2019 09:39 #7631 by support
First, as a note, I am not sure that what you refer to as "browse path" is an actual OPC UA browse path - that term has its specific meaning. Browse paths includes a starting node, and a sequence of browse names and references. See e.g. . I think you are probabling referring to an OPC UA node ID with a string identifier that "looks" similar to some kind of browse path.

To the question: You can read an attribute of a node to see if it exists, and check for errors. You should read an attribute that *all* nodes have - I suggest, the UAAttributeId.NodeClass. If you get an exception, you need to test whether it represent a non-exist node, or some other kind of error. To do, you can use the following method:

        static private bool IndicatesNonExistentNode(Exception exception)
            switch (exception)
                case UAStatusCodeException statusCodeException 
                        // The syntax of the node id is not valid.
                        (statusCodeException.StatusCode.CodeBits == UACodeBits.BadNodeIdInvalid) ||
                        // The node id refers to a node that does not exist in the Server address space.
                        (statusCodeException.StatusCode.CodeBits == UACodeBits.BadNodeIdUnknown):
                case UAServiceException serviceException 
                    when (serviceException.ServiceResult == UACodeBits.BadNoMatch):
                    return true;
                    return false;
Note that if the read is done using one of the multiple-operand methods, the exception I am talking about is in the .Exception property of the ValueResult object returned. If you have used a single -operand method, it would throw, and the exception I am talking about will be the .InnerException of the UAException thrown.

We plan to expose a "helper method" to perform such checking in future QuickOPC version.

Best regards

Please Log in or Create an account to join the conversation.

15 Aug 2019 12:55 #7628 by gtan14
Is there a way to see if a node exists given a browse path such as this - Data Type Examples.16 Bit Device.R Registers.Double2? QuickOPC for DA has a method ReadItem() where I can pass in the machine, server and itemid, and for the item id, I'm just passing in that browse path. Does UA have something similar?

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.176 seconds


 Recommend this on Google