Browses the nodes in server's address space, given an endpoint descriptor, node descriptor, and browse parameters.
Syntax
Parameters
- endpointDescriptor
- OpcLabs.EasyOpc.UA.UAEndpointDescriptor. Endpoint descriptor. Identifies the OPC-UA server.
Because the OpcLabs.EasyOpc.UA.UAEndpointDescriptor has implicit conversions from System.String and System.Uri, in languages that support implicit conversion operators (such as C# or VB.NET), you can simply use a string (representing the endpoint URL, or a so-called OPC UA endpoint descriptor string), or a System.Uri object, in place of this parameter, and the corresponding endpoint descriptor will be constructed automatically. When the implicit conversion operators are not supported (such as with Python.NET), you can use the FromString or FromUri static method instead.
Also, because the OpcLabs.EasyOpc.UA.Discovery.UAApplicationElement and OpcLabs.EasyOpc.UA.Discovery.UADiscoveryElement have an implicit conversion to OpcLabs.EasyOpc.UA.UAEndpointDescriptor, in languages that support implicit conversion operators (such as C# or VB.NET), you can simply use a OpcLabs.EasyOpc.UA.Discovery.UAApplicationElement or OpcLabs.EasyOpc.UA.Discovery.UADiscoveryElement (results from OPC UA discovery) in place of this parameter, and the corresponding endpoint descriptor will be constructed automatically. When the implicit conversion operators are not supported (such as with Python.NET), you can convert a (non-null) OpcLabs.EasyOpc.UA.Discovery.UAApplicationElement or OpcLabs.EasyOpc.UA.Discovery.UADiscoveryElement to OpcLabs.EasyOpc.UA.UAEndpointDescriptor using the OpcLabs.EasyOpc.UA.Discovery.UAApplicationElement.ToUAEndpointDescriptor or OpcLabs.EasyOpc.UA.Discovery.UADiscoveryElement.ToUAEndpointDescriptor method instead.
If you are using OPC Wizard (for server development), an implicit conversion from OpcLabs.EasyOpc.UA.EasyUAServerCore can be used in the same way to simply pass the server object in place of this parameter, which will use its OpcLabs.EasyOpc.UA.EasyUAServerCore.EffectiveServerDescriptor property for the connection.
The value of this parameter cannot be null
(Nothing
in Visual Basic).
- nodeDescriptor
- OpcLabs.EasyOpc.UA.UANodeDescriptor. Node descriptor. Identifies the node in OPC server's address space.
Because the OpcLabs.EasyOpc.UA.UANodeDescriptor has implicit conversions from OpcLabs.EasyOpc.UA.AddressSpace.UANodeId, OpcLabs.EasyOpc.UA.AddressSpace.UANodeElement, OpcLabs.EasyOpc.UA.Navigation.UABrowsePath and System.String, in languages that support implicit conversion operators (such as C# or VB.NET), you can simply use a OpcLabs.EasyOpc.UA.AddressSpace.UANodeId object (representing the Id of the OPC UA node), a node element object (from OPC UA browsing), OpcLabs.EasyOpc.UA.Navigation.UABrowsePath object (representing OPC UA absolute browse path), or a string (with expanded node Id text) in place of this parameter, and the corresponding node descriptor will be constructed automatically. When the implicit conversion operators are not supported (such as with Python.NET), you can use the FromString, FromUABrowsePath, FromUANodeElement or FromUANodeId static method instead.
If you are using OPC Wizard (for server development), an implicit conversion from OpcLabs.EasyOpc.UA.NodeSpace.UAServerNode can be used in the same way to simply pass the server node in place of this parameter, which will use its OpcLabs.EasyOpc.UA.NodeSpace.UAServerNode.EffectiveNodeDescriptor property for the operation.
The value of this parameter cannot be null
(Nothing
in Visual Basic).
- browseParameters
- OpcLabs.EasyOpc.UA.UABrowseParameters. Specifies which nodes will be returned.
The value of this parameter cannot be null
(Nothing
in Visual Basic).
Return Value
The method returns a node element collection, which contains
OpcLabs.EasyOpc.UA.AddressSpace.UANodeElement values. Each element contains information about a particular node found.
This method never returns null
(Nothing
in Visual Basic).
The individual elements of the returned value are never null
(Nothing
in Visual Basic).
Exceptions
Exception | Description |
System.ArgumentNullException |
A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.
This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception. |
OpcLabs.EasyOpc.UA.OperationModel.UAException |
The OPC UA operation has failed. This operation exception in uniformly used to allow
common handling of various kinds of errors. The System.Exception.InnerException always contains
information about the actual error cause.
This is an operation error that depends on factors external to your program, and thus cannot be always avoided. Your code must handle it appropriately. |
Example
COM
// This example shows how to obtain nodes under a given node of the OPC-UA address space.
// For each node, it displays its browse name and node ID.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
#include "stdafx.h" // Includes "QuickOpc.h", and other commonly used files
#include "Browse.h"
namespace _EasyUAClient
{
void Browse::Main()
{
// Initialize the COM library
CoInitializeEx(nullptr, COINIT_MULTITHREADED);
{
_UAEndpointDescriptorPtr EndpointDescriptorPtr(__uuidof(UAEndpointDescriptor));
EndpointDescriptorPtr->UrlString =
//L"http://opcua.demo-this.com:51211/UA/SampleServer";
L"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
_UANodeDescriptorPtr NodeDescriptorPtr(__uuidof(UANodeDescriptor));
_UABrowsePathParserPtr BrowsePathParserPtr(__uuidof(UABrowsePathParser));
BrowsePathParserPtr->DefaultNamespaceUriString = L"http://test.org/UA/Data/";
NodeDescriptorPtr->BrowsePath = BrowsePathParserPtr->Parse(L"[ObjectsFolder]/Data/Static/UserScalar");
_UABrowseParametersPtr BrowseParametersPtr(__uuidof(UABrowseParameters));
BrowseParametersPtr->StandardName = L"AllForwardReferences";
// Instantiate the client object
_EasyUAClientPtr ClientPtr(__uuidof(EasyUAClient));
// Perform the operation
_UANodeElementCollectionPtr NodeElementsPtr = ClientPtr->Browse(
static_cast<IDispatch*>(EndpointDescriptorPtr),
static_cast<IDispatch*>(NodeDescriptorPtr),
static_cast<IDispatch*>(BrowseParametersPtr));
// Display results
IEnumVARIANTPtr EnumNodeElementPtr = NodeElementsPtr->GetEnumerator();
_variant_t vNodeElement;
while (EnumNodeElementPtr->Next(1, &vNodeElement, nullptr) == S_OK)
{
const _UANodeElementPtr NodeElementPtr(vNodeElement);
_tprintf(_T("%s: "), (LPCTSTR)CW2CT(NodeElementPtr->BrowseName->ToString));
_tprintf(_T("%s\n"), (LPCTSTR)CW2CT(NodeElementPtr->NodeId->ToString));
vNodeElement.Clear();
}
}
// Release all interface pointers BEFORE calling CoUninitialize()
CoUninitialize();
}
}
// This example shows how to obtain nodes under a given node of the OPC-UA
// address space. For each node, it displays its browse name and node ID.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
class procedure Browse.Main;
var
BrowseParameters: _UABrowseParameters;
BrowsePathParser: _UABrowsePathParser;
Client: EasyUAClient;
Count: Cardinal;
Element: OleVariant;
EndpointDescriptor: _UAEndpointDescriptor;
NodeDescriptor: _UANodeDescriptor;
NodeElement: _UANodeElement;
NodeElementEnumerator: IEnumVariant;
NodeElements: _UANodeElementCollection;
begin
EndpointDescriptor := CoUAEndpointDescriptor.Create;
EndpointDescriptor.UrlString :=
//'http://opcua.demo-this.com:51211/UA/SampleServer';
'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer';
NodeDescriptor := CoUANodeDescriptor.Create;
BrowsePathParser := CoUABrowsePathParser.Create;
BrowsePathParser.DefaultNamespaceUriString := 'http://test.org/UA/Data/';
NodeDescriptor.BrowsePath := BrowsePathParser.Parse('[ObjectsFolder]/Data/Static/UserScalar');
BrowseParameters := CoUABrowseParameters.Create;
BrowseParameters.StandardName := 'AllForwardReferences';
// Instantiate the client object
Client := CoEasyUAClient.Create;
NodeElements := Client.Browse(
EndpointDescriptor,
NodeDescriptor,
BrowseParameters);
NodeElementEnumerator := NodeElements.GetEnumerator;
while (NodeElementEnumerator.Next(1, Element, Count) = S_OK) do
begin
NodeElement := IUnknown(Element) as _UANodeElement;
WriteLn(NodeElement.BrowseName.ToString, ': ', NodeElement.NodeId.ToString);
end;
end;
// This example shows how to obtain nodes under a given node of the OPC-UA
// address space. For each node, it displays its browse name and node ID.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in Object Pascal (Delphi) on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-OP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
class procedure Browse.Main;
var
BrowseParameters: _UABrowseParameters;
BrowsePathParser: _UABrowsePathParser;
Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient;
Count: Cardinal;
Element: OleVariant;
EndpointDescriptor: _UAEndpointDescriptor;
NodeDescriptor: _UANodeDescriptor;
NodeElement: _UANodeElement;
NodeElementEnumerator: IEnumVariant;
NodeElements: _UANodeElementCollection;
begin
EndpointDescriptor := CoUAEndpointDescriptor.Create;
EndpointDescriptor.UrlString :=
//'http://opcua.demo-this.com:51211/UA/SampleServer';
//'https://opcua.demo-this.com:51212/UA/SampleServer/';
'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer';
NodeDescriptor := CoUANodeDescriptor.Create;
BrowsePathParser := CoUABrowsePathParser.Create;
BrowsePathParser.DefaultNamespaceUriString := 'http://test.org/UA/Data/';
NodeDescriptor.BrowsePath := BrowsePathParser.Parse('[ObjectsFolder]/Data/Static/UserScalar');
BrowseParameters := CoUABrowseParameters.Create;
BrowseParameters.StandardName := 'AllForwardReferences';
// Instantiate the client object
Client := CoEasyUAClient.Create;
try
NodeElements := Client.Browse(
EndpointDescriptor,
NodeDescriptor,
BrowseParameters);
except
on E: EOleException do
begin
WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
Exit;
end;
end;
NodeElementEnumerator := NodeElements.GetEnumerator;
while (NodeElementEnumerator.Next(1, Element, Count) = S_OK) do
begin
NodeElement := IUnknown(Element) as _UANodeElement;
WriteLn(NodeElement.BrowseName.ToString, ': ', NodeElement.NodeId.ToString);
end;
end;
// This example shows how to obtain nodes under a given node of the OPC-UA address space.
// For each node, it displays its browse name and node ID.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in PHP on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PHP .
// Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
// a commercial license in order to use Online Forums, and we reply to every post.
$EndpointDescriptor = new COM("OpcLabs.EasyOpc.UA.UAEndpointDescriptor");
$EndpointDescriptor->UrlString =
//"http://opcua.demo-this.com:51211/UA/SampleServer";
//"https://opcua.demo-this.com:51212/UA/SampleServer/";
"opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
$NodeDescriptor = new COM("OpcLabs.EasyOpc.UA.UANodeDescriptor");
$BrowsePathParser = new COM("OpcLabs.EasyOpc.UA.Navigation.Parsing.UABrowsePathParser");
$BrowsePathParser->DefaultNamespaceUriString = "http://test.org/UA/Data/";
$NodeDescriptor->BrowsePath = $BrowsePathParser->Parse("[ObjectsFolder]/Data/Static/UserScalar");
$BrowseParameters = new COM("OpcLabs.EasyOpc.UA.UABrowseParameters");
$BrowseParameters->StandardName = "AllForwardReferences";
// Instantiate the client object
$Client = new COM("OpcLabs.EasyOpc.UA.EasyUAClient");
// Perform the operation
try
{
$NodeElements = $Client->Browse($EndpointDescriptor, $NodeDescriptor, $BrowseParameters);
}
catch (com_exception $e)
{
printf("*** Failure: %s\n", $e->getMessage());
exit();
}
// Display results
foreach ($NodeElements as $NodeElement)
{
printf(" s\n", $NodeElement->BrowseName, $NodeElement->NodeId);
}
# This example shows how to obtain nodes under a given node of the OPC-UA address space.
# For each node, it displays its browse name and node ID.
#
# The Python for Windows (pywin32) extensions package is needed. Install it using "pip install pypiwin32".
# CAUTION: We now recommend using Python.NET package instead. Full set of examples with Python.NET is available!
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
import win32com.client
from pywintypes import com_error
endpointDescriptor = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.UAEndpointDescriptor')
#endpointDescriptor.UrlString = 'http://opcua.demo-this.com:51211/UA/SampleServer'
endpointDescriptor.UrlString = 'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer'
nodeDescriptor = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.UANodeDescriptor')
browsePathParser = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.Navigation.Parsing.UABrowsePathParser')
browsePathParser.DefaultNamespaceUriString = 'http://test.org/UA/Data/'
nodeDescriptor.BrowsePath = browsePathParser.Parse('[ObjectsFolder]/Data/Static/UserScalar')
browseParameters = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.UABrowseParameters')
browseParameters.StandardName = 'AllForwardReferences'
# Instantiate the client object
client = win32com.client.Dispatch('OpcLabs.EasyOpc.UA.EasyUAClient')
# Perform the operation
try:
nodeElements = client.Browse(endpointDescriptor, nodeDescriptor, browseParameters)
except com_error as e:
print('*** Failure: ' + e.args[2][1] + ': ' + e.args[2][2])
exit()
# Display results
for nodeElement in nodeElements:
print(nodeElement.BrowseName, ': ', nodeElement.NodeId)
REM This example shows how to obtain nodes under a given node of the OPC-UA address space.
REM For each node, it displays its browse name and node ID.
REM
REM Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
REM OPC client and subscriber examples in Visual Basic on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VB .
REM Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
REM a commercial license in order to use Online Forums, and we reply to every post.
Public Sub Browse_Main_Command_Click()
OutputText = ""
Dim endpointDescriptor As New UAEndpointDescriptor
endpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
Dim nodeDescriptor As New UANodeDescriptor
Dim BrowsePathParser As New UABrowsePathParser
BrowsePathParser.DefaultNamespaceUriString = "http://test.org/UA/Data/"
Set nodeDescriptor.browsePath = BrowsePathParser.Parse("[ObjectsFolder]/Data/Static/UserScalar")
Dim browseParameters As New UABrowseParameters
browseParameters.StandardName = "AllForwardReferences"
' Instantiate the client object
Dim Client As New EasyUAClient
' Perform the operation
On Error Resume Next
Dim NodeElements As UANodeElementCollection
Set NodeElements = Client.Browse(endpointDescriptor, nodeDescriptor, browseParameters)
If Err.Number <> 0 Then
OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf
Exit Sub
End If
On Error GoTo 0
' Display results
Dim NodeElement: For Each NodeElement In NodeElements
OutputText = OutputText & NodeElement.BrowseName & ": " & NodeElement.NodeId & vbCrLf
Next
End Sub
Rem This example shows how to obtain nodes under a given node of the OPC-UA address space.
Rem For each node, it displays its browse name and node ID.
Rem
Rem Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
Rem OPC client and subscriber examples in VBScript on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBScript .
Rem Missing some example? Ask us for it on our Online Forums, https://www.opclabs.com/forum/index ! You do not have to own
Rem a commercial license in order to use Online Forums, and we reply to every post.
Option Explicit
Dim EndpointDescriptor: Set EndpointDescriptor = CreateObject("OpcLabs.EasyOpc.UA.UAEndpointDescriptor")
EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
Dim NodeDescriptor: Set NodeDescriptor = CreateObject("OpcLabs.EasyOpc.UA.UANodeDescriptor")
Dim BrowsePathParser: Set BrowsePathParser = CreateObject("OpcLabs.EasyOpc.UA.Navigation.Parsing.UABrowsePathParser")
BrowsePathParser.DefaultNamespaceUriString = "http://test.org/UA/Data/"
NodeDescriptor.BrowsePath = BrowsePathParser.Parse("[ObjectsFolder]/Data/Static/UserScalar")
Dim BrowseParameters: Set BrowseParameters = CreateObject("OpcLabs.EasyOpc.UA.UABrowseParameters")
BrowseParameters.StandardName = "AllForwardReferences"
' Instantiate the client object
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")
' Perform the operation
On Error Resume Next
Dim NodeElements: Set NodeElements = Client.Browse(EndpointDescriptor, NodeDescriptor, BrowseParameters)
If Err.Number <> 0 Then
WScript.Echo "*** Failure: " & Err.Source & ": " & Err.Description
WScript.Quit
End If
On Error Goto 0
' Display results
Dim NodeElement: For Each NodeElement In NodeElements
WScript.Echo NodeElement.BrowseName & ": " & NodeElement.NodeId
Next
Requirements
Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows
See Also