OPC Studio User's Guide and Reference
UAQueryApplicationsFilter Class
Members 



OpcLabs.EasyOpcUA Assembly > OpcLabs.EasyOpc.UA.Discovery Namespace : UAQueryApplicationsFilter Class
A filter used to find servers that meet the specified criteria.
Object Model
UAQueryApplicationsFilter ClassUAQueryApplicationsFilter ClassStringCollection Class
Syntax
'Declaration
 
<CLSCompliantAttribute(True)>
<ComDefaultInterfaceAttribute(OpcLabs.EasyOpc.UA.Discovery.ComTypes._UAQueryApplicationsFilter)>
<ComVisibleAttribute(True)>
<GuidAttribute("6A98CE77-1543-4AEA-B80C-AC4ECCFFBF7E")>
<TypeConverterAttribute(System.ComponentModel.ExpandableObjectConverter)>
<ValueControlAttribute("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.80.82.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   DefaultReadWrite=False, 
   Export=True, 
   PageId=10001)>
<SerializableAttribute()>
Public NotInheritable Class UAQueryApplicationsFilter 
   Inherits OpcLabs.BaseLib.Info
   Implements LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.EasyOpc.UA.Discovery.ComTypes._UAQueryApplicationsFilter, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable 
'Usage
 
Dim instance As UAQueryApplicationsFilter
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.UA.Discovery.ComTypes._UAQueryApplicationsFilter)]
[ComVisible(true)]
[Guid("6A98CE77-1543-4AEA-B80C-AC4ECCFFBF7E")]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.80.82.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   DefaultReadWrite=false, 
   Export=true, 
   PageId=10001)]
[Serializable()]
public sealed class UAQueryApplicationsFilter : OpcLabs.BaseLib.Info, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.EasyOpc.UA.Discovery.ComTypes._UAQueryApplicationsFilter, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable  
[CLSCompliant(true)]
[ComDefaultInterface(OpcLabs.EasyOpc.UA.Discovery.ComTypes._UAQueryApplicationsFilter)]
[ComVisible(true)]
[Guid("6A98CE77-1543-4AEA-B80C-AC4ECCFFBF7E")]
[TypeConverter(System.ComponentModel.ExpandableObjectConverter)]
[ValueControl("OpcLabs.BaseLib.Forms.Common.ObjectSerializationControl, OpcLabs.BaseLibForms, Version=5.80.82.1, Culture=neutral, PublicKeyToken=6faddca41dacb409", 
   DefaultReadWrite=false, 
   Export=true, 
   PageId=10001)]
[Serializable()]
public ref class UAQueryApplicationsFilter sealed : public OpcLabs.BaseLib.Info, LINQPad.ICustomMemberProvider, OpcLabs.BaseLib.ComTypes._Info, OpcLabs.BaseLib.ComTypes._Object2, OpcLabs.EasyOpc.UA.Discovery.ComTypes._UAQueryApplicationsFilter, System.ICloneable, System.Runtime.Serialization.ISerializable, System.Xml.Serialization.IXmlSerializable  
Remarks

 

QuickOPC-UA allows you to query information contained in so called OPC-UA Global Discovery Server(s). A Global Discovery Server (GDS) maintains discovery information for OPC UA applications available in an administrative domain.

If you want to retrieve a list of OPC Unified Architecture servers in an administrative domain, call the DiscoverGlobalServers method, passing it the endpoint of the GDS.

In addition, you can call an overload of the DiscoverGlobalServers method that also takes a filter parameter of type UAQueryServerFilter. Using this filter, you can limit the search only to servers that meet the specified criteria. The criteria include:

You can also call the EasyUAClient.DiscoverGlobalServers method that takes no arguments, in which case the endpoint descriptor of the GDS will be taken from the GdsEndpointDescriptor property of the SharedParameters.

In all cases described above, you will receive back a UADiscoveryElementCollection object, which is collection of UADiscoveryElement-s. Each element contains a server's discovery URL. The discovery URL is the main piece of information that you can further use if you want to connect to that OPC-UA server. Each UADiscoveryElement contains information gathered about one OPC server found by the discovery process, including things like the application name, server capabilities, etc.

