Missing properties of instances imported from file

Questions regarding the use of the .NET SDK 2.0 for Server or Client development or integration into customer products ...

Moderator: uasdknet

Post Reply
ake
Jr. Member
Jr. Member
Posts: 2
Joined: 14 Nov 2022, 17:01

Missing properties of instances imported from file

Post by ake »

Hi,

I'm trying to get a small OPC-UA server running (in .NET 6, with the .NET SDK 3.1.0 eval license), which should load its complete node set from XML files. I've modified the GettingStarted server example and removed the creation of nodes by code; instead, I'm importing my nodes like this

Code: Select all

    public override void Startup()
        {
            try
            {
                Console.WriteLine("Starting NodeManager.");
                base.Startup();
                InstanceNamespaceIndex = AddNamespaceUri("urn:Testsite:TestNS");
                Console.WriteLine("Loading XML files ...");
                if (!String.IsNullOrEmpty(XmlPath))
                {
                    DirectoryInfo xmlDir = new DirectoryInfo(XmlPath);
                    foreach (FileInfo file in xmlDir.GetFiles("*.xml"))
                    {
                        Console.WriteLine($"   Loading {file} ...");
                        ImportUaNodeset(file);
                    }
                    Console.WriteLine("Done.");
                }
		<--- snip --->
This works just fine and I can run the server and load the following test file:

Code: Select all

<?xml version="1.0" encoding="UTF-8" ?>
<UANodeSet xmlns="http://opcfoundation.org/UA/2011/03/UANodeSet.xsd" xmlns:uax="http://opcfoundation.org/UA/2008/02/Types.xsd">
  <NamespaceUris>
    <Uri>urn:Testsite:TestNS</Uri>
  </NamespaceUris>
  
  <UAObjectType NodeId="ns=1;s=testType" BrowseName="1:testType">
    <DisplayName Locale="en">testType</DisplayName>
    <Description Locale="en">testType</Description>
	<References>
	  <Reference ReferenceType="i=45" IsForward="false">i=58</Reference>
    </References>
  </UAObjectType>
  <UAVariable NodeId="ns=1;s=testType.testProperty" BrowseName="1:testProperty" DataType="i=12" ValueRank="-1">
    <DisplayName Locale="en">testProperty</DisplayName>
    <Description Locale="en">testProperty</Description>
    <References>
      <Reference ReferenceType="i=47" IsForward="false">ns=1;s=testType</Reference>
      <Reference ReferenceType="i=40">i=62</Reference>
      <Reference ReferenceType="i=37">i=78</Reference>
    </References>
    <Value>
      <uax:String>HelloWorld</uax:String>
    </Value>
  </UAVariable>

  <UAObject NodeId="ns=1;s=testInstance" BrowseName="1:testInstance">
    <DisplayName Locale="en">testInstance</DisplayName>
    <Description Locale="en">testInstance</Description>
    <References>
	  <Reference ReferenceType="i=45" IsForward="false">i=85</Reference>
      <Reference ReferenceType="i=40">ns=1;s=testType</Reference>
    </References>
  </UAObject>
  <UAVariable NodeId="ns=1;s=testInstance.testProperty" BrowseName="1:testProperty">
    <Value>
      <String>Test</String>
    </Value>
  </UAVariable>
</UANodeSet>
The problem I'm having is: All nodes are created as expected, except for ns=1;s=testInstance.testProperty, which is simply missing. The testInstance node is created as expected, however. It looks like the "Mandatory" modelling rule defined for ns=1;s=testType.testProperty isn't respected.

Is there a way for me to make sure that the server creates all components of the instances defined in the XML file on or after import?
Last edited by ake on 14 Nov 2022, 17:27, edited 1 time in total.

ake
Jr. Member
Jr. Member
Posts: 2
Joined: 14 Nov 2022, 17:01

Re: Missing properties of instances imported from file

Post by ake »

I should add that I can import the XML file above into Atvise and a test open62541server I wrote and the instance properties are created as expected.
The file itself was created by hand, but later will be created by a custom made application.

User avatar
Support Team
Hero Member
Hero Member
Posts: 3064
Joined: 18 Mar 2011, 15:09

Re: Missing properties of instances imported from file

Post by Support Team »

Hi,

the easiest way to get compliant NodeSetXML2 format files is to use the "UaModeler". It has consistency check and it can identify errors in the XML (more than just schema validation). In you example it seems like your instance has no reference to the parent, and no reference to the type definition. This is required by OPC UA specification (independent of the modelling rule), hence your hand written Nodeset does not comply to the specification.

Use UaModeler to create XML for Unified Automation SDK, use Siemens-tools for Siemens and Atvise-tools for Atvise. It makes no sense to mix tools because there might be additional information, extension, consitency check which is required to import (or to generate code).

When importing your nodeset into UaModeler you will see the errors in the log window. Additionally you should run the consistency check to see even more errors.
Best regards
Unified Automation Support Team

Post Reply