OPC Studio User's Guide and Reference
FindGdsRegistrations Method (IEasyUAClientServerApplication)
Example 



OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA.Application Namespace > IEasyUAClientServerApplication Interface : FindGdsRegistrations Method
The endpoint of OPC UA Global Discovery Server (GDS).
Finds all registrations for this application URI in the GDS.
Syntax
'Declaration
 
<ElementsNotNullAttribute()>
<NotNullAttribute()>
Function FindGdsRegistrations( _
   ByVal gdsEndpointDescriptor As UAEndpointDescriptor _
) As IReadOnlyDictionary(Of UANodeId,UAApplicationElement)
'Usage
 
Dim instance As IEasyUAClientServerApplication
Dim gdsEndpointDescriptor As UAEndpointDescriptor
Dim value As IReadOnlyDictionary(Of UANodeId,UAApplicationElement)
 
value = instance.FindGdsRegistrations(gdsEndpointDescriptor)

Parameters

gdsEndpointDescriptor
The endpoint of OPC UA Global Discovery Server (GDS).

Return Value

Returns a dictionary of OpcLabs.EasyOpc.UA.Discovery.UAApplicationElement objects with application registration information, keyed by a OpcLabs.EasyOpc.UA.AddressSpace.UANodeId which is the application ID identifying the registration in the GDS.
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

The identity of the application itself is carried by its application URI, as given by the OpcLabs.EasyOpc.UA.Discovery.UAApplicationElement.ApplicationUriString returned by the OpcLabs.EasyOpc.UA.Application.Extensions.IEasyUAClientServerApplicationExtension.GetApplicationElement. Methods on this interface that manipulate or inspect the GDS registration use the application URI to identify the registration records belonging to this application.

Example

.NET

COM

// Shows how to find all application's registrations in the GDS.
// In order to be able to find the registration, run the example for the RegisterToGds method first.
//
// Find all latest examples here: https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

using System;
using System.Collections.Generic;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.AddressSpace;
using OpcLabs.EasyOpc.UA.Application;
using OpcLabs.EasyOpc.UA.Application.Extensions;
using OpcLabs.EasyOpc.UA.Discovery;
using OpcLabs.EasyOpc.UA.Extensions;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples.Application._IEasyUAClientServerApplication
{
    class FindGdsRegistrations
    {
        public static void Main1()
        {
            // Define which GDS we will work with.
            UAEndpointDescriptor gdsEndpointDescriptor =
                ((UAEndpointDescriptor)"opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer")
                .WithUserNameIdentity("appadmin", "demo");

            // Obtain the application interface.
            EasyUAApplication application = EasyUAApplication.Instance;

            // Display which application we are about to work with.
            Console.WriteLine("Application URI string: {0}",
                application.GetApplicationElement().ApplicationUriString);

            // Find all application's registrations in the GDS.
            IReadOnlyDictionary<UANodeId, UAApplicationElement> applicationElementDictionary;
            try
            {
                applicationElementDictionary = application.FindGdsRegistrations(gdsEndpointDescriptor);
            }
            catch (UAException uaException)
            {
                Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message);
                return;
            }

            // Display results
            foreach (KeyValuePair<UANodeId, UAApplicationElement> pair in applicationElementDictionary)
            {
                Console.WriteLine();
                Console.WriteLine("Application ID: {0}", pair.Key);

                UAApplicationElement applicationElement = pair.Value;
                Console.WriteLine("Application element: {0}", applicationElement);
                Console.WriteLine("  Application URI string: {0}", applicationElement.ApplicationUriString);
                Console.WriteLine("  Discovery URI strings: {0}", applicationElement.DiscoveryUriStrings);
                Console.WriteLine("  Product URI string: {0}", applicationElement.ProductUriString);
            }
        }
    }
}
# Shows how to find all application's registrations in the GDS.
# In order to be able to find the registration, run the example for the RegisterToGds method first.
#
# 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.Application import *
from OpcLabs.EasyOpc.UA.Application.Extensions import *
from OpcLabs.EasyOpc.UA.Extensions import *
from OpcLabs.EasyOpc.UA.OperationModel import *


# Define which GDS we will work with.
gdsEndpointDescriptor = UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer')
gdsEndpointDescriptor = UAEndpointDescriptorExtension.WithUserNameIdentity(gdsEndpointDescriptor,
                                                                           'appadmin', 'demo')

# Obtain the application interface.
application = EasyUAApplication.Instance

# Display which application we are about to work with.
applicationElement = IEasyUAClientServerApplicationExtension.GetApplicationElement(application)
print('Application URI string: ', applicationElement.ApplicationUriString, sep='')

