OPC Studio User's Guide and Reference
BrowseObjects(IEasyUAClient,UAEndpointDescriptor,UANodeDescriptor) Method
Example 



OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA Namespace > IEasyUAClientExtension Class > BrowseObjects Method : BrowseObjects(IEasyUAClient,UAEndpointDescriptor,UANodeDescriptor) Method
The client object that will perform the operation.

This is typically the EasyUAClient object.

The value of this parameter cannot be null (Nothing in Visual Basic).

Endpoint descriptor. Identifies the OPC-UA server.

Because the 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 UAEndpointDescriptor.FromString or UAEndpointDescriptor.FromUri static method instead.

Also, because the OpcLabs.EasyOpc.UA.Discovery.UAApplicationElement and OpcLabs.EasyOpc.UA.Discovery.UADiscoveryElement have an implicit conversion to 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 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 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).

Node descriptor. Identifies the node in OPC server's address space.

Because the 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 UANodeDescriptor.FromString, UANodeDescriptor.FromUABrowsePath, UANodeDescriptor.FromUANodeElement or UANodeDescriptor.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).

Browses the Objects, specifying an endpoint descriptor, and a starting Node Id.
Syntax
'Declaration
 
<ExtensionAttribute()>
<NotNullAttribute()>
Public Overloads Shared Function BrowseObjects( _
   ByVal client As IEasyUAClient, _
   ByVal endpointDescriptor As UAEndpointDescriptor, _
   ByVal nodeDescriptor As UANodeDescriptor _
) As UANodeElementCollection
'Usage
 
Dim client As IEasyUAClient
Dim endpointDescriptor As UAEndpointDescriptor
Dim nodeDescriptor As UANodeDescriptor
Dim value As UANodeElementCollection
 
value = IEasyUAClientExtension.BrowseObjects(client, endpointDescriptor, nodeDescriptor)

Parameters

client
The client object that will perform the operation.

This is typically the EasyUAClient object.

The value of this parameter cannot be null (Nothing in Visual Basic).

endpointDescriptor
Endpoint descriptor. Identifies the OPC-UA server.

Because the 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 UAEndpointDescriptor.FromString or UAEndpointDescriptor.FromUri static method instead.

Also, because the OpcLabs.EasyOpc.UA.Discovery.UAApplicationElement and OpcLabs.EasyOpc.UA.Discovery.UADiscoveryElement have an implicit conversion to 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 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 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
Node descriptor. Identifies the node in OPC server's address space.

Because the 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 UANodeDescriptor.FromString, UANodeDescriptor.FromUABrowsePath, UANodeDescriptor.FromUANodeElement or UANodeDescriptor.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).

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
ExceptionDescription

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.

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.

Remarks

