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



OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA Namespace > IEasyUAClientExtension Class > BrowseMethods Method : BrowseMethods(IEasyUAClient,UAEndpointDescriptor,UANodeDescriptor) Method
The client object that will perform the operation.
Endpoint descriptor. Identifies the OPC-UA server.
Node descriptor. Identifies the node in OPC server's address space.
Browses the Methods in OPC server's address space. Starts from the specified node (or Objects folder), and returns information about child nodes found. Browses the Methods, specifying an endpoint descriptor, and a starting Node Id.
Syntax
'Declaration
 
<ExtensionAttribute()>
<ElementsNotNullAttribute()>
<NotNullAttribute()>
Public Overloads Shared Function BrowseMethods( _
   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.BrowseMethods(client, endpointDescriptor, nodeDescriptor)

Parameters

client
The client object that will perform the operation.
endpointDescriptor
Endpoint descriptor. Identifies the OPC-UA server.
nodeDescriptor
Node descriptor. Identifies the node in OPC server's address space.

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.
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.

Example

.NET

// This example shows how to obtain all method 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 .

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

namespace UADocExamples._EasyUAClient
{
    class BrowseMethods
    {
        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 methods under the specified node.
            UANodeElementCollection nodeElementCollection;
            try
            {
                nodeElementCollection = client.BrowseMethods(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10755");
            }
            catch (UAException uaException)
            {
                Console.WriteLine($"*** Failure: {uaException.GetBaseException().Message}");
                return;
            }

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

        // Example output:
        //ScalarMethod1: nsu = http://test.org/UA/Data/ ;ns=2;i=10756
        //ScalarMethod2: nsu = http://test.org/UA/Data/ ;ns=2;i=10759
        //ScalarMethod3: nsu = http://test.org/UA/Data/ ;ns=2;i=10762
        //ArrayMethod1: nsu = http://test.org/UA/Data/ ;ns=2;i=10765
        //ArrayMethod2: nsu = http://test.org/UA/Data/ ;ns=2;i=10768
        //ArrayMethod3: nsu = http://test.org/UA/Data/ ;ns=2;i=10771
        //UserScalarMethod1: nsu = http://test.org/UA/Data/ ;ns=2;i=10774
        //UserScalarMethod2: nsu = http://test.org/UA/Data/ ;ns=2;i=10777
        //UserArrayMethod1: nsu = http://test.org/UA/Data/ ;ns=2;i=10780
        //UserArrayMethod2: nsu = http://test.org/UA/Data/ ;ns=2;i=10783
    }
}
# This example shows how to obtain all method 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 .

#requires -Version 5.1
using namespace OpcLabs.EasyOpc.UA
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 methods under the specified node.
try {
    $nodeElementCollection = [IEasyUAClientExtension]::BrowseMethods($client, 
        $endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10755")
}
catch [UAException] {
    Write-Host "*** Failure: $($PSItem.Exception.GetBaseException().Message)"
    return
}

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


# Example output:
#
#ScalarMethod1: nsu = http://test.org/UA/Data/ ;ns=2;i=10756
#ScalarMethod2: nsu = http://test.org/UA/Data/ ;ns=2;i=10759
#ScalarMethod3: nsu = http://test.org/UA/Data/ ;ns=2;i=10762
#ArrayMethod1: nsu = http://test.org/UA/Data/ ;ns=2;i=10765
#ArrayMethod2: nsu = http://test.org/UA/Data/ ;ns=2;i=10768
#ArrayMethod3: nsu = http://test.org/UA/Data/ ;ns=2;i=10771
#UserScalarMethod1: nsu = http://test.org/UA/Data/ ;ns=2;i=10774
#UserScalarMethod2: nsu = http://test.org/UA/Data/ ;ns=2;i=10777
#UserArrayMethod1: nsu = http://test.org/UA/Data/ ;ns=2;i=10780
#UserArrayMethod2: nsu = http://test.org/UA/Data/ ;ns=2;i=10783
# This example shows how to obtain all method 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 Python on GitHub: https://github.com/OPCLabs/Examples-QuickOPC-Python .
# 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.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 methods under the specified node.
try:
    nodeElementCollection = IEasyUAClientExtension.BrowseMethods(client,
                                                                 endpointDescriptor,
                                                                 UANodeDescriptor('nsu=http://test.org/UA/Data/ ;i=10755'))
except UAException as uaException:
    print('*** Failure: ' + uaException.GetBaseException().Message)
    exit()

# Display results.
for nodeElement in nodeElementCollection:
    print(nodeElement.BrowseName, ': ', nodeElement.NodeId, sep='')
' This example shows how to obtain all method 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 .

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

Namespace _EasyUAClient
    Friend Class BrowseMethods
        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 methods under the specified node.
            Dim nodeElementCollection As UANodeElementCollection
            Try
                nodeElementCollection = client.BrowseMethods(endpointDescriptor, "nsu=http://test.org/UA/Data/ ;i=10755")
            Catch uaException As UAException
                Console.WriteLine($"*** Failure: {uaException.GetBaseException().Message}")
                Exit Sub
            End Try

            ' Display results
            For Each nodeElement As UANodeElement In nodeElementCollection
                Console.WriteLine($"{nodeElement.BrowseName}: {nodeElement.NodeId}")
            Next nodeElement
        End Sub

        ' Example output:
        'ScalarMethod1 nsu = http  'test.org/UA/Data/ ;ns=2;i=10756
        'ScalarMethod2: nsu = http : 'test.org/UA/Data/ ;ns=2;i=10759
        'ScalarMethod3: nsu = http : 'test.org/UA/Data/ ;ns=2;i=10762
        'ArrayMethod1: nsu = http : 'test.org/UA/Data/ ;ns=2;i=10765
        'ArrayMethod2: nsu = http : 'test.org/UA/Data/ ;ns=2;i=10768
        'ArrayMethod3: nsu = http : 'test.org/UA/Data/ ;ns=2;i=10771
        'UserScalarMethod1: nsu = http : 'test.org/UA/Data/ ;ns=2;i=10774
        'UserScalarMethod2: nsu = http : 'test.org/UA/Data/ ;ns=2;i=10777
        'UserArrayMethod1: nsu = http : 'test.org/UA/Data/ ;ns=2;i=10780
        'UserArrayMethod2: nsu = http : 'test.org/UA/Data/ ;ns=2;i=10783
    End Class
End Namespace
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