Re: VB6 - WebSpring Class: Read, Write, Publish to Web from your VB6 Program
I've decided to post an update to this thread that offers an example of the sort of alternative suggested in the last post. Enough people have come along to read this thread that I hate to leave everyone hanging.
MiniDAVShare
This is a small VB6 class built on top of the MSXML.XmlHttpRequest object.
While it is not full-featured, omitting many WebDAV operations including locking and other nuances, it does enough in a compact form tobe useful for many applications. Most of the features that are implemented should be supported by most WebDAV servers though.
This class gives you access to a remote WebDAV server account where you can fetch a directory listing with several attributes, get and put a file as binary data or as ANSI or Unicode (UTF-16LE) text, make directories, delete directories and files, copy and move directories and files, etc.
A Demonstration
The attachment contains MiniDAVShare.cls and two small projects that make use of it: DataManager and DataConsumer.
DataManager can be used to view and edit a simple list of data, and to persist the changed list to disk and post it to the WebDAV server.
DataConsumer can retrieve this list from the server and display it. Retrieved data is persisted to disk along with a "last updated" timestamp. This timestamp is used to query the server for an updated list, which is then retrieved and stored for use locally.
Data Formats
The list of data is stored as a persisted ADO Recordset in XML format. The timestamp is stored locally at the DataConsumer machines in VB6's Write # format in a separate local file.
Your programs could use any other formats you wish, text or binary. You might post arbitrary XML, CSV, text, a Jet MDB, or whatever else your programs require.
Helper Classes
Both projects isolate some of the fiddly ADO-related and local persistence logic out into xxxHelper classes. This helps keep the logic in the Forms a little cleaner and easier to follow. All of that could easily be inline code within the Forms though.
"Connection Strings"
Both projects use a hard-coded String value containing their "connection parameters." Real programs might do this as well, or they might fetch these values from a config file or something. You'd probably want to do some encryption of at least the password value though, especially in a program dstributed publicly.
To run the demo you will have to have an account with read/write/create access on a WebDAV server.
You can set most versions of IIS up with WebDAV for testing, and many Apache versions have a module for WebDAV support as well. But for this to be of much use you'll want a publicly visible WebDAV server and for most of us it isn't practical to expose our own servers to the Internet and keep them up 24 by 7.
They offer a free account with 2GB of storage, and better yet they have a 2-tired account scheme where you have an owner account and sub-accounts. You get 1 sub-account for free.
For this demo the subdirectory that the data gets posted to is created by the DataManager program. Since MiniDAVShare doesn't have any way to set permissions, the DataConsumer demo would also need to use the owner account.
For a real application similar to the demo you'd probably want to use their Web interface to create the subdirectory and give your guest/limited-user subaccount read only access. Then the DataConsumer piece of your application only needs that subaccount and password rather than your owner credentials.
For applications where the client programs must post data you could of course grant the limited subaccount read/write access to a given directory.
I'm not sure which other providers offer this sort of owner vs. limited-user access. It's a great feature though! I really can't imagine why this isn't more widely available.
So once you have your server and account, modify the CONN string value in the two projects to test them. Some WebDAV servers require a URL of the form:
http://someguy.com/~account
Where account is your account user ID.
MyDrive figures out where your data lives there based on the user ID passed to it as security credentials.
Way Better than File Sync Services
Unlike numerous "cloud storage" offerings, including some clunky single-user WebDAV services, this approach makes WebDAV a useful part of application design. There are other Web Service offerings based on numerous ad-hoc (and often extremely clumsy to implement) protocols you could use, but WebDAV client capability is very light weight to implement as illustrated by MiniDAVShare.
With some effort you could probably configure IIS or Apache with WebDAV to work in a similar fashion as well of course.