Giving an URL connection established through the function http.connection performs the reading and returns the content.

1 http.connection.read

<http.connection.read
    encoding='encoding'
    raw='true|false'
>
    <http_connection /> !
</http.connection.read>
Example

Obtain the source code of a page. The function http.connection returns an URL connection and with http.connection.read the content of the connection can be read. The function println shows the content by console.

Copy
<xsql-script name='http_connection_read'>
    <body>
        <println>
            <http.connection.read>
                <http.connection url='http://www.google.es' />
            </http.connection.read>
        </println>
    </body>
</xsql-script>
Example

Call to the National Digital Forecast Database XML/SOAP Service - NOAA's.

Copy
<xsql-script name='sample_soap_request'>
   <body>
     <set name= 'm_request'><--![CDATA[<?xml version='1.0' encoding='UTF-8'?>

<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ndf="http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl">
<soapenv:Header/>
<soapenv:Body>
<ndf:NDFDgenByDay soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<latitude xsi:type="xsd:decimal">38.99</latitude>
<longitude xsi:type="xsd:decimal">-77.99</longitude>
<startDate xsi:type="xsd:date">2015-03-04T09:00:00</startDate>
<numDays xsi:type="xsd:integer">7</numDays>
<Unit xsi:type="xsd:int">0</Unit>
<format xsi:type="xsd:string">24 hourly</format>
</ndf:NDFDgenByDay>
</soapenv:Body>
</soapenv:Envelope>
]]--></set>


     <println>
        <http.connection.read>
           <http.connection
              url = '/xml/SOAP_server/ndfdXMLserver.php'
              protocol= 'http'
              host='graphical.weather.gov'
              doInput='true'
              >
              <properties>
                 <setproperty name = 'SOAPAction'>http://graphical.weather.gov/xml/DWMLgen/wsdl/ndfdXML.wsdl#NDFDgenByDay</setproperty>
                 <setproperty name = 'Content-type'>text/xml; charset=utf-8</setproperty>
              </properties>
              <post type='raw'><m_request/></post>
           </http.connection>
        </http.connection.read>
     </println>

   </body>

</xsql-script>
Example

Download a PDF file of an URL (the attribute raw='true' must be used).

Copy
<xsql-script name='download_pdf'>
	<body>
        <file.out.open id='out1'> 
             <file name='/tmp/test.pdf' type='absolute' />
        </file.out.open>
 
        <file.out.write id='out1'>    
            <http.connection.read raw='true'>
                 <http.connection url='http://mirror1.mydeister.com:10000/deister/pdf-sample.pdf' />
            </http.connection.read>
        </file.out.write>
    </body>
</xsql-script>