Reading of user structure from server

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

Moderator: uasdkcpp

Post Reply
2garin
Jr. Member
Jr. Member
Posts: 1
Joined: 25 May 2018, 11:46

Reading of user structure from server

Post by 2garin »

Hello.
We would like to read user defined structure from the server. Values of this structure are displayed correctly in different OPC UA browsers like UaExpert, Softing client etc.
When we try to get the structure definiton with the following code, we get return value null also definition.isNull()

Here is code snippet:

UaStatus status = m_pUaSession->read(serviceSettings, 0, OpcUa_TimestampsToReturn_Both, nodesToRead, values, diagnosticInfos);
if (status.isGood())
{
OpcUa_StatusCode statusCode = OpcUa_IsGood(values[0].StatusCode);
if (statusCode)
{
UaVariant vVal = UaVariant(values[0].Value);
UaExtensionObject extObj;
if (vVal.arrayType() == OpcUa_VariantArrayType_Scalar)
{
vVal.toExtensionObject(extObj);
status = vVal.toExtensionObject(extObj);
if (status.isGood())
{
if (extObj.encoding() == UaExtensionObject::Binary)
{
UaStructureDefinition definition = m_pUaSession->structureDefinition(extObj.encodingTypeId());
if (!definition.isNull())
{

We have checked, the dictionary is read from the server. Did we forget anything else?

Kind regards

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

Re: Reading of user structure from server

Post by Support Team »

Hello 2garin,

there's an example in the C++ console client doing exactly this.
See examples/client_cpp_sdk/callback.h method printExtensionObjects() - you find the full source code there to print the content of an ExtensionObject.
Best regards
Unified Automation Support Team

Post Reply