# Find all application's registrations in the GDS.
try:
    applicationElementDictionary = application.FindGdsRegistrations(gdsEndpointDescriptor)
except UAException as uaException:
    print('*** Failure: ' + uaException.GetBaseException().Message)
    exit()

# Display results.
for pair in applicationElementDictionary:
    print()
    print('Application ID: ', pair.Key, sep='')

    applicationElement = pair.Value
    print('Application element: ', applicationElement, sep='')
    print('  Application URI string: ', applicationElement.ApplicationUriString, sep='')
    print('  Discovery URI strings: ', applicationElement.DiscoveryUriStrings, sep='')
    print('  Product URI string: ', applicationElement.ProductUriString, sep='')

print()
print('Finished.')
' Shows how to find all application's registrations in the GDS.
'
' 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.Application
Imports OpcLabs.EasyOpc.UA.Application.Extensions
Imports OpcLabs.EasyOpc.UA.Discovery
Imports OpcLabs.EasyOpc.UA.Extensions
Imports OpcLabs.EasyOpc.UA.OperationModel

Namespace Application._IEasyUAClientServerApplication
    Friend Class FindGdsRegistrations
        Public Shared Sub Main1()

            ' Define which GDS we will work with.
            Dim gdsEndpointDescriptor As UAEndpointDescriptor =
                New UAEndpointDescriptor("opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer") _
                .WithUserNameIdentity("appadmin", "demo")

            ' Obtain the application interface.
            Dim application As EasyUAApplication = EasyUAApplication.Instance

            ' Display which application we are about to work with.
            Console.WriteLine("Application URI string: {0}",
                application.GetApplicationElement().ApplicationUriString)

            ' Find all application's registrations in the GDS.
            Dim applicationElementDictionary As IReadOnlyDictionary(Of UANodeId, UAApplicationElement)
            Try
                applicationElementDictionary = application.FindGdsRegistrations(gdsEndpointDescriptor)
            Catch uaException As UAException
                Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message)
                Exit Sub
            End Try

            ' Display results
            For Each pair In applicationElementDictionary
                Console.WriteLine()
                Console.WriteLine("Application ID: {0}", pair.Key)

                Dim applicationElement = pair.Value
                Console.WriteLine("Application element: {0}", applicationElement)
                Console.WriteLine("  Application URI string: {0}", applicationElement.ApplicationUriString)
                Console.WriteLine("  Discovery URI strings: {0}", applicationElement.DiscoveryUriStrings)
                Console.WriteLine("  Product URI string: {0}", applicationElement.ProductUriString)
            Next pair
        End Sub
    End Class
End Namespace
// Shows how to find all application's registrations in the GDS.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

class procedure FindGdsRegistrations.Main;
var
  Application: TEasyUAApplication;
  ApplicationElement: _UAApplicationElement;
  ApplicationElementDictionary: _UANodeIdUAApplicationElementReadOnlyDictionary;
  ApplicationId: _UANodeId;
  Count: Cardinal;
  Element: OleVariant;
  Enumerator: IEnumVARIANT;
  GdsEndpointDescriptor: _UAEndpointDescriptor;
begin
  // Define which GDS we will work with.
  GdsEndpointDescriptor := CoUAEndpointDescriptor.Create;
  GdsEndpointDescriptor.UrlString := 'opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer';
  GdsEndpointDescriptor.UserIdentity.UserNameTokenInfo.UserName := 'appadmin';
  GdsEndpointDescriptor.UserIdentity.UserNameTokenInfo.Password := 'demo';

  // Obtain the application interface.
  Application := TEasyUAApplication.Create(nil);

  // Display which application we are about to work with.
  WriteLn('Application URI string: ', Application.GetApplicationElement.ApplicationUriString);

  // Find all application's registrations in the GDS.
  try
    ApplicationElementDictionary := Application.FindGdsRegistrations(GdsEndpointDescriptor);
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
    end;
  end;

  // Display results
  Enumerator := ApplicationElementDictionary.GetEnumerator;
  while (Enumerator.Next(1, Element, Count) = S_OK) do
  begin
    WriteLn;
    ApplicationId := IUnknown(Element.Key) as _UANodeId;
    WriteLn('Application ID: ', ApplicationId.ToString);

    ApplicationElement := IUnknown(Element.Value) as _UAApplicationElement;
    WriteLn('  Application URI string: ', ApplicationElement.ApplicationUriString);
    WriteLn('  Discovery URI string: ', ApplicationElement.DiscoveryUriString);
    WriteLn('  Product URI string: ', ApplicationElement.ProductUriString);
  end;
end;
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