httpfile()

Description:

Package the returned result of URL as the file flow and return it.

Syntax:  

httpfile(url:cs,post:cs;header)

Note:

The function packages the returned result of URL string of HTTP service into a file flow and returns it, which can only be retrieved with segmentation forbidden.

Parameters:  

url

HTTP service in the URL string format.

Parameter port is the port number configured in Http Server. The dfx path is the one relative to the main directory configured in Tool -> Options -> Environment.

Two scenarios about the syntax of writing a URL for performing an HTTP service:

I. esProc style

  Here are the syntax of writing a URL when using esProc’s HTTP service:

  http:// IP:port /dfx1.dfx()

  http:// IP:port /dfx1.dfx(arg1,arg2,...)

http://IP: port/dfx1.dfx(...)dfx2.dfx

http://[IP6]:port /dfx1.dfx()

1. There’s only one dfx file. If the dfx file has parameters, write them in order in the parentheses after the file; use comma to separate the multiple parameters. If the dfx file hasn’t parameters, the parentheses are empty; in this case the format of the file’s return value is what a user expects.

2. There are two dfx files. When the return value format a user wants is different from the format of the return value in dfx1 file, dfx2 file is used to change the format of the return value in dfx1 into a desired one. The syntax for dfx1 is the same as the that for the dfx file in the first scenario, but here the file supports only the single result set. dfx2 file is a program with only one parameter, which is the return value of dfx1 file.

  dfx2 file converts the format of the return value in dfx1 file into a desired one and return it as a result. For example, in the table sequence returned by dfx1 file, fields are by default separated by “|”; you can change dfx1’s return value in dfx2 to use the blank space as the separator.

If the second result set, which must contain strings, is returned, it is treated as the header.

3.  For IPv6, bracket the IP address with [].

II. SAP style

When the dfx file is located in a subdirectory under the main directory, you can use SAP Result type to call it.

Configure the dfx file’s path relative to the main directory in httpServer.xml’s sapPath property. The path can be of multilevel directory structure or an empty string. The latter means the file is saved directly under the main directory. If there are multiple paths in the sapPath property, separate them by comma. For example:

<?xml version="1.0" encoding="UTF-8"?>

<Server Version="1" host="127.0.0.1" port="8503" parallelNum="10" sapPath="/sf,,/sr/pm"/>

In the above XML code, three relative paths are configured in sapPath property. They are [main directory]/sf, [main directory] and [main directory]/sr/pm.

The following shows the SAP syntax of a URL:

http://IP:port /sapPath/dfxName  For calling a dfx file without parameters

http://IP:port /sapPath/dfxName/arg1[value1]/arg2[value2],... For calling a dfx file containing parameters

sapPath is a path in httpServer.xml’s sapPath property;

dfxName is the name of dfx file, whose extension will be omitted at the call;

arg1[value1]/arg2[value2],... is the name and value of each parameter in the dfx file; parameter name must be a string of letters and parameter value is a string where the first character should be a number; the name and value will concatenate together as one string to respond to a call. Multiple parameters are separated by slash “/”.

 

Note:To access database data from the dfx file, configure the value of autoConnect property as true in raqsoftconfig.xml’s DB node; you can’t connect to the database if skipping this configuration.

cs

Character set, which supports JVM's built-in character set, and which by default is the default value of virtual machine.

post

 

header

A parameter submitted with POST method with a syntax like p1=v1&p2=v2…. Can be omitted.

The header property can have multiple items, like headerName1:value1,headerName2:value2,... (the format is "property":"value",…); or can be omitted. The execution of .property() function over a returned file object will return the header property.

Return value:

File flow

Example:

 

A

 

1

=httpfile("http:// localhost:9090/p1.dfx()":"GBK").import@t()

Here’s the p1.dfx file:

Load p1.dfx file from the http server, with the charset as GBK

2

=httpfile("http://localhost:9090/p2.dfx(3)":"GBK").import@t()

Here’s the p2.dfx file where StuId is the parameter

3 is the value of parameter in p2.dfx file

3

=httpfile("http://localhost:9090/p3.dfx(3Class%20two)":"GBK").import@t()

Here’s the p3.dfx file where StuId and Class are the parameters

The two parameters are separated by a comma

4

=httpfile("http://localhost:9090/http2.dfx()").import@t()

Here’s http2.dfx :

 

The returned result:

 

5

=httpfile("http://127.0.0.1:9090/http2.dfx()http3.dfx").import@t()

Here’s the http3.dfx

The returned result:

 

By default the execution of http2.dfx file returns a sequence of STATE values. To return comma-separated strings, we process the result of http2.dfx using another dfx file http3.dfx.

6

=httpfile("http:// 192.168.0.131:6080/myweb/servlet/testServlet?table=employee&type=json")

testServlet returns a string of employee data in the JSON format

7

=httpfile("http://localhost:6080/myweb/servlet/testServlet":"GBK","table=employee&type=json":"GBK")

 

8

=httpfile("http://127.0.0.1:8182/scada/v1/uaes/datapoint/history/rawvalue/rtdb/access","{\"nodeIds\":[\"ns=102;s=AI_002_0600.PV\"], \"startTime\":\"2018/6/28 13:10:00\", \"endTime\":\"2018/6/28 13:11:0\", \"returnBounds\":\"false\", \"maxSizePerNode\":\"10\"}"; "Content-Type":"application/json")

 

9

=httpfile("http://127.0.0.1:8503/sr/pm/gypb/id3/parent15").read()

Here’s gypb.dfx:

Set a cellset parameter:

To use the SAP Result style, first configure sapPath="/sr/pm" in httpServer.xml under [installation directory]/config/. In the URL, “/sr/pm” shows a position relative to the main directory; “gypb” points to the dfx fle gypb.dfx, and “id3/parent15” means that parameter id’s value is 3 and parameter parent’s value is 15.

10

=httpfile("http://192.168.74.1:8508/dc/arg22").read()

There’s no need to configure sapPath if the file is under the main directory and the port number can be directly followed by /dfxName instead of the path. Here the URL means that dc.dfx is saved under the main directory and it has a parameter arg, whose value is 22.

11

=httpfile("http://[fe80::2918:abe0:3017:8401%15]:8503/emp.dfx()":"GBK").import@t()

Load emp.dfx file through http service via IPv6 connectivity using GBK charset