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>

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

Example

Obtain the source code of a page. Through the label http.conection.read is possible to read the content of the connection.

Copy
<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>
Example

Obtain the XML code of a news page RSS.

Copy
<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).

Example

Vote in a poll.

Copy
<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.