Access via ADS
One option for access is via MQTT and a message broker. In addition, access is also possible directly via ADS. In this case, the same interface is addressed that is addressed internally in the MQTT case.
The JSON documents corresponding to the API description (cf. API description) are passed to the JSON Data Interface via ADS, and the response then also contains a JSON document. This is done by executing an ADS ReadWrite command with index group 0xf070 and index offset 0x0. The data to be written contains the request document, while the data to be read reserves the memory for the response document. The following code snippet shows how to access the JSON Data Interface using ADS .NET V5.
int adsPort = 851;
string responseString;
AdsClient adsClient = new AdsClient();
adsClient.Connect(adsPort);
string json = "{\"symbol\":\"MAIN.nCounter\"}";
byte[] writeData = new byte[json.Length+1];
MemoryStream writeStream = new MemoryStream(writeData);
BinaryWriter writer = new BinaryWriter(writeStream);
writer.Write(Encoding.ASCII.GetBytes(json));
byte[] readData = new byte[1000];
adsClient.ReadWrite(0xf070, 0, readData, writeData);
responseString = Encoding.ASCII.GetString(readData);
In principle, Ads-ReadWrite commands are always sent to the combination of Index Group and Index Offset described in the code. The response returned within the command then contains the JSON response of the JSON Data Interface.