View Issue Details

IDProjectCategoryView StatusLast Update
0008788Core ComponentsImplementation Bugpublic2023-04-12 01:59
Reporterharvey Assigned To 
PriorityimmediateSeverityblockReproducibilityalways
Status newResolutionopen 
Summary0008788: Failed with error 'BadTooManyArguments' when call a method which generated by Opc.Ua.Export.UANodeSet
Description

I got an error 'BadTooManayArguments' when call a method which generated by Opc.Ua.Export.UANodeSet.
Reason is InputArguments of this method node is not generated, but we set argument in nodeSet.xml.

I put details to 'Steps to Reproduce', could you please help to review and let me know how to fix this issue?

Here is a link that someone else met this issue before.
https://github.com/OPCFoundation/UA-.NETStandard/issues/546

Steps To Reproduce

I have a nodeSet.xml like below.
+++++++++++++++++ nodeSet.xml - Begin +++++++++++++++++++++++
<UAMethod ParentNodeId="ns=1;i=1003" NodeId="ns=1;i=7001" BrowseName="1:TransferData">
<DisplayName>TransferData</DisplayName>
<References>
<Reference ReferenceType="HasModellingRule">i=78</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=6001</Reference>
<Reference ReferenceType="HasProperty">ns=1;i=6002</Reference>
<Reference ReferenceType="HasComponent" IsForward="false">ns=1;i=1003</Reference>
</References>
</UAMethod>
<UAVariable DataType="Argument" ParentNodeId="ns=1;i=7001" ValueRank="1" NodeId="ns=1;i=6001" ArrayDimensions="1" BrowseName="InputArguments">
<DisplayName>InputArguments</DisplayName>
<References>
<Reference ReferenceType="HasTypeDefinition">i=68</Reference>
<Reference ReferenceType="HasModellingRule">i=78</Reference>
<Reference ReferenceType="HasProperty" IsForward="false">ns=1;i=7001</Reference>
</References>
<Value>
<uax:ListOfExtensionObject>
<uax:ExtensionObject>
<uax:TypeId>
<uax:Identifier>i=297</uax:Identifier>
</uax:TypeId>
<uax:Body>
<uax:Argument>
<uax:Name>Data</uax:Name>
<uax:DataType>
<uax:Identifier>i=15</uax:Identifier>
</uax:DataType>
<uax:ValueRank>-1</uax:ValueRank>
<uax:ArrayDimensions/>
<uax:Description/>
</uax:Argument>
</uax:Body>
</uax:ExtensionObject>
</uax:ListOfExtensionObject>
</Value>
</UAVariable>
+++++++++++++++++ nodeSet.xml - End +++++++++++++++++++++++

Then I use Opc.Ua.Export.UANodeSet to read this nodeSet.xml and convert to NodeStateCollection, like below.
+++++++++++++++++ Load xml - Begin +++++++++++++++++++++++
private void ImportXml(IDictionary<NodeId, IList<IReference>> externalReferences, string resourcepath)
{
NodeStateCollection predefinedNodes = new NodeStateCollection();

        Stream stream = new FileStream(resourcepath, FileMode.Open);
        Opc.Ua.Export.UANodeSet nodeSet = Opc.Ua.Export.UANodeSet.Read(stream);

        foreach (string namespaceUri in nodeSet.NamespaceUris)
            {
                SystemContext.NamespaceUris.GetIndexOrAppend(namespaceUri);
            }

        nodeSet.Import(SystemContext, predefinedNodes);

        for (int ii = 0; ii &lt; predefinedNodes.Count; ii++)
        {
            AddPredefinedNode(SystemContext, predefinedNodes[ii]);
        }
        // ensure the reverse refernces exist.
        AddReverseReferences(externalReferences);
    }

+++++++++++++++++ Load xml - End +++++++++++++++++++++++

We can see the import function, for UAMethod, it just create a new methodState but not add InputArguments.
+++++++++++++++++ Import UAMethod - Begin +++++++++++++++++++++++
case NodeClass.Method:
{
UAMethod uAMethod = (UAMethod)node;
nodeState = new MethodState(null)
{
Executable = uAMethod.Executable,
UserExecutable = uAMethod.Executable,
MethodDeclarationId = ImportNodeId(uAMethod.MethodDeclarationId, context.NamespaceUris, lookupAlias: true)
};
break;
}
+++++++++++++++++ Import UAMethod - End+++++++++++++++++++++++

TagsBadTooManyArguments, UANodeSet

Activities

There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2023-04-12 01:59 harvey New Issue
2023-04-12 01:59 harvey Tag Attached: BadTooManyArguments
2023-04-12 01:59 harvey Tag Attached: UANodeSet