Connectivity Software User's Guide and Reference
Examples - OPC UA Specialized - Kepware KEPServerEX - Retrieve all data types

.NET

// This KEPServerEX/UA example shows how to retrieve all sub-types of a given data type, recursively.
//
// Find all latest examples here: https://www.doc-that.com/files/onlinedocs/OPCLabs-ConnectivityStudio/Latest/examples.html .
// OPC client and subscriber examples in C# on GitHub: https://github.com/OPCLabs/Examples-ConnectivityStudio-CSharp .
// Missing some example? Ask us for it on our Online Forums, https://forum.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.BaseLib.OperationModel.Generic;
using OpcLabs.EasyOpc.UA;
using OpcLabs.EasyOpc.UA.AddressSpace.Standard;
using OpcLabs.EasyOpc.UA.Extensions;

namespace UADocExamples.Specialized
{
    partial class Kepware_KEPServerEX_UA
    {
        public static void RetrieveAllDataTypes()
        {
            UAEndpointDescriptor endpointDescriptor = "opc.tcp://localhost:49320";  // default KEPServerEX/UA endpoint 

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

            // Retrieve all sub-types of the 'Structure' data type.
            ValueResult<UANodeDescriptor[]> result = client.RetrieveAllDataTypes(
                endpointDescriptor, UADataTypeIds.Structure);
            // Check if the operation succeeded. Use the ThrowIfFailed method instead if you want exception be thrown.
            if (!result.Succeeded)
            {
                Console.WriteLine("*** Failure: {0}", result.ErrorMessageBrief);
                return;
            }

            // Display results. Note that all node descriptors have node IDs in them; but the default display format shows 
            // the browse paths, which are more readable, when they are available.
            foreach (UANodeDescriptor nodeDescriptor in result.Value)
                Console.WriteLine(nodeDescriptor);
        }
    }
}