Please consider registering

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Is There A Way to Get The NodeId From A String Path To Node?
January 25, 2024
2:25, EET
Forum Posts: 3
Member Since:
January 20, 2024
sp_UserOfflineSmall Offline


Is there a way to get the NodeId from a path to the node? In their C# client Traegar will let you get to the node with something like “ns=2;s=WI_OPC/Database.FreeSpace” and I’m hoping for something similar. If I browse to the previous example in your ProsysOPCUAClient, it shows up as:
Root > Objects > WI_OPC

I know I can get to it by calling
NodeId rootNodeId = Identifiers.RootFolder;
List references = client.getAddressSpace().browse(rootNodeId);
List references2 = client.getAddressSpace().browse(references.get(0).getNodeId()); // Objects
List references3 = client.getAddressSpace().browse(references2.get(1).getNodeId()); // WI_OPC
NodeId freeSpaceNodeId = references3.get(222).getReferenceTypeId(); // Database.FreeSpace
UaNode node = client.getAddressSpace().getNode(freeSpaceNodeId);
but that seems awfully clumsy, so I assume I’m missing the correct way to do it.


January 25, 2024
9:11, EET
Matti Siponen

Forum Posts: 311
Member Since:
February 11, 2020
sp_UserOfflineSmall Offline


In general, there is no way to get a NodeId from a “String path” to the Node. Some Nodes in some OPC UA Servers might use this type of convention for their NodeIds, but the NodeIds could be just numbers or GUID so you can’t assume this type of logic would always work.

However, there is TranslateBrowsePathsToNodeIds Service(see https://reference.opcfoundation.org/Core/Part4/v105/docs/5.8.4). Various overloads of translateBrowsePathsToNodeIds are available in the com.prosysopc.ua.client.AddressSpace class that can be accessed by calling the getAddressSpace method of UaClient instance. These methods require you to know the BrowsePath to the Node, but if you do know these, then you could use these methods to get the NodeIds. And do note that these Methods can return multiple NodeIds if there are multiple Nodes that match the BrowsePath.

But, it seems to me that you already know that the NodeId is “ns=2;s=WI_OPC/Database.FreeSpace”. Thus, you can just use

NodeId freeSpaceNodeId = new NodeId(2, “WI_OPC/Database.FreeSpace”);


NodeId freeSpaceNodeId = NodeId.parse(“ns=2;s=WI_OPC/Database.FreeSpace”);

to generate the NodeId and then call

UaNode node = client.getAddressSpace().getNode(freeSpaceNodeId);

to get the Node. If you already know the NodeId, there is no need to get it by browsing the AddressSpace starting from the root. Or am I missing something?

Forum Timezone: Europe/Helsinki

Most Users Ever Online: 518

Currently Online:
13 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

hbrackel: 130

pramanj: 86

Francesco Zambon: 78

ibrahim: 75

rocket science: 75

Sabari: 62

kapsl: 57

gjevremovic: 49

Xavier: 43

fred: 41

Member Stats:

Guest Posters: 0

Members: 731

Moderators: 16

Admins: 1

Forum Stats:

Groups: 3

Forums: 15

Topics: 1450

Posts: 6201

Newest Members:

jadadibdin6, DiianaZof, antoniettakarn, Tor, Arktistync, floybateson9, inilarythikibia, celinamcguire5, helenblodo

Moderators: Jouni Aro: 1007, Otso Palonen: 32, Tuomas Hiltunen: 5, Pyry: 1, Petri: 0, Bjarne Boström: 970, Heikki Tahvanainen: 402, Jukka Asikainen: 1, moldzh08: 0, Jimmy Ni: 26, Teppo Uimonen: 21, Markus Johansson: 42, Niklas Nurminen: 0, Matti Siponen: 311, Lusetti: 0, Ari-Pekka Soikkeli: 5

Administrators: admin: 1