.NET

// This example shows how to obtain information about OPC UA servers from the Global Discovery Server (GDS).
// The result is flat, i.e. each discovery URL is returned in separate element, with possible repetition of the servers.
//
// 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.Discovery;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples._EasyUAClient
{
    partial class DiscoverGlobalServers
    {
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyUAClient();

            // Obtain collection of application elements.
            UADiscoveryElementCollection discoveryElementCollection;
            try
            {
                discoveryElementCollection = client.DiscoverGlobalServers(
                    "opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer");
            }
            catch (UAException uaException)
            {
                Console.WriteLine($"*** Failure: {uaException.GetBaseException().Message}");
                return;
            }

            // Display results.
            foreach (UADiscoveryElement discoveryElement in discoveryElementCollection)
            {
                Console.WriteLine();
                Console.WriteLine($"Server name: {discoveryElement.ServerName}");
                Console.WriteLine($"Discovery URI string: {discoveryElement.DiscoveryUriString}");
                Console.WriteLine($"Server capabilities: {discoveryElement.ServerCapabilities}");
            }
        }
    }
}
# This example shows how to obtain information about OPC UA servers from the Global Discovery Server (GDS).
# The result is flat, i.e. each discovery URL is returned in separate element, with possible repetition of the servers.
#
# 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.Discovery
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"

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

# Obtain collection of application elements.
try {
    $discoveryElementCollection = [IEasyUAClientExtension]::DiscoverGlobalServers($client,
        "opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer")
}
catch [UAException] {
    Write-Host "*** Failure: $($PSItem.Exception.GetBaseException().Message)"
    return
}

# Display results.
foreach ($discoveryElement in $discoveryElementCollection) {
    Write-Host
    Write-Host "Server name: $($discoveryElement.ServerName)"
    Write-Host "Discovery URI string: $($discoveryElement.DiscoveryUriString)"
    Write-Host "Server capabilities: $($discoveryElement.ServerCapabilities)"
}


# Example output:
#

# This example shows how to obtain information about OPC UA servers from the Global Discovery Server (GDS).
# The result is flat, i.e. each discovery URL is returned in separate element, with possible repetition of the servers.
#
# 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.Discovery import *
from OpcLabs.EasyOpc.UA.OperationModel import *


# Instantiate the client object.
client = EasyUAClient()

# Obtain collection of application elements.
try:
    discoveryElementCollection = IEasyUAClientExtension.DiscoverGlobalServers(client,
        UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer'))
except UAException as uaException:
    print('*** Failure: ' + uaException.GetBaseException().Message)
    exit()

# Display results.
for discoveryElement in discoveryElementCollection:
    print()
    print('Server name: ', discoveryElement.ServerName, sep='')
    print('Discovery URI string: ', discoveryElement.DiscoveryUriString, sep='')
    print('Server capabilities: ', discoveryElement.ServerCapabilities, sep='')

print()
print('Finished.')
' This example shows how to obtain information about OPC UA servers from the Global Discovery Server (GDS).
' The result is flat, i.e. each discovery URL is returned in separate element, with possible repetition of the servers.
'
' 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.Discovery
Imports OpcLabs.EasyOpc.UA.OperationModel

Namespace _EasyUAClient
    Partial Friend Class DiscoverGlobalServers
        Public Shared Sub Main1()
            ' Instantiate the client object
            Dim client = New EasyUAClient()

            ' Obtain collection of application elements
            Dim discoveryElementCollection As UADiscoveryElementCollection
            Try
                discoveryElementCollection = client.DiscoverGlobalServers("opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer")
            Catch uaException As UAException
                Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message)
                Exit Sub
            End Try

            ' Display results
            For Each discoveryElement As UADiscoveryElement In discoveryElementCollection
                Console.WriteLine()
                Console.WriteLine("Server name: {0}", discoveryElement.ServerName)
                Console.WriteLine("Discovery URI string: {0}", discoveryElement.DiscoveryUriString)
                Console.WriteLine("Server capabilities: {0}", discoveryElement.ServerCapabilities)
            Next discoveryElement
        End Sub
    End Class
End Namespace

COM

