>>
APLDN Home

>>
Events

>>
Trainings

>>
APL Books

>>
APLDN Links

>>
Discussion Groups

>>
Downloads

>>
Articles

>>
Library

>>
Learning Tools

>>
APLDN User IO

>>
APL2000.com




APL+WebTransfer and Web Sites

Posted by on Thursday, May 13, 2004 (EST)
This article has been Downloaded: 814 times

The APL+WebTransfer is designed to make it possible to communicate between APL programs, APL programs and the web, and between APL programs and programs written in other languages.

APL+WebTransfer supports both synchronous and asynchronous transfers of data.

 

In all cases the first thing we need to do in APL is to instantiate the APL+WebTransfer:

 

'wt' Œwi 'Create' 'APL2000.WebTransfer'

 

Connecting to Web Sites

 

When using APL+WebTransfer to connect to a web site, either the XSend or XASend method can be used.  In the case of the XSend method, the data is sent and received synchronously, which means that execution in the workspace waits for the data to be returned before executing the next line of code.

 

To setup a transfer of data use the XOpen method:

 

'wt' Œwi 'XOpen'  'http://www.openhere.com/'

 

This will validate that the domain exists and is resolvable.  After opening a location, subsequent calls sending and receiving data do not have to resolve the location again, which makes data transfer quicker.  Also, cookies and similar data set by a site are maintained for all following transactions.

 

To retrieve the home page from OpenHere.com use:

 

a„'wt' Œwi 'XSend'  '' ''

 

Notice that the XSend method takes two arguments.  The first argument is the path and the second is the data for the “POST” method.  So, setting the second argument to ‘’ means that a “GET” will be transmitted to the web server.

 

To retrieve the US News page from OpenHere.com use:

 

a„'wt' Œwi 'XSend' '/news1/' ''   

 

or

 

a„'wt' Œwi 'XSend' '/news1/default.htm' ''

 

Both calls retrieve the same page.

 

If we now wanted to retrieve the data, but not wait for the return, we would use the events to alert us as to the progress of the page retrieval and use the XASend method.

 

'wt' Œwi 'onCompleteCallback' 'complete'

'wt' Œwi 'onDownloadProgressCallback' 'download'

 

The complete function is called when the retrieval is complete and the download function is called as the download progresses.

 

The complete function would look at Œwarg which contains the id, which defaults to 0 if not set, and a second element which is 0 for success and -1 for error.  You can look at
the lastError property to retrieve the error.

 

The download function would have a three element Œwarg, the first element has the number of bytes downloaded so far, the total number of bytes expected and the third element is the id.

 

When the XASend method is called it returns a two element array, with 0 for success and a second element set to ‘processing’ or the resulting error in the case of an error.

 

When transmitting large amounts of data to a server it is also useful to have events indicating the progress of the transfer.  In this case you could set:

 

'wt' Œwi 'onUploadProgressCallback'   'upload'

 

Which would mean that upload would be called as the data is uploaded to the web site.  In this case Œwarg contains a three element vector, with the first element being the number of bytes uploaded so far, the second element being the total bytes to be uploaded and the third element being the id property value.

 

This means that you can create progress bars to indicate upload and download progress of data transfers.  In addition you can run multiple uploads and downloads simultaneously as the XASend method returns immediately.  Simply create another instantiation of APL+WebTransfer and start transferring more data.

 

The data returned is available by referencing the “returnedData” property.

 

While this is a very useful utility, APL+WebTransfer is more particularly designed to facilitate the movement of complex data between programs. 

 

APL+WebTransfer works as a COM and also a .Net Assembly.  This means that any programming language that supports com objects can consume APL+WebTransfer, such as VB 6.0 and .asp pages. 

 

The .Net languages (VB .Net, C#, J#, C++, Jscript) and .aspx pages can also use APL+WebTransfer as a .Net assembly.

 

For a review of how to use APL+WebTransfer to transfer data between programs, please see:  APL+WebTransfer and Objects

 

 


Bad
Good|Rate Item
Average Rating:

Add Your Comment



APL2000 Official Web Site

Service is the rent we pay for being. It is the very purpose of life, and not something you do in your spare time.
--- Marion Wright Edelman

APLDN Home   |    |  Events   |  Trainings   |  APL Books   |  APLDN Links   |    |  Discussion Groups   |    |  Downloads   |  Articles   |  Library   |  Learning Tools   |  APLDN User IO   |  APL2000.com   |