.NET Based OPC UA Client/Server SDK
Read – Read With Data Encoding


A session with the server must be established.


The following dialog shows an example implementation of the Read service. Press the button “Show Code” to display the corresponding code, and the button “Help” to show this documentation page.


Press the button “...” to open a Browse window and select a NodeId of a variable with a structured DataType, e.g. ServerStatus. Confirm your choice by pressing “OK”.


The NodeId is now displayed in the field “Node Id” and the drop-down shows all available Data Encodings for the DataType of the selected Variable node. Standard values are “Default Binary” and “Default XML”.


On pressing the button “Read”, the variable is read using the specified data encoding and the response is displayed at “Read Response”. Check the box in front of “Use Asynchronous Pattern” to call “BeginRead” instead of “Read”.


Sample Code

Calling the Read service itself works in the same way as shown in the other Read examples. The difference is that the DataEncoding is set in the ReadValueId. In this example, the DataEncoding can be set in the GUI. The CacheManager of the session is used to get the BrowseName of the encoding node.

private List<ReadValueId> PrepareRequest(Session session)
// nothing to do if no session.
if (session == null)
return null;
// need the browse name of the encoding to pass with the request.
QualifiedName dataEncoding = null;
if (DataEncodingCB.SelectedIndex >= 0)
// Get the BrowseName of the selected encoding node.
// Standard values are QualifiedName("Default Binary") and QualifiedName("Default XML").
dataEncoding = session.Cache.GetAttribute<QualifiedName>(
// build a list of values to read.
List<ReadValueId> nodesToRead = new List<ReadValueId>();
// assume we are reading a variable so the default attribute is the Value attribute.
nodesToRead.Add(new ReadValueId()
NodeId = NodeId.Parse(NodeIdTB.Text),
AttributeId = Attributes.Value,
DataEncoding = dataEncoding
return nodesToRead;

In most use cases, one of the standard encodings “Default Binary” or “Default XML” is used. Then you can hard code the DataEncodings with

new QualifiedName(UaBase.BrowseNames.DefaultBinary)


new QualifiedName(UaBase.BrowseNames.DefaultXml)