We provide an API via Web-Service that can read and write tag values. To access the tags, a login is required for solution users. You can directly access this API through HTTP (REST API) connecting with a runtime system.
This page presents information about how to use the WebAccess REST API.
On this page:
Contract Methods Using Rest API
The Web-Server URLs have the following URL syntax "http://<IPAddress>/<ProductVersion>/WebAccessService.svc/<ContractMethod>" where the contract methods are described below.
GetVersion()
Gets the service version.
Syntax:
- Method: GET
- URL Example: http://localhost/fs-8.1/WebAccessService.svc/GetVersion
- Response Example:
{"GetVersionResult":2}
Login(string userName, string password)
Logs in project user. Parameters:
- userName: User No case.
- password: Password. Case
Syntax:
- Method: GET
- URL Example: http://localhost/fs-8.1/WebAccessService.svc/Login?userName=guest password=test.
- Response Example:
{ "LoginResult": { "Handle": 2, "Status": "" } } Returns the connection handle (whether >= 0) or error code (whether < 0).
Logout(int handle)
Logs out project user. Parameters:
- handle: Connection. This value was returned by Login method.
Syntax:
- Method: GET
- URL Example: http://localhost/fs-8.1/WebAccessService.svc/Logout?handle=1.
- Response Example:
{ "LogoutResult": 0 } 0: OK, 1: Invalid connection handle.
ReadObject(int handle, string objectName)
Reads value from specified object. Parameters:
- handle: Connection. This value was returned by Login method.
- objectName: Object (Tag) Name.
Syntax:
- Method: GET
- URL Example: http://localhost/fs-8.1/WebAccessService.svc/ReadObject?handle=1&objectName=tagExample.
- Response Example:
{ "ReadObjectResult": { "ObjectName": "tagExample", "Quality": 64, "UtcTimeStamp": "11/29/2019 17:33:47", "Value": "0" } } Returns Value of the object.
ReadObjects(int handle, IList<string> objectNames)
Read value from a list of objects. Parameters:
- handle: Connection. This value was returned by Login method.
- objectNames: Objects (Tags) Name.
Syntax:
- Method: POST
- URL Example: http://localhost/fs-8.1/WebAccessService.svc/ReadObjects .
- Body Example:
{ "handle" : 1, "objectNames" :["tagExample1", "tagExample2"]}
4. Response Example:
{ "ReadObjectResult": { "ObjectName": "tagExample1", "Quality": 192, "UtcTimeStamp": "02/12/2021 11:13:38", "Value": "20" }, { "ObjectName": "tagExample2", "Quality": 192, "UtcTimeStamp": "02/12/2021 11:13:36", "Value": "10" } } Returns Value of the objects.
WriteObject(int handle, ObjectItem item, bool force)
Write value to specified object. Parameters:
- handle: Connection. This value was returned by Login method.
- item: Object (Tag) Name.
- force: Flag to force value.
Syntax:
- Method: POST
- URL Example: http://localhost/fs-8.1/WebAccessService.svc/WriteObject.
- Body Example:
{ "handle" : 1, "item" : { "ObjectName": "tagExample2", "Quality": 192, "UtcTimeStamp": "02/12/2021 11:13:36", "Value": "2" } "force": false}
4. Response Example:
"WriteObjectResult": true Returns Flag indicating success or fail.
WriteObjects(int handle, IList<ObjectItem> items, bool force)
Write value to specified object. Parameters:
- handle: Connection. This value was returned by Login method.
- items: Object (Tag) Names.
- force: Flag to force value.
Syntax:
- Method: POST
- URL Example: http://localhost/fs-8.1/WebAccessService.svc/WriteObjects.
{ "handle" : 1, "itens" : [{ "ObjectName": "tagExample1", "Quality": 192, "UtcTimeStamp": "02/12/2021 11:13:36", "Value": "2" }, { "ObjectName": "tagExample2", "Quality": 192, "UtcTimeStamp": "02/12/2021 11:13:36", "Value": "13" }], "force": false}
4. Response Example:
"WriteObjectsResult": [true, true] Returns Flag indicating success or fail.
In this section: