Skip to content

Read complex structure #198

Open
Open
@friko16

Description

@friko16

Can someone help ? I am sitting on this for days and can't figure out how to read a non-leaf, complex data structure:


 ReadValueId[] nodesToRead = new ReadValueId[1];
 NodeId nodeId = new NodeId(3, "\"Trace\".\"DataRead\".\"TP\"[0]");
 nodesToRead[i] = new ReadValueId(nodeId, Attributes.Value, null,null);
 ReadRequest req = new ReadRequest(null, maxAge, TimestampsToReturn.Both, nodesToRead);
 ReadResponse res = connection.getSession().Read(req);

this data structure when viewed in UAExpert expands into multiple leaf nodes with String and boolean leafs.

and I am getting and exception:

Exception in thread "main" org.opcfoundation.ua.common.ServiceResultException: Bad_InternalError (code=0x80020000, description="2147614720, namespaceUri; value=TE_"Trace"."DataRead"."TP"")
	at org.opcfoundation.ua.transport.tcp.io.TcpConnection$ReadThread.run(TcpConnection.java:1193)
Caused by: java.lang.NullPointerException: namespaceUri; value=TE_"Trace"."DataRead"."TP"
	at org.opcfoundation.ua.builtintypes.ExpandedNodeId.<init>(ExpandedNodeId.java:204)
	at org.opcfoundation.ua.common.NamespaceTable.toExpandedNodeId(NamespaceTable.java:106)
	at org.opcfoundation.ua.encoding.binary.BinaryDecoder.getExtensionObject(BinaryDecoder.java:970)
	at org.opcfoundation.ua.encoding.binary.BinaryDecoder.getScalarObject(BinaryDecoder.java:1436)
	at org.opcfoundation.ua.encoding.binary.BinaryDecoder.getVariant(BinaryDecoder.java:1659)
	at org.opcfoundation.ua.encoding.binary.BinaryDecoder.getDataValue(BinaryDecoder.java:651)
	at org.opcfoundation.ua.encoding.binary.BinaryDecoder.getDataValueArray(BinaryDecoder.java:674)
	at org.opcfoundation.ua.core.EncodeableSerializer$171.getEncodeable(EncodeableSerializer.java:4491)
	at org.opcfoundation.ua.encoding.utils.AbstractSerializer.getEncodeable(AbstractSerializer.java:197)
	at org.opcfoundation.ua.encoding.utils.SerializerComposition.getEncodeable(SerializerComposition.java:104)
	at org.opcfoundation.ua.encoding.binary.BinaryDecoder.getMessage(BinaryDecoder.java:1255)
	at org.opcfoundation.ua.transport.tcp.io.TcpConnection$ReadThread.run(TcpConnection.java:1115)

with UAExpert tool, I can read that node with no problems and all it's leafs.
opcua.1.4.1.jar

I have read in other issue that I need to read namespaceArray and set is as context, but have no idea how to set it, neither are there examples for that.
please help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions