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.

 

The 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

http://IP:port /sapPath/dfx  No parameters

http://IP:port /sapPath/dfx/arg1/arg2,...  Use the slash sign (/) to separate the parameters

  sapPath is relative to the dfx file’s main director; it can be a multilevel directory structure or an empty string. sapPath should be configured in [installation directory]/config/httpServer.xml. A sapPath can contain multiple paths which sparated by comma. dfx represents a dfx file’s name, which doesn’t have an extension. arg contains both the name and value; the name consists of all letters and the value always begins with a number.

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(30)").import@t()

Here’s the http2.dfx where id is the parameters

5

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

Here’s the http3.dfx

Process the return value of http2.dfx in 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://192.168.74.1:8508/sap/arg/arg22").read()

Sap style; configure the style in [installation directory]/config/httpServer.xml; here sapPath is "/sap"; it can contain multiple values that separated by comma, like sapPath="/sap,/sap/en". The dfx file name doesn’t have an extension and the name and value of a parameter are written continuously

10

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

There’s no need to configure sap if the file is under the main directory; and the port number can be directly followed by /dfx

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