Please enable JavaScript to view this site.

Navigation: Linkar CLIENTS > Client Functions

SendCommand_Text, SendCommandAsync_Text

Scroll Prev Top Next More

SendCommand is a standard interface for a wide variety of operations, defined as standard XML or JSON requests.

This one function can be used to perform all common CRUD requests, to execute TCL/ECL commands, to run subroutines, and to format data. This is simply an alternative method to access a database, compared to using individual single-purpose client functions. For example, a desktop application might use the LinkarClt.SendCommand_Text static method to log a message into the database, or to do a quick retrieval of a name related to an ID. The lksendcommand.exe program uses this function to perform operations on remote MV databases.

 

Among the parameters for this function (detailed below) is the commandFormat parameter. This is set to an enumeration value to specify the format being used for the command string, either XML or JSON. The command parameter is the request itself in the specified format.

 

As an example of usage, to send an XML request to Execute the command "COUNT fileName", the SendCommand_Text parameter commandFormat will be the enum value ENVELOPE_FORMAT.XML, and the command payload will be as follows:

 

<COMMAND NAME="EXECUTE">

 <STATEMENT>COUNT fileName</STATEMENT>

 <CUSTOM_VARS></CUSTOM_VARS>

 <OUTPUT_FORMAT>MV</OUTPUT_FORMAT>

</COMMAND>

 

If commandFormat is set to ENVELOPE_FORMAT.JSON, the command value will be

 

{ "NAME" : "EXECUTE", "COMMAND" : 

 

         "STATEMENT" : "COUNT fileName" ,

         "CUSTOM_VARS" : "" ,

         "OUTPUT_FORMAT" : "MV"

 }

}

 

The OUTPUT_FORMAT in the template specifies how the result of the operation is returned, and can be MV, XML, XML_DICT, XML_JSCH, JSON, JSON_DICT, JSON_SCH.

 

If the output format is MV, Linkar will convert the response to Base64. This prevents MV-specific delimiter characters in the XML payload from corrupting the XML structure.

 

XML and JSON Templates are available at GitHub: https://github.com/kosday/Resources to copy into code and modify.

 

As always, white-space is ignored in XML and JSON, and is provided here only for readability.

 

When using the Linkar REST API, the XML or JSON request payload also uses SendCommand Templates.

 

For a full code example, see this topic in the LinkarClient Documentation

 

 

 

As with other Client Functions, SendCommand can be executed in a Client Session after Login, or using credentialsOptions, for a Direct/Volatile operation.

Transactions can also be processed synchronously or asynchronously.

 

Note that the method name and parameters are different when this feature is used in C.

 

* hasError

(only C)

BOOL*

 

Only in C functions: bool pointer used in the C functions that indicates the return of the function is a system error and must be communicated to the Linkar SERVER

* callback

OperationAsyncCallbackString

ArrayList

 

 

Return type in asynchronous methods. For further information see ASYNCHRONOUS CALLS

* credentialsOptions

CredentialsOptions

char*

 

 

Object that defines the necessary data to access the database: Username, Password, EntryPoint, Language, FreeText. In the C Direct Functions, it is a char*

* connectionInfo

(only C)

char*

 

 

Only in C Persistent Functions: string that is returned by the Login function and contains all the necessary connection data. This data is necessary in persistent functions.

* command

string

char*

 

 

Content of the operation to send

commandFormat

enum ENVELOPE_FORMAT

DataFormatTYPE

 

ENVELOPE_FORMAT.XML

Indicates the format the operation : XML or JSON

customVars

string

char*

 

This is a free text field to send in the transaction. If not empty, subroutine SUB.LK.MAIN.CONTROL.CUSTOM will be called. Add custom code to that subroutine to define special behaviours for some or all transactions.

 

receiveTimeout

Numeric

 

-1

0

 

This is the maximum time in seconds that the client will wait for a response. Use 0 for no timeout. This is a function-specific override : -1 in a Persistent function defaults back to the timeout defined in the LinkarClt constructor.

 

This function can generate exceptions.

In COM assemblies, a return value of type String will contain an error message if an error occurs when performing the operation.

 

Asynchronous calls are not yet available for C-based Client libraries including C, JavaScript, PHP, and Python.

       SendCommand. Persistent Functions

       SendCommand. Direct Functions

       SendCommandAsync. Persistent Functions

       SendCommandAsync. Direct Functions