Requests to a Web Service

<< Click to Display Table of Contents >>

 

Requests to a Web Service

HTTP requests to a Web Service have a POST type and must include the required parameters Operation, Entity, and Data. The Data parameter must be in XML or JSON format, according to the next specification.

 

General Structure

Except for the UPDATE TAG operation, the parameters of a request are encapsulated in a reserved Block Tag called OperationBlock. For requests with the UPDATE TAG operation, the Block Tag OperationBlock is not used, since this operation is intended for updating specific PLC or Block Tags. In this case, the Entity parameter represents the Item property of the Tag to update and the Data parameter must follow the formats described next.

 

For PLC Tag Updates

XML format:

<TagData>
  <Value>XXX</Value>
  <Quality>XXX</Quality>
  <Time>XXX</Time>
</TagData>

 

JSON format:

{
  "Value": "XXX",
  "Quality": XXX,
  "Time": "XXX"
}

 

For Block Tag Updates

XML format:

<TagData>
  <Values>
    <Value>XXX</Value>
    <Value>XXX</Value>
    <Value>XXX</Value>
  </Values>
  <Quality>XXX</Quality>
  <Time>XXX</Time>
</TagData>

 

NOTE

The <Values> section can contain as many <Value> elements as needed.

 

JSON format:

{
  "Value": ["XXX", "XXX", "XXX"],
  "Quality": XXX,
  "Time": "XXX"
}

 

NOTE

The Value array can include as many values as needed.

 

Rules for Values

•Value: The values sent are interpreted by an application as Strings, integer, or floating point values, depending on the most appropriate format

•Quality: Must be an integer value representing the quality of a Tag, such as 192 for good quality

•Time: Must be a String in ISO 8601 format, using the pattern YYYY-MM-DDTHH:MM:SS, such as "2026-09-28T14:23:18"

 

Specific Behavior

If a POST request to update a Block Tag is sent, but the Entity parameter refers to a PLC Tag in an application, only the first value from an array or list of values is considered for updating that Block Tag.

 

Example of a Request Using the curl Program

curl -X POST http://localhost:5050/ \
  -H "Content-Type: application/json" \
  -H "Operation: XXX" \
  -H "Entity: XXX" \
  -d "XXX"

 

The value of the Content-Type header must match the format of data sent in the body, that is, the -d parameter. Use "application/json" if data is in JSON format and "application/xml" if data is in XML format.

The response of a request is a String in JSON format with the Err field, an integer representing an error code, and the ErrMsg field, a String containing a description of that error. The available values for the Err field and the corresponding messages of the ErrMsg field are described on the next table.

Return codes of a request

Err

ErrMsg

Description

0 (zero)

OK

Request successfully processed. Data sent remains pending until the next reading of this Driver

1 (one)

Operation is empty

The Operation header was not informed or is empty

2 (two)

Error parsing data

Unable to parse data sent in an UPDATE TAG operation. It occurs when the body of a request is empty, when data in XML or JSON format is invalid for the format informed in the Content-Type header, when the Value field contains an unsupported data type, or when no valid value is found

3 (three)

Invalid XML or JSON data

The body of a request is empty or there is no valid data in the XML or JSON format for the format informed in the Content-Type header. It applies to operations other than UPDATE TAG

 

Example of a Response

{"Err":3,"ErrMsg":"Invalid XML or JSON data"}

Was this page useful?