Repository navigation
Is there any solution to import nodeset xml file dynamically( using a file upload method call) to opc ua server in C# ? #3379
Type of issue
Current BehaviorCurrently I use the uaNodeSetImported.Import(SystemContext, nodesNodeStateCollection) function to get the Nodestatecollection objects, and then for each NodeState object I call AddPredefinedNode(systemcontext,nodeStateObject) . I also call parentNodeState.AddChild(childNodeState) for each parent-child. When I rebrowse the 'Objects' node(using uaexpert client), I am only able to see the first level objects(objects directly under 'Objects'), but when I expand them, I can't see any children . All the nodes are available in the m_predefinednodes field of the nodemanager with correct references but somehow children are not coming. Although when I explicitly create a method node(using MethodState) with input arguments, and call AddPredefinedNode and objectNode.AddChild(methodnode) methods, I can see them, along with children, after the rebrowse. Please guide! Expected BehaviorThe child nodes should also be visible after the rebrowse. Steps To ReproduceNo response EnvironmentAnything else?No response |
Replies: 1 comment
|
That pattern (top-level objects visible, but expanding them returns nothing, while nodes you create yourself work) usually means the imported namespace is not owned by your node manager. The server routes a Browse to the node manager that owns the NodeId's namespace. The reference from Fixes for 1.5.x:
For the upload use case, 2.0 supports this directly: a running server can load a NodeSet2 from a stream as its own node manager, and reload or remove it later: NodeManagerRegistration registration = await lifecycle.AddRuntimeNodeSetAsync( // INodeManagerLifecycle
new RuntimeNodeSetOptions
{
Sources = [RuntimeNodeSetSource.FromStream("upload", ct => new ValueTask<Stream>(new MemoryStream(bytes)), ["urn:my:model"])]
},
callerContext: null,
ct);Don't run this from inside the Method callback itself: lifecycle operations wait for in-flight requests to drain. Store the uploaded bytes in the callback and start the load right after the call returns. See docs/RuntimeNodeSets.md and docs/NodeManagers.md. Closing as answered. |
That pattern (top-level objects visible, but expanding them returns nothing, while nodes you create yourself work) usually means the imported namespace is not owned by your node manager. The server routes a Browse to the node manager that owns the NodeId's namespace. The reference from
Objectsto your top-level object is stored by the core node manager, so it shows up. But the Browse on the object itself (ns=X) goes to whichever manager owns ns=X, and if that is not yours, it finds nothing. Your method node works because it uses your manager's namespace.Fixes for 1.5.x:
NamespaceUris(the base constructor orSetNamespaces(...)) before…