Contributed by Roy Kiesler
|PowerBuilder and Internet. A recent survey mentioned in the February 1998 issue of
PowerBuilder Developer's Journal shows that a mare 2% of today's projects are using the
two technologies in tandem.
Some developers, including myself, hear the words "web enabled" and immediately start thinking in terms like HTML, Java, ActiveX, COM/DCOM and other such buzz words, and before you can say "datawindow plug-in" - we're all dazed and confused.
However, Internet enabled PowerBuilder applications do not necessarily have to be n-tier distributed apps. Even traditional 2-tier client/server applications can be Internet aware. Consider a sales application running on a laptop. If the client database does not support replication, the sales person may need to transmit a daily data file to be incorporated into the central database. Wouldn't it be nice if the client application could connect to the company's FTP site, and post a CSV or PSR file, to be picked up by the same client application running on the DBA'a machine, which in turn is imported into a datawindow and updates the central database. It would be even nicer if this whole process could be done automatically, without any user intervention.
Fortunately, the WinINet API provides all the tools necessary for an application to connect to and get data from the Internet using the standard HTTP, FTP and Gopher protocols, shielding developers from changes in the underlying protocols as the standards evolve.
|n_cst_wininet32||n_base||Ancestor Internet service object.|
|n_cst_wininet_ftp||n_cst_wininet32||FTP service object.|
|n_cst_wininet_http||n_cst_wininet32||HTTP service object.|
|of_InternetAutoDial||Initiates an unattended dial-up Internet connection using Dial-Up Networking's default phonebook entry.|
|of_InternetAutoDialHangup||Hangs up an internet connection which was initiated by a call to of_InternetAutoDial.|
|of_InternetDial||Initiates an dial-up Internet connection using a specified Dial-Up Networking's phonebook entry. Can be invoked with or without visual user interface.|
|of_InternetHangup||Hangs up an internet connection which was initiated by a previous call to of_InternetDial.|
|of_InternetGetConnection||Returns the current Internet connection type (LAN/Modem/Proxy.)|
|of_GetConnectedState||Retrieves the current state of the Internet connection.|
|of_InternetOpen||Loads and initilizes the Wininet DLL.|
|of_GetSessionHandle||Returns the current internet session handle as obtained by a previous call to of_InternetOpen.|
|of_InternetGetErrorText||Returns the text of the last error message produced in the current internet session.|
|of_Connect||Connects to a specified FTP or HTTP server.|
|of_ChangeDirectory||Changes to a specified working directory on an FTP server.|
|of_DirList||Returns an FTP directory listing in a string format.|
|of_FileExist||Searches for a file in the working directory on an FTP server.|
|of_GetFile||Retrieves a file from an FTP server ans stores it under the specified local filename.|
|of_PutFile||Uploads a file to an FTP server and stores it under the specified remote filename,.|
|The n_cst_wininet32 and its descendants are auto-instantiated NVOs. In order to use them, you need to declare them as an instance variables of an object, as shown in listing 1 below.|
|Listing 1: Instance variable declaration for window object w_ftp_client|
|A typical Internet enabled application should use the following process flow:|
|Determine if the client machine is connected to the internet.||of_InternetGetConnectedState()|
|If not already connected, initiate a dial-up connection.||of_InternetAutoDial()
|Connect to a remote FTP or HTTP server.||of_Connect()|
|Application specific functionality.||See Object Functions above and the list of local external functions in n_cst_wininet32.|
|The file wininet.pbl contains a small PFC application that demonstrates
the use of all functions in this service. It demonstrates how to upload and download files
to/from an FTP server and how to obtain live stock quotes from an HTTP site.
As an added bonus, the FTP demo shows how to use multiple threads and background processing in a PB 6.0 client application (using distributed objects.)
|Included in these 3 services are 20 functions which I consider to have the most common
uses, like FTP and HTTP. Other functionalities, like Gopher, for example, I chose not to
implement since this type of functionality is rarely used in the business world today.
Other features, like cookies and security certificates are really geared more towards web
browsers than a PB app.
However, if you can think of a functionthat should be implemented in this service, and would benefit others as well, please let me know and I will include it in the next release.
|Download the||About the extension contributor|
|08/05/1998||fixes the following bugs in
|04/14/1998||Fixed a memory leak in the stock quote wizard window of the sample pbl.||Ver. 1.01|
|04/07/1998||Initial Revision||Ver. 1.00|
Interested in contributing material to this web site? Send an email to firstname.lastname@example.org, but don't forget to check the contribution guidelines first.
For information or suggestions about this web site please contact email@example.com
sponsored by Dynamic Technology Group.
The information on this site is provided for advice only and not to be considered a contract or a liability against Dynamic Technology Group.