Sends a request of HTTP connection to a server and returns the answer received from the server.
1 http.connection
<http.connection
url='url'
protocol='protocol'
host='host'
port='port'
user='user'
password='password'
ignore-certs='true|false'
store-cookies='true|false'
doInput='doInput'
doOutput='doOutput'
allowUserInteraction='true|false'
followRedirects='followRedirects'
instanceFollowRedirects='instanceFollowRedirects'
>
<properties> ?
<setproperty name='name'> *
<value /> !
</setproperty>
<addproperty name='name'> *
<value /> !
</addproperty>
</properties>
<post type='raw'> ?
<field name='name'> *
<value /> !
</field>
<string /> ?
</post>
<delete /> ?
<put /> ?
</http.connection>
Attributes | |||||
---|---|---|---|---|---|
Name | Type | Required | Default | Description | |
Aurl | string | Internet address of the web resource. | |||
Aprotocol | string | Protocol used for the connection (can be indicated in the URL). | |||
Ahost | integer | Name of the remote host (can be indicated in the URL). | |||
Aport | string | Port number by which the remote host listens. | |||
Auser | string | Username if the web resource requires authentication. | |||
Apassword | string | Password of the specified user. | |||
Aignore-certs | boolean | true | Allows to verify the certificate in case of HTTP connection. The default value avoids errors of the type No trusted certificate found. For security reasons it is not recommended to skip checking (indicatring false). | ||
Astore-cookies | boolean | false | Allows to indicate if it is allowed to store cookies received from the server. | ||
AdoInput | |||||
AdoOutput | |||||
AallowUserInteraction | boolean | false | Allows interactions of the user like to popup the authentification dialog. | ||
AfollowRedirects | |||||
AinstanceFollowRedirects |
Arguments | |||||
---|---|---|---|---|---|
Name | Type | Required | Unique | Nullable | Description |
Eproperties | A request is composed of a header with properties. | ||||
Esetproperty | Asign a value to a property. | ||||
Aname | string | Name of the property. | |||
Evalue | Valor de la propiedad. | ||||
Eaddproperty | Añade el valor de una propiedad del request. | ||||
Aname | string | Nombre de la propiedad. | |||
Evalue | Value of the property.. | ||||
Epost | Indicates which the methode of the request is POST , to be able to send some data to the server.
|
||||
Atype | string | Allows to indicate the type of POST. | |||
Efield | Allows to indicate fields with their respective values. | ||||
Aname | string | Name of the field. | |||
Evalue | Value of the field. | ||||
Estring | Allows to indicate fields with their respective values. | ||||
Edelete | Indicates that the methode of the request is DELETE , to be able to remove some data of the server.
|
||||
Eput | Indicate that the methode of the request is PUT , to be able to put some data of the server. |
Returns | |
---|---|
Type | Description |
HttpURLConnectionWrapper | Returns the URL connection established. |
Inform the attributes user and password is equivalent to asign to the property Authorization
, the value
Basic <credenciales>. Where <credenciales> is the string <user>:<password> encoded in Base 64.
More information about the concept request in www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.3
Obtain the source code of a page. Through the label http.conection.read is possible to read the content of the connection.
<xsql-script name='http_connection_sample1'> <body> <println> <http.connection.read> <http.connection url='http://www.google.es' /> </http.connection.read> </println> </body> </xsql-script>
Obtain the XML code of a news page RSS.
<xsql-script name='sample_soap_request'> <body> <set name= 'm_request'><--![CDATA[<xsql-script name='http_connection_sample2'> <body> <set name='doc_xml'> <http.connection.read> <http.connection url='http://www.lavanguardia.es/rss/index.rss' /> </http.connection.read> </set> <return> <file.getBytes> <dom.transform> <doc_xml /> <webapp.wic_xslt_object.getText code='doc_rss_transform.xsl' /> </dom.transform> </file.getBytes> </return> </body> </xsql-script>
It is stored in a variable and is transformed through a XSL transformer to a HTML code, to be represented in the navigator. The transformer is stored in a database of dictionary (wic).
Vote in a poll.
<xsql-script name='http_conneciton_sample3'> <body> <for name='i' start='0' end='10'> <do> <http.connection url='http://www.xyz.es/encuestas/index.asp'> <properties> <setproperty name='api-key'>XJKH873562HHZ1BCSCMGA</setproperty> </properties> <post> <field name='id'>1029</field> <field name='choice'>2474</field> </post> </http.connection> <http.connection url='http://www.xyz.es/encuestas/index.asp'> <properties> <setproperty name='api-key'>XJKH873562HHZ1BCSCMGA</setproperty> </properties> <post type='raw'> <string>{apiver: 1.0, text:"VOTE ACCEPTED" }</string> </post> </http.connection> <println>Voto <i/></println> </do> </for> </body> </xsql-script>
A POST of a remote form is performed. The name field id corresponds to the identifier of the poll and the field choice to the selected vote option.