arc:script

Version 23.4.8839


arc:script

Version 23.4.8839


The arc:script keyword can be used to create script blocks that respond to REST methods.

Parameters

  • method: The HTTP method (GET, POST, PUT/PATCH/MERGE, or and DELETE) used to invoke the script. Specify multiple methods in a comma-separated list. This can be used to create REST-like services in ArcScript.
  • language: The programming language used to program the script. For example, python or js.

Control Attributes

None

Examples

Below is the script that defines the GetTransmissionDetails service. The script will be executed only when GetTransmissionDetails is accessed using the POST method. The input parameters are defined in the body of the HTTP request.

<arc:script xmlns:arc="http://www.arcesb.com/ns/ArcScript/2">
  
  <arc:restrict user="admin" role="Administrators"/>
  
  <arc:info title="GetTransmissionDetails" description="Retrieves the transmission details of the application.">
    <input name="ConnectorId"          desc="The id of the connector." required="true"/>
    <input name="MessageId"       desc="The message Id." required="true"/>
    <input name="Direction"       desc="The direction of the transmission." values="Incoming,Outgoing" required="true"/>
    <output name="LogTimeCreated" desc="The time the log file was created."/>
    <output name="LogType"        desc="The type of the log file." />
    <output name="LogFile"        desc="The name of the log file." />
    <output name="LogPath"        desc="The path of the log file." />
  </arc:info>

  <arc:script method="POST">
    <arc:push op="portGetTransmissionDetails" />
  </arc:script>
</arc:script>

The next examples show how to use the language parameter to convert a script originally written in ArcScript to another language (in this case, Python). Here is a short script that lists *.rst files:

<arc:set attr="mask" value="*.rst"/>
<arc:call op="fileListDir">
    <arc:push/>
</arc:call>

Here is the same script written in Python, where the language is established by the language parameter:

<arc:script language="python">
  input = {"mask":"*.rst"}
  rsb.call("fileListDir",input)
</arc:script>