Skip to main content

TCP Method Design

tip

To create a TCP protocol, start by creating a new TCP client. Once the client is saved, you can then create a new TCP method under that client.

The Design section allows you to align with the API-first development habits by predefining interface request parameters and expected responses. If your focus is on debugging, you can skip this step and go directly to the Debug page.

Create a New TCP Method

Find the TCP client in the directory sidebar, then go to More Operations → Create New TCP Method.

image.png

Basic Information

caution

The service address of the TCP method inherits the parent client's service address and cannot be directly modified. To change it, you must modify it at the client level.

image.png

Request Message

Supports the following message formats: fixed-length, separator, and raw (xml/json/text/) .

Fixed-Length Message

Allows setting a fixed length for each parameter value in the message. If the length is insufficient, you can define padding rules.

image.png

How to Set Padding Rules

image.png

Separator Message

Supports setting a separator between each parameter value in the message.

image.png

How to Set Separator Rules

image.png

Raw

For sending JSON, XML, or Text formats, switch to the corresponding raw type.

The Raw (json/xml) format supports visual editing, allowing you to design request messages with hierarchical JSON or XML structures and better understand data organization.

image.png

image.png

The Raw (Text) format supports source code editing, enabling you to design parameter values for input fields directly

image.png

Response Message

This section is primarily used in the interface documentation, showing the expected structure of the TCP method's response.

Create New Response

Click[New Response] to select the expected status code, provide a name, choose the content format, and click [OK] to create it successfully.

image.png

Design JSON Schema

You can choose from four content formats: JSON, XML, HTML, and Binary. JSON/XML formats can be visually designed to define the expected data structure of the response(you can understand the use of JSON Schema).

image.png

Design and Generate Example Response Values

The well-designed JSON Schema can also be used to generate mock response example values.

image.png