// This example shows how to obtain information about OPC UA servers from the Global Discovery Server (GDS).
// The result is flat, i.e. each discovery URL is returned in separate element, with possible repetition of the servers.
//
// Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

class procedure DiscoverGlobalServers.Main;
var
  Client: OpcLabs_EasyOpcUA_TLB._EasyUAClient;
  Count: Cardinal;
  Element: OleVariant;
  DiscoveryElement: _UADiscoveryElement;
  DiscoveryElementEnumerator: IEnumVariant;
  DiscoveryElements: _UADiscoveryElementCollection;
begin
  // Instantiate the client object
  Client := CoEasyUAClient.Create;

  // Obtain collection of application elements
  try
    DiscoveryElements := Client.DiscoverGlobalServers('opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer');
  except
    on E: EOleException do
    begin
      WriteLn(Format('*** Failure: %s', [E.GetBaseException.Message]));
      Exit;
    end;
  end;

  // Display results
  DiscoveryElementEnumerator := DiscoveryElements.GetEnumerator;
  while (DiscoveryElementEnumerator.Next(1, Element, Count) = S_OK) do
  begin
    DiscoveryElement := IUnknown(Element) as _UADiscoveryElement;
    WriteLn;
    WriteLn('Server name: ', DiscoveryElement.ServerName);
    WriteLn('Discovery URI string: ', DiscoveryElement.DiscoveryUriString);
    WriteLn('Server capabilities: ', DiscoveryElement.ServerCapabilities.ToString);
  end;
end;
REM This example shows how to obtain information about OPC UA servers from the Global Discovery Server (GDS).
REM The result is flat, i.e. each discovery URL is returned in separate element, with possible repetition of the servers.
REM
REM Find all latest examples here : https://opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .

Public Sub DiscoverGlobalServers_Main_Command_Click()
    OutputText = ""

    ' Instantiate the client object
    Dim Client As New EasyUAClient

    ' Obtain collection of application elements
    On Error Resume Next
    Dim DiscoveryElementCollection As UADiscoveryElementCollection
    Set DiscoveryElementCollection = Client.DiscoverGlobalServers("opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer")
    If Err.Number <> 0 Then
        OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf
        Exit Sub
    End If
    On Error GoTo 0
    
    ' Display results
    Dim DiscoveryElement As UADiscoveryElement: For Each DiscoveryElement In DiscoveryElementCollection
        OutputText = OutputText & vbCrLf
        OutputText = OutputText & "Server name: " & DiscoveryElement.ServerName & vbCrLf
        OutputText = OutputText & "Discovery URI string: " & DiscoveryElement.DiscoveryUriString & vbCrLf
        OutputText = OutputText & "Server capabilities: " & DiscoveryElement.serverCapabilities.ToString & vbCrLf
    Next
End Sub

You can also obtain the results unflattened:

// This example shows how to obtain information about OPC UA servers from the Global Discovery Server (GDS).
// The result is hierarchical, i.e. each server is returned in one element, and the element contains all its discovery URLs.
//
// 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.Discovery;
using OpcLabs.EasyOpc.UA.OperationModel;

namespace UADocExamples._EasyUAClient
{
    partial class DiscoverGlobalServers
    {
        public static void Hierarchical()
        {
            // Instantiate the client object
            var client = new EasyUAClient();

            // Obtain collection of application elements
            UADiscoveryElementCollection discoveryElementCollection;
            try
            {
                discoveryElementCollection = client.DiscoverGlobalServers(
                    "opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer", 
                    flat:false);
            }
            catch (UAException uaException)
            {
                Console.WriteLine("*** Failure: {0}", uaException.GetBaseException().Message);
                return;
            }

            // Display results
            foreach (UADiscoveryElement discoveryElement in discoveryElementCollection)
            {
                Console.WriteLine();
                Console.WriteLine("Server name: {0}", discoveryElement.ServerName);
                Console.WriteLine("Discovery URI strings:");
                foreach (string discoveryUriString in discoveryElement.DiscoveryUriStrings)
                    Console.WriteLine("  {0}", discoveryUriString);
                Console.WriteLine("Server capabilities: {0}", discoveryElement.ServerCapabilities);
                Console.WriteLine("Application URI string: {0}", discoveryElement.ApplicationUriString);
                Console.WriteLine("Product URI string: {0}", discoveryElement.ProductUriString);
            }
        }
    }
}
# This example shows how to obtain information about OPC UA servers from the Global Discovery Server (GDS).
# The result is hierarchical, i.e. each server is returned in one element, and the element contains all its discovery
# URLs.
#
# 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.Discovery import *
from OpcLabs.EasyOpc.UA.OperationModel import *