This is an extension method (info: C#, VB.NET). In languages that have support for extensions methods (such as C# and VB.NET), you can use the extension method as if it were a regular method on the object that is its first parameter. In other languages (such as with Python.NET), you will call the extension as a static method, and pass it the object on which it acts as its first parameter.

Example
// This example shows how to obtain objects under the "Server" node in the address space.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-CSharp .
// 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.

using System;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.AddressSpace;
using OpcLabs.EasyOpc.UA.AddressSpace.Standard;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples._EasyUAClient
{
    class BrowseObjects
    {
        public static void Overload2()
        {
            UAEndpointDescriptor endpointDescriptor =
                "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer";
            // or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            // or "https://opcua.demo-this.com:51212/UA/SampleServer/"

            // Instantiate the client object
            var client = new EasyUAClient();

            // Obtain objects under "Server" node.
            UANodeElementCollection nodeElementCollection;
            try
            {
                nodeElementCollection = client.BrowseObjects(endpointDescriptor, UAObjectIds.Server);
            }
            catch (UAException uaException)
            {
                Console.WriteLine($"*** Failure: {uaException.GetBaseException().Message}");
                return;
            }

            // Display results
            foreach (UANodeElement nodeElement in nodeElementCollection)
            {
                Console.WriteLine();
                Console.WriteLine($"nodeElement.DisplayName: {nodeElement.DisplayName}");
                Console.WriteLine($"nodeElement.NodeId: {nodeElement.NodeId}");
                Console.WriteLine($"nodeElement.NodeId.ExpandedText: {nodeElement.NodeId.ExpandedText}");
            }
        }

        // Example output:
        //
        //nodeElement.DisplayName: ServerCapabilities
        //nodeElement.NodeId: Server_ServerCapabilities
        //nodeElement.NodeId.ExpandedText: nsu = http://opcfoundation.org/UA/ ;i=2268
        //
        //nodeElement.DisplayName: ServerDiagnostics
        //nodeElement.NodeId: Server_ServerDiagnostics
        //nodeElement.NodeId.ExpandedText: nsu = http://opcfoundation.org/UA/ ;i=2274
        //
        //nodeElement.DisplayName: VendorServerInfo
        //nodeElement.NodeId: Server_VendorServerInfo
        //nodeElement.NodeId.ExpandedText: nsu = http://opcfoundation.org/UA/ ;i=2295
        //
        //nodeElement.DisplayName: ServerRedundancy
        //nodeElement.NodeId: Server_ServerRedundancy
        //nodeElement.NodeId.ExpandedText: nsu = http://opcfoundation.org/UA/ ;i=2296
        //
        //nodeElement.DisplayName: Namespaces
        //nodeElement.NodeId: Server_Namespaces
        //nodeElement.NodeId.ExpandedText: nsu = http://opcfoundation.org/UA/ ;i=11715
    }
}
# This example shows how to obtain objects under the "Server" node in the address space.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in PowerShell on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-PowerShell .
# 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.

#requires -Version 5.1
using namespace OpcLabs.EasyOpc.UA
using namespace OpcLabs.EasyOpc.UA.AddressSpace.Standard
using namespace OpcLabs.EasyOpc.UA.OperationModel

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUA.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcUAComponents.dll"

[UAEndpointDescriptor]$endpointDescriptor =
    "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
# or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
# or "https://opcua.demo-this.com:51212/UA/SampleServer/"

# Instantiate the client object.
$client = New-Object EasyUAClient

# Obtain objects under "Server" node.
try {
    $nodeElementCollection = [IEasyUAClientExtension]::BrowseObjects($client, 
        $endpointDescriptor, [UAObjectIds]::Server)
}
catch [UAException] {
    Write-Host "*** Failure: $($PSItem.Exception.GetBaseException().Message)"
    return
}

# Display results
foreach ($nodeElement in $nodeElementCollection) {
    Write-Host
    Write-Host "nodeElement.DisplayName: $($nodeElement.DisplayName)"
    Write-Host "nodeElement.NodeId: $($nodeElement.NodeId)"
    Write-Host "nodeElement.NodeId.ExpandedText: $($nodeElement.NodeId.ExpandedText)"
}


# Example output:
#
#nodeElement.DisplayName: ServerCapabilities
#nodeElement.NodeId: Server_ServerCapabilities
#nodeElement.NodeId.ExpandedText: nsu = http://opcfoundation.org/UA/ ;i=2268
#
#nodeElement.DisplayName: ServerDiagnostics
#nodeElement.NodeId: Server_ServerDiagnostics
#nodeElement.NodeId.ExpandedText: nsu = http://opcfoundation.org/UA/ ;i=2274
#
#nodeElement.DisplayName: VendorServerInfo
#nodeElement.NodeId: Server_VendorServerInfo
#nodeElement.NodeId.ExpandedText: nsu = http://opcfoundation.org/UA/ ;i=2295
#
#nodeElement.DisplayName: ServerRedundancy
#nodeElement.NodeId: Server_ServerRedundancy
#nodeElement.NodeId.ExpandedText: nsu = http://opcfoundation.org/UA/ ;i=2296
#
#nodeElement.DisplayName: Namespaces
#nodeElement.NodeId: Server_Namespaces
#nodeElement.NodeId.ExpandedText: nsu = http://opcfoundation.org/UA/ ;i=11715
' This example shows how to obtain objects under the "Server" node in the address space.
'
' Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
' OPC client and subscriber examples in VB.NET on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-VBNET .
' 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.

Imports OpcLabs.EasyOpc.UA
Imports OpcLabs.EasyOpc.UA.AddressSpace
Imports OpcLabs.EasyOpc.UA.AddressSpace.Standard
Imports OpcLabs.EasyOpc.UA.OperationModel

Namespace _EasyUAClient
    Friend Class BrowseObjects
        Public Shared Sub Overload2()

            ' Define which server we will work with.
            Dim endpointDescriptor As UAEndpointDescriptor =
                    "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
            ' or "http://opcua.demo-this.com:51211/UA/SampleServer" (currently not supported)
            ' or "https://opcua.demo-this.com:51212/UA/SampleServer/"

            ' Instantiate the client object
            Dim client = New EasyUAClient()

            ' Obtain objects under "Server" node
            Dim nodeElementCollection As UANodeElementCollection
            Try
                nodeElementCollection = client.BrowseObjects(endpointDescriptor, UAObjectIds.Server)
            Catch uaException As UAException
                Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message)
                Exit Sub
            End Try

            ' Display results
            For Each nodeElement As UANodeElement In nodeElementCollection
                Console.WriteLine()
                Console.WriteLine("nodeElement.NodeId: {0}", nodeElement.NodeId)
                Console.WriteLine("nodeElement.DisplayName: {0}", nodeElement.DisplayName)
            Next nodeElement

            ' Example output:
            '
            'nodeElement.NodeId: nsu=http://opcfoundation.org/UA/;i=2268
            'nodeElement.DisplayName: ServerCapabilities
            '
            'nodeElement.NodeId: nsu=http://opcfoundation.org/UA/;i=2274
            'nodeElement.DisplayName: ServerDiagnostics
            '
            'nodeElement.NodeId: nsu=http://opcfoundation.org/UA/;i=2295
            'nodeElement.DisplayName: VendorServerInfo
            '
            'nodeElement.NodeId: nsu=http://opcfoundation.org/UA/;i=2296
            'nodeElement.DisplayName: ServerRedundancy
        End Sub
    End Class
