OpcUaWebServer
OpcUaWebServer copied to clipboard
READRESPONSE has a strange format
Describe the bug
I've tried to read the value of a variable and got the following response:
{
"Header": {
"MessageType": "READ_RESPONSE",
"ClientHandle": "1"
},
"Body": {
"Value": {
"Type": "1",
"Body": "true"
},
"SourceTimestamp": "2019-07-26T11:10:20Z",
"ServerTimestamp": "2019-07-26T11:10:20Z"
}
}
First of all, the type is wrong anf equals 1. And I think, if variable 'Boolean' has type Boolean, the body should be true not string "ture".
To Reproduce
- Run demo application:
docker-compose run -p 8080:8080 -p 8081:8081 -p 8082:8082 webserver
- Launch script:
import websocket
import json
msg = {
'Header': {
'MessageType':'READ_REQUEST',
'ClientHandle':'1'
},
'Body': { 'Variable' : 'Boolean'}
}
ws = websocket.create_connection('ws://127.0.0.1:8081')
ws.send(json.dumps(msg))
resp = ws.recv()
json.loads(resp)
Expected behavior
The expected message should be:
{
"Header": {
"MessageType": "READ_RESPONSE",
"ClientHandle": "1"
},
"Body": {
"Value": {
"Type": "Boolean",
"Body": "true"
},
"SourceTimestamp": "2019-07-26T11:10:20Z",
"ServerTimestamp": "2019-07-26T11:10:20Z"
}
}
The type is an integer variable. These are not returned as a string.
The string "true" is actually an error. That's because json boost only allows strings. We can think about using another JSON parser.
It works a bit confusing. ValueInfo Response returns the type as a string that stores the name of the type. Read Response returns the code of the type. What is why I habe taken it as a bug.
We can think about using another JSON parser.
I can offer jsoncpp
but we have to fix this before:
https://github.com/ASNeG/OpcUaStack/issues/252
See Issue #41.
I think the own data types should be adapted to the OPC UA standard.
I think the better solution of the JSON parser problem is to make some little workaround:
https://stackoverflow.com/questions/2855741/why-does-boost-property-tree-write-json-save-everything-as-string-is-it-possibl.