# Instantiate the client object.
client = EasyUAClient()

# Obtain collection of application elements.
try:
    discoveryElementCollection = IEasyUAClientExtension.DiscoverGlobalServers(client,
        UAEndpointDescriptor('opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer'),
        False) # flat=False
except UAException as uaException:
    print('*** Failure: ' + uaException.GetBaseException().Message)
    exit()

# Display results.
for discoveryElement in discoveryElementCollection:
    print()
    print('Server name: ', discoveryElement.ServerName, sep='')
    print('Discovery URI strings:')
    for discoveryUriString in discoveryElement.DiscoveryUriStrings:
        print('  ', discoveryUriString, sep='')
    print('Server capabilities: ', discoveryElement.ServerCapabilities, sep='')
    print('Application URI string: ', discoveryElement.ApplicationUriString, sep='')
    print('Product URI string: ', discoveryElement.ProductUriString, sep='')

print()
print('Finished.')
' This example shows how to obtain information about OPC UA servers from the Global Discovery Server (GDS).
' The result is hierarchical, i.e. each server is returned in one element, and the element contains all its discovery URLs.
'
' 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.Discovery
Imports OpcLabs.EasyOpc.UA.OperationModel

Namespace _EasyUAClient
    Partial Friend Class DiscoverGlobalServers
        Public Shared Sub Hierarchical()
            ' Instantiate the client object
            Dim client = New EasyUAClient()

            ' Obtain collection of application elements
            Dim discoveryElementCollection As UADiscoveryElementCollection
            Try
                discoveryElementCollection = client.DiscoverGlobalServers( _
                    "opc.tcp://opcua.demo-this.com:58810/GlobalDiscoveryServer",
                    flat:=False)
            Catch uaException As UAException
                Console.WriteLine("*** Failure: {0}", uaException.GetBaseException.Message)
                Exit Sub
            End Try

            ' Display results
            For Each discoveryElement As UADiscoveryElement In discoveryElementCollection
                Console.WriteLine()
                Console.WriteLine("Server name: {0}", discoveryElement.ServerName)
                Console.WriteLine("Discovery URI strings:")
                For Each discoveryUriString As String In discoveryElement.DiscoveryUriStrings
                    Console.WriteLine("  {0}", discoveryUriString)
                Next discoveryUriString
                Console.WriteLine("Server capabilities: {0}", discoveryElement.ServerCapabilities)
                Console.WriteLine("Application URI string: {0}", discoveryElement.ApplicationUriString)
                Console.WriteLine("Product URI string: {0}", discoveryElement.ProductUriString)
            Next discoveryElement
        End Sub
    End Class
End Namespace

In .NET, if you want to connect to the discovered OPC server later in your code by calling other methods, use the built-in conversion of UADiscoveryElement to UAEndpointDescriptor, and pass the resulting object as an endpointDescriptor argument either directly to some other method call.

Note that QuickOPC returns UADiscoveryElementCollection from all OPC UA discovery methods, but the amount of information contained in each returned UADiscoveryElement depends on the discovery approach used. For OPC UA Global Discovery and OPC UA Network Discovery, only following primary properties of each UADiscoveryElement are filled in:

OPC UA Global Discovery Server (GDS) is not part of QuickOPC installation.
The features discussed here, or some of them, may not be available in all editions of the product. Check the Product Editions page for differences between the editions. The trial license has all features enabled (and is limited in period for which it provides valid data), but licenses for specific commercial editions may have functionality limitations.

 

Inheritance Hierarchy

System.Object
   OpcLabs.BaseLib.Object2
      OpcLabs.BaseLib.Info
         OpcLabs.EasyOpc.UA.Discovery.UAQueryApplicationsFilter

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