End Namespace
// This example shows how to obtain objects under the "Server" node
// in the address space.
//
// 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 BrowseObjects.Main;
var
  Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient;
  Count: Cardinal;
  Element: OleVariant;
  EndpointDescriptor: string;
  NodeElement: _UANodeElement;
  NodeElementEnumerator: IEnumVariant;
  NodeElements: _UANodeElementCollection;
  ServerNodeId: _UANodeId;
begin
  EndpointDescriptor := 
    //'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';

  // Instantiate the client object
  Client := CoEasyUAClient.Create;

  // Obtain objects under "Server" node
  ServerNodeId := CoUANodeId.Create;
  ServerNodeId.StandardName := 'Server';
  try
    NodeElements := Client.BrowseObjects(EndpointDescriptor, ServerNodeId.ExpandedText);
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
      Exit;
    end;
  end;

  // Display results
  NodeElementEnumerator := NodeElements.GetEnumerator;
  while (NodeElementEnumerator.Next(1, Element, Count) = S_OK) do
  begin
    NodeElement := IUnknown(Element) as _UANodeElement;
    WriteLn;
    WriteLn('nodeElement.NodeId: ', NodeElement.NodeId.ToString);
    WriteLn('nodeElement.NodeId.ExpandedText: ', NodeElement.NodeId.ExpandedText);
    WriteLn('nodeElement.DisplayName: ', NodeElement.DisplayName);
  end;

  // Example output:
  //
  //nodeElement.NodeId: Server_ServerCapabilities
  //nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2268
  //nodeElement.DisplayName: ServerCapabilities
  //
  //nodeElement.NodeId: Server_ServerDiagnostics
  //nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2274
  //nodeElement.DisplayName: ServerDiagnostics
  //
  //nodeElement.NodeId: Server_VendorServerInfo
  //nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2295
  //nodeElement.DisplayName: VendorServerInfo
  //
  //nodeElement.NodeId: Server_ServerRedundancy
  //nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2296
  //nodeElement.DisplayName: ServerRedundancy
  //
  //nodeElement.NodeId: Server_Namespaces
  //nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=11715
  //nodeElement.DisplayName: Namespaces

end;
// This example shows how to obtain objects under the "Server" node
// in the address space.
//
// 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";

// Instantiate the client object
$Client = new COM("OpcLabs.EasyOpc.UA.EasyUAClient");

// Obtain variables under "Server" node
$ServerNodeId = new COM("OpcLabs.EasyOpc.UA.AddressSpace.UANodeId");
$ServerNodeId->StandardName = "Server";

try
{
    $NodeElements = $Client->BrowseObjects($EndpointDescriptor, $ServerNodeId->ExpandedText);
}
catch (com_exception $e)
{
    printf("*** Failure: %s\n", $e->getMessage());
    exit();
}

// Display results
foreach ($NodeElements as $NodeElement)
{
    printf("\n");
    printf("nodeElement.NodeId: %s\n", $NodeElement->NodeId);
    printf("nodeElement.NodeId.ExpandedText: %s\n", $NodeElement->NodeId->ExpandedText);
    printf("nodeElement.DisplayName: %s\n", $NodeElement->DisplayName);
}

