Read Node to Encodage Xml |OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
Read Node to Encodage Xml
Avatar
julien MARTIN
Member
Members
Forum Posts: 6
Member Since:
03/06/2024
sp_UserOfflineSmall Offline
1
03/07/2024 - 04:22
sp_Permalink sp_Print sp_EditHistory

Hello,  

Hello, I have an Opc client, when I read the node is ExtensionObject.

the node is custom structure in Opc Ua Server PLC siemens 1500.

the value is systematically encoded as a byte.

In the example provided, the node is read with an Xml encoding.

I tried to specify to the client not to use the Binary encoding with :

ConfiguredEndpoint endpoint = new ConfiguredEndpoint(null, endpointDescription, endpointConfiguration);
endpoint.Configuration.UseBinaryEncoding = false;

This changes nothing.

I Have try this:  

DataValue value = _session.ReadValue(nodeId);
ExtensionObject extObject = (ExtensionObject)value.Value;
var Decoder = new BinaryDecoder(extObject.Body as Byte[], ServiceMessageContext.GlobalContext);
var Result = Decoder.ReadXmlElement(null);
return value;

Exception :MaxByteStringLength 1048560 < 54657037

Do you have any idea what I might have missed?

Thanks in advance.

Best regards.

Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
03/08/2024 - 16:33
sp_Permalink sp_Print

endpoint.Configuration.UseBinaryEncoding only works of the protocol allows XML (i.e. http).

It has no effect if using opc.tcp

You can, in theory, read an alternate encoding by setting the DataEncoding in the ReadValueId when reading a value.

However, this only works if the Server supports conversions for that particular Variable.

The right way to deal with these unknown types is to use the Generic structure class that are part of the .NET Codebase:

https://github.com/OPCFoundati…..mplexTypes

Samples of using these classes are part of the Reference server.

Avatar
julien MARTIN
Member
Members
Forum Posts: 6
Member Since:
03/06/2024
sp_UserOfflineSmall Offline
3
03/11/2024 - 05:12
sp_Permalink sp_Print

Hello , Thank you for your Help ! 

I didn’t have install the nuget OPCFoundation.NetStandard.Opc.Ua.Client.ComplexTypes.

I added this to my server connection and the objects are now decoded, so I can watch them being processed and written.

ComplexTypeSystem complexTypeSystem = new ComplexTypeSystem(_session);
complexTypeSystem.Load().Wait();

Cdt.

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 24
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1446
Posts: 4890