client addnode failed

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

Moderator: uasdknet

Post Reply
junchen
Full Member
Full Member
Posts: 9
Joined: 12 Mar 2014, 05:21

client addnode failed

Post by junchen »

hi

when I have tried to add a node to NET Demo Server , it return error status of BadUserAccessDenied. I have overwritten HasAccessToAddNode() in demonodemanager so that it returns true always. It still can't work. after client send request of adding nodes, server doesn't call hasAccessToAddNode(). I have login server as anonynmous user.

thanks

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

Re: client addnode failed

Post by Support Team »

HI,

http://documentation.unified-automation ... mple5.html

We tried to reproduce the issue. We overrided the "HasAccessToAddNode" method.

Code: Select all

        protected override bool HasAccessToAddNode(RequestContext context, BrowseHandle parent, NodeId referenceTypeId, NodeId typeDefinitionId)
        {
            return true;
        }
When calling the AddNodes method with a client, this HasAccessToAddNode method from the server is called and adding nodes works.

Maybe there is a problem with your client side code. An error could be that the RequestedNewNodeId for the node has a wrong NamespaceIndex.

Best regards
Support Team

junchen
Full Member
Full Member
Posts: 9
Joined: 12 Mar 2014, 05:21

Re: client addnode failed

Post by junchen »

what is your test server? I have used .net demo server, add override function HasAccessToAddNode() in demonodemanager.cs.
in my client code, it looks like codes in client get started solution.

the adding node code section is

AddNodesItem nodeToAdd = new AddNodesItem()
{
ParentNodeId = NodeId.Parse(ParentIdTB.Text),
ReferenceTypeId = NodeId.Parse(ReferenceTypeIdTB.Text),
NodeClass = (NodeClass)NodeClassCB.SelectedItem,
BrowseName = new QualifiedName(BrowseNameTB.Text, 1) // namesapceindex is 1, can't know what is the right namespaceindex?
};

switch (nodeToAdd.NodeClass)
{
case NodeClass.Object:
{
nodeToAdd.TypeDefinition = NodeId.Parse(TypeDefinitionIdTB.Text);

nodeToAdd.NodeAttributes = new ExtensionObject(new ObjectAttributes()
{
SpecifiedAttributes = (uint)(NodeAttributesMask.DisplayName),
DisplayName = BrowseNameTB.Text
});

break;
}

case NodeClass.Variable:
{
nodeToAdd.TypeDefinition = NodeId.Parse(TypeDefinitionIdTB.Text);

nodeToAdd.NodeAttributes = new ExtensionObject(new VariableAttributes()
{
SpecifiedAttributes = (uint)(NodeAttributesMask.DataType | NodeAttributesMask.ValueRank | NodeAttributesMask.DisplayName),
DisplayName = BrowseNameTB.Text,
DataType = NodeId.Parse(DataTypeIdTB.Text),
ValueRank = (int)ValueRankCB.SelectedItem
});

break;
}
}

List<AddNodesItem> nodesToAdd = new List<AddNodesItem>();
nodesToAdd.Add(nodeToAdd);

// add the node.
List<AddNodesResult> results = session.AddNodes(nodesToAdd, null);


thanks

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

Re: client addnode failed

Post by Support Team »

Hello,

You have to specify the RequestedNewNodeId.
Depending on the NamespaceIndex of this NodeId the NodeManager is selected that has to add the node.
If you want to add a node to the Demo NodeManager in UaDemoServer the NamespaceIndex of the RequestedNewNodeId must be equal to the NamespaceIndex of this NodeManager. The HasAccessToAddNode is only called for the selected NodeManager.

Code: Select all

ushort DemoNsIdx = (ushort) session.NamespaceUris.IndexOf("http://www.unifiedautomation.com/DemoServer/");
//...
new AddNodesItem()
{
//...
    RequestedNewNodeId = new NodeId("AddedNodeIdentifier", DemoNsIdx);
//...
}

Best regards
Support Team

Post Reply