// Example output:
//
//nodeElement.NodeId: Server_ServerCapabilities
//nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2268
//nodeElement.DisplayName: ServerCapabilities
//
//nodeElement.NodeId: Server_ServerDiagnostics
//nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2274
//nodeElement.DisplayName: ServerDiagnostics
//
//nodeElement.NodeId: Server_VendorServerInfo
//nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2295
//nodeElement.DisplayName: VendorServerInfo
//
//nodeElement.NodeId: Server_ServerRedundancy
//nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2296
//nodeElement.DisplayName: ServerRedundancy
//
//nodeElement.NodeId: Server_Namespaces
//nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=11715
//nodeElement.DisplayName: Namespaces
REM This example shows how to obtain objects under the "Server" node
REM in the address space.
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 BrowseObjects_Main_Command_Click()
    OutputText = ""

    Dim endpointDescriptor As String
    'endpointDescriptor = "http://opcua.demo-this.com:51211/UA/SampleServer"
    'endpointDescriptor = "https://opcua.demo-this.com:51212/UA/SampleServer/"
    endpointDescriptor = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"

    ' Instantiate the client object
    Dim Client As New EasyUAClient

    ' Obtain objects under "Server" node
    Dim serverNodeId As New UANodeId
    serverNodeId.StandardName = "Server"
    
    On Error Resume Next
    Dim NodeElements As UANodeElementCollection
    Set NodeElements = Client.BrowseObjects(endpointDescriptor, serverNodeId.expandedText)
    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 & vbCrLf
        OutputText = OutputText & "nodeElement.NodeId: " & NodeElement.NodeId & vbCrLf
        OutputText = OutputText & "nodeElement.NodeId.ExpandedText: " & NodeElement.NodeId.expandedText & vbCrLf
        OutputText = OutputText & "nodeElement.DisplayName: " & NodeElement.DisplayName & vbCrLf
    Next
    
    ' Example output:
    '
    'nodeElement.NodeId: Server_ServerCapabilities
    'nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2268
    'nodeElement.DisplayName: ServerCapabilities
    '
    'nodeElement.NodeId: Server_ServerDiagnostics
    'nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2274
    'nodeElement.DisplayName: ServerDiagnostics
    '
    'nodeElement.NodeId: Server_VendorServerInfo
    'nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2295
    'nodeElement.DisplayName: VendorServerInfo
    '
    'nodeElement.NodeId: Server_ServerRedundancy
    'nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2296
    'nodeElement.DisplayName: ServerRedundancy
    '
    'nodeElement.NodeId: Server_Namespaces
    'nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=11715
    'nodeElement.DisplayName: Namespaces
End Sub
Rem This example shows how to obtain objects under the "Server" node in the address space.
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: endpointDescriptor = _
    "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
    '"http://opcua.demo-this.com:51211/UA/SampleServer"  
    '"https://opcua.demo-this.com:51212/UA/SampleServer/"

' Instantiate the client object
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")

' Obtain objects under "Server" node
Dim ServerNodeId: Set ServerNodeId = CreateObject("OpcLabs.EasyOpc.UA.AddressSpace.UANodeId")
ServerNodeId.StandardName = "Server"
On Error Resume Next
Dim NodeElementCollection: Set NodeElementCollection = Client.BrowseObjects(endpointDescriptor, ServerNodeId.ExpandedText)
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 NodeElementCollection
    WScript.Echo 
    WScript.Echo "nodeElement.NodeId: " & NodeElement.NodeId
    WScript.Echo "nodeElement.NodeId.ExpandedText: " & NodeElement.NodeId.ExpandedText
    WScript.Echo "nodeElement.DisplayName: " & NodeElement.DisplayName
Next

' Example output:
'
'nodeElement.NodeId: Server_ServerCapabilities
'nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2268
'nodeElement.DisplayName: ServerCapabilities
'
'nodeElement.NodeId: Server_ServerDiagnostics
'nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2274
'nodeElement.DisplayName: ServerDiagnostics
'
'nodeElement.NodeId: Server_VendorServerInfo
'nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2295
'nodeElement.DisplayName: VendorServerInfo
'
'nodeElement.NodeId: Server_ServerRedundancy
'nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=2296
'nodeElement.DisplayName: ServerRedundancy
'
'nodeElement.NodeId: Server_Namespaces
'nodeElement.NodeId.ExpandedText: nsu=http://opcfoundation.org/UA/ ;i=11715
'nodeElement.DisplayName: Namespaces
# This example shows how to obtain objects under the "Server" node in the address space.
#
# Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .
# OPC client and subscriber examples in Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# 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.
# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.EasyOpc.UA import *
from OpcLabs.EasyOpc.UA.AddressSpace import *
from OpcLabs.EasyOpc.UA.AddressSpace.Standard import *
from OpcLabs.EasyOpc.UA.OperationModel import *


endpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:51210/UA/SampleServer')
# or 'http://opcua.demo-this.com:51211/UA/SampleServer' (currently not supported)
# or 'https://opcua.demo-this.com:51212/UA/SampleServer/'

# Instantiate the client object.
client = EasyUAClient()

# Obtain objects under "Server" node.
try:
    nodeElementCollection = IEasyUAClientExtension.BrowseObjects(client,
                                                                 endpointDescriptor,
                                                                 UANodeDescriptor(UAObjectIds.Server))
except UAException as uaException:
    print('*** Failure: ' + uaException.GetBaseException().Message)
    exit()

# Display results.
for nodeElement in nodeElementCollection:
    print()
    print('nodeElement.DisplayName: ', nodeElement.DisplayName, sep='')
    print('nodeElement.NodeId: ', nodeElement.NodeId, sep='')
    print('nodeElement.NodeId.ExpandedText: ', nodeElement.NodeId.ExpandedText, sep='')

print()
print('Finished.')
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