Please enable JavaScript to view this site.

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_SCH, 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.

 

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.

 

 

* command

string

 

 

Content of the operation to send

commandFormat

 

 


Indicates the format the operation : XML or JSON

customVars

string

 

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.