Wiki Home

Using Web Connect


Namespace: WIN_COM_API
A Wednesday Night Lecture held 2000.11.15, presented by Les Pinter

Web Connect is created by West Wind
SO, why not come up with a better topic, and move this text, then delete this topic. Something like, nTierVFPWithWebConnect or such.
Maybe because it is a published Wednesday Night Lecture, so I thought improper to refactor. If consensus is to do it, then feel free. -- Alex Feldstein
Before you read the transcript, you must understand that the title might be a little misleading. Although the chat itself was excellent for its content and its value, as you are about to see, it might imply the chat is about a discussion on how to use Web Connect. Rather, it discusses the usage of Web Connect's in a Fat Client application, using the Internet as your LAN. A beginner to the subject might think that is all Web Connect can do, which is far from the truth as Web Connect is a fully featured product.

In order for beginners to get a feel for what the tool can do, please follow these links:
WebConnection's web site
WebConnection's feature list
CNET's Review of WebConnect (Oct '99)

A more detailed explanation of the usage of Web Connect in distrinbuted (Fat Client) apps can be also seen at:
Whitepaper: Building distributed Web Applications with Visual FoxPro
LesPinter's site

-- Alex Feldstein (Thanks to Randy P for pointing this out).

Enjoy!
[Irrelevant material has been removed.]

[21:00] {Evan Delay} Okay. Let's get started...
Tonight's lecturer is Les Pinter. For those that don't know him… I am going to paste his bio. Hold on...

[21:01] {Evan Delay} While working toward a Ph.D. in Economics at Rice University in Houston, Texas, Les Pinter teamed up with two high-school friends to market the fourth word processing program ever written for microcomputers - the Magic Wand. A year later, Les had sold the Magic Wand to a 23-year-old Bill Gates and was hooked on microcomputers.
After writing and marketing the Real Estate Guide, the first nationally-marketed templates for Lotus 1-2-3, Les discovered dBase II and became a database specialist. He bought copy number 253 of Fox BASE, and started publishing a monthly newsletter about Fox BASE in 1989. The Pinter FoxPro letter was published for 10 years in the US and 4 years in Russia.
Currently, Les continues to publish articles on FoxPro and ASP at his website, www.LesPinter.com.
Les has been a speaker at dozens of FoxPro conferences in the US, France, Spain, Russia and Canada. He gives seminars in five languages, and will be speaking at the Mexican FoxPro Developer's Conference in Mexico City at the end of November. He has offices in San Mateo, California, and his consulting clients include Halliburton, Brown and Root, TRW, Stanford University, Anthology Software, uGetHeard.com, and many others.
Les is a private pilot, and once played lead guitar in the road band for Jerry Lee Lewis.
His topic is "Using Web Connect".

[21:03] {LesPinter} I'm not a salesman for Web Connection, but I'm a very, very satisfied customer.
For the last year and a half, almost all of my consulting work has involved Web-enabled FoxPro applications.
Users are amazed that they can run their apps anywhere and get to their data.
The real surprise for me was that, once I got a simple methodology down, it only adds about 5% to the cost of a typical app.

[21:04] {DenisChasse} Les: Will I be able to folllow your discussion tonight even if I don't have Web Connection?

[21:05] {LesPinter} Absolutely. In fact, you can download my article on the subject from my website, get the shareware version if Rick's WWIPSTUFF, and build it yourself at no cost.
Actually, it costs about $99.00 to license the shareware, and I heartily recommend it. In fact, the whole package is a great treasure at any price. But you can run the sample without buying the software.
Any burning questions, or shall I proceed?

[21:07] {RandyPearson} Once you've used tried the samples, you'll buy the software.

[21:07] {ChrisMccandless} Les, how expensive is it to run a web site with web connection? Do I need a dedicated server hosted by someone else?

[21:07] {LesPinter} I made one tiny discovery that made my work much, much simpler. Shall I describe it?
To build a Web Connection server, you unpack the software and run SETUP. Then, the simplest thing to do is to start writing procedures in the wwDEMO procedure, so that your code fits right in with the demo.
(Eventually you'll write your own, but I'm talking about hitting the ground running.)
I added a couple of lines of code in the wwDemoMain program to open a connection to SQL Server, then started writing my procedures.
In my application, I have a place where I define my HTTP connection. I used the name of my computer on my network; you can also use it's IP address.
Then, in each of my forms, I defined cursors that were exactly like the TABLES that I would ordinarily use. So my Web Connection apps don't use ANY local tables.

[21:11] {ChrisMccandless} Speaking of SQL Server, how fast is that so far as a back end? Of course, VFP is faster, right :)?

[21:11] {RandyPearson} SQL Server is more scalable and has other attributes that make it much more reliable for web apps, IMO.

[21:12] {LesPinter} Absolutely. Notwithstanding my rantings about Microsoft's efforts to push people away from .DBFs and toward SQL server, I NEVER use .DBFs. SQL server is very good - and a heckuva lot cheaper than Oracle...

[21:13] {ChrisMccandless} Randy - Yes, but what about speed and cost? What is the liscensing fee for SQL Server 2000 on a web site?

[21:12] {BarbaraPeisch} Les, are you talking about HTML based forms here?

[21:13] {LesPinter} No HTML forms. This session, and most of my consulting work, involves writing NORMAL FOXPRO APPS that just happen to get their data from a web server that's located elsewhere.

[21:14] {Evan Delay} Ah, that is interesting Les.

[21:14] {LesPinter} Shall I do 2 minutes on why each of the two modalities has a place on this Earth?

[21:14] {RandyPearson} Higher than SQL Server 7 for sure, but there are limits to VFP local data. Beyond them, with high enough demand on the site, you need something more robust.

[21:15] {LesPinter} I use HTML forms when my users are numerous and don't have any financial relationship to the application. I use FoxPro apps when they paid good money to be part of an application network.
One tiny comment and we'll leave SQL aside. One of my clients got a $2,000 SQL 7.0 license that did all they needed. Oracle wanted $170,000 for the same level of usage. I rest my case.

[21:16] {BarbaraPeisch} So, in most cases, your users aren't accessing the app through a browser?

[21:17] {LesPinter} Correct. I build applications in VFP because HTML is a pretty poor interface tool. If my users paid $50,000 for a custom application, and there are 50 users worldwide, we send out 50 copies of the installation package, and they get data from our FoxPro server.
For the last 3 months, I've been working on ASP and HTML interfaces. But most of the last year and a half, I did my Internet apps in FoxPro.

[21:18] {BarbaraPeisch} Then you are also assuming responsiblity for their data.

[21:19] {LesPinter} Well, don't we always? Seriously, the data server app runs on a collocated server, but it's their data. I'm not an ISP. I just write the stuff.

[21:19] {BarbaraPeisch} I don't assume responsibility for the user being able to access their data whenever they need to.

[21:20] {LesPinter} To continue, when you're writing a "webbified" FoxPro app, you move back and forth between the application screens and the server procedures constantly. Build a screen that needs data, then write the server procedure that selects and returns the data as XML. The two are done simultaneously.
For example, your code in a LOOKUP button might call a form that asks for the first few letters of a customer name. You then send that string to your server, using the HttpGetEx() function.
HttpGetEx ( "CommandString", lcBuffer, lnBufLen) contains the string used to build the SQL on the server, and lcBuffer is where the result is returned.
Let me explain that. The result of a query in FoxPro is returned as a cursor - a .TMP file. It's pretty hard to send a .TMP file across the internet. So how do you convert a .DBF or a cursor to a string?
You could send the DBF itself, but there's a better way. Rick Strahl has written a wrapper for msXML.dll that converts a .DBF to an XML string in a SINGLE LINE OF CODE. Converting it back to a cursor is - you guessed it - a SINGLE LINE OF CODE also.

[21:24] {RandyPearson} Newbies need to understand Web Connection offers 2 very different development approaches: browser-based clients (universal access) and VFP fat client access across the Net. Les is speaking mainly of the latter.

[21:25] {LesPinter} That's right, Randy. I do both, but obviously if you're building HTML screens you need to master HTML as well. It's not hard, but if you're just writing FoxPro applications and you want to user the Internet as the network cable, it's as easy as pie.
So to continue, you call this little HttpGetEx() function and wait. Long about 1 second later, and I mean from anywhere in the world, it comes back with your data in the lcBuffer string.

[21:25] {AlejandroSosa} Les, just out of curiosity, what is the size ratio between a .DBF file and its XML representation? Say column names are 8 chars on average.

[21:26] {LesPinter} The data is in the form of an XML string, so you have to SELECT CursorName and call oXML.XMLToCursor( lcBuffer ). And Voila, you've got data!
Any questions?

[21:27] {Evan Delay} How is the performance of converting to and from XML?

[21:27] {LesPinter} Alejandro, XML is a little bigger than the corresponding DBF. But for a 1k string, it's a third of a second to transmit at 44k baud.
The conversion to XML is virtually instantaneous.

[21:29] {AlejandroSosa} Les, seeing that XML is the true Esperanto, that seems like a small price to pay.

[21:28] {BarbaraPeisch} Les, have you looked at the conversion functions built into VFP 7? I've heard they're even faster than Rick's.

[21:27] {DanCummings} Are you concerned with limiting the result set?

[21:28] {LesPinter} I try to build limitations to the number of records into the server software. I would pretty much never use this technique for an amount of data that took more than, say, 10 seconds to transmit.

[21:29] {CarlKarsten} I think it is worth pointing out that the amount of data in 10 second transmision will take a human hours to read, so it isn't a good thing to do to your user

[21:28] {Evan Delay} wwIpStuff is shareware. What percent of Web Connect is it?

[21:29] {LesPinter} Web Connection is a vast collection of hundreds of functions. There's nothing in there that doesn't give me a little thrill. But you can write FoxPro webbified apps with just wwIpStuff and wwXML.
Carl's right. I never understood the value of the "progressive fetch" in VFP remote views. In fact, I don't much LIKE remote views...
Anyway, you call this HttpGetEx() function, it returns XML, you pour it into your form's cursor, and you've got data. From that point, you can treat your record just as if it were a record in a local .DBF. Use buffering to manage EDIT/SAVE/CANCEL, whatever.
However, when it's time to Edit and Save, you've got an interesting problem.
To save a record in VFP, you TableUpdate() and you're done. In SQL, you build an UPDATE statement with a WHERE clause.
If you're saving an ADD, however, you build an INSERT statement, and leave out the name of the IDENTITY field.
This is where my two little breakthroughs came in handy.
First, when I send a record to be updated, I send a keyword - EDIT or ADD - indicating what I was doing.
My SAVE function on the server uses that to decide whether to build an UPDATE or an INSERT. I also send the name of the KEY field and the Identity field so that they'll be used as needed.
The routines are in my Web-Enabled Database Applications article at the Learning Center on www.LesPinter.com. Free!
Questions?

[21:31] {ChrisMccandless} Les - How do you get the data? SQL Select from VFP or stored procs?

[21:36] {LesPinter} My WC appserver can call either Stored Procedures, or it can build and execute SQL on the fly. Theoretically, procs are a lot faster, but for our purposes, the difference isn't material.

[21:36] {LarryMoody} Yes, the user would need local data and some kind of merging routine in case someone else changed the same record.
Les, how would you handle a user who was *not* connected to the internet, but needs to stay in sync?

[21:35] {AlexFeldstein} Larry: As in disconnected sets and batch updates?

[21:37] {LesPinter} As to disconnected sets, synchronizing, I ignore it. You can write your app to store data and upload it when reconnected, but I haven't yet found a client willing to pay for the extra coding.

[21:37] {LarryMoody} I see. That's one of the requirements of my next project. thanks.

[21:37] {LesPinter} Note that XML can contain one record or a thousand., It can also store parent-child data. So it's excellent for batch-type applications.

[21:38] {AlejandroSosa} Les, I am a little behind this curve. If I wish to practice WestWindConnection in my LAN, must I use TCP/IP, or can IPX/SPX do ?

[21:38] {LesPinter} Quick answer to Alejandro. No.

[21:38] {AlejandroSosa} Thanks

[21:39] {LesPinter} Seriously, TCP/IP is pretty easy to set up. It only took me a few months to figure it out < g >
XML, interesting thing: I remember getting my eyes crossed reading about Document Type Definitions (DTDs) and creating the table cursor and such. But it turns out that, with a VFP app, YOU DON'T NEED A DTD.
When you open a cursor and call Rick's XML To Cursor() function, it uses the structure of the open cursor to do data conversion. Note: The order of the fields doesn't have to match that of the XML, and fields can be present in the cursor that don't get populated by the XML. It's pretty forgiving.
A DTD is a data structire that defines the data types. Remember that XML is all strings. No Integers, no dates, no currency. Just strings. So converting from XML to a cursor implies data typing every field. Luckily the CURSOR is all XML To Cursor needs to do it.

[21:42] {Evan Delay} Thanks Les.

[21:42] {LesPinter} So all you need to send is "< record >< name >Les Pinter< /name >< amount >5.00< /amount >< /record >" (Editor's note, remove spaces in XML), and XML to Cursor does the rest.

[21:42] {RandyPearson} DTDs will be superseded by XML schemas (easier to learn and use) in the near future. Schemas look like XML itself, so they are easier to deal with than DTDs that have their own syntax.

[21:43] {LesPinter} The one thing that tricked me up is that HTML has to have a header, and so does XML. It looks like this: < XML whatever > followed by a blank line,
I didn't know that, so I went to Rick's conference in Hawaii, asked my one question, got the answer, and went to the beach with my wife for the rest of the week. Best thousand dollars I ever spent...
So, let's see. To build a webbified FoxPro application, you write your normal VFP app, then take out all of the tables and put CREATE CURSOR statements in the form LOAD events to replace all of the tables, then write code to get and send XML strings, using WWXML to convert them.

[21:45] {LarryMoody} That sounds wayyy too easy :)

[21:46] {LesPinter} On the server side, you write one procedure for each place in your app where you need to get or put data. The syntax of the HttpGetEx() function is HttpGetEx ( "servername/wc.dll?libraryname~functionName~Parameters`~Parm2...) etc. So there will be one function for each place in each form that uses data - about 4 per form.
Larry, it IS easy. I can convert a VFP form to use a Web Connection web server at the rate of about 30 minutes per form - start to finish.

[21:47] {LarryMoody} What do you mean by "place" ? Does place mean field? combo box? data environment?

[21:48] {LesPinter} Usually, buttons at the bottom of the form. "LOOKUP" to call a screen that displays candidate records is one call; picking the one record you want and returning it is another. DELETE is a separate call, and a very simple one. That's usally about it.

[21:49] {LarryMoody} Wow!

[21:49] {LesPinter} If your form needs to populate a combobox or two, each one would require a call to HttpGetEx(), presumably in the form's LOAD event. However, you could make several SQL calls on the app server and return all of the data - several combo boxes' lists, for example - in a single trip across the Net.
In fact, for the speed freaks among us, SQL can return multiple datasets in a single call, which can then be turned into a single XML structure. But what's a few milliseconds among friends?
I personally don't worry much about speed. I have to be nice to Microsoft (apparently Im off the black list as of today, by the way - hold your applause) - but the reason VB people are so concerned is because DAO and even ADO are so slow! FoxPro people have never had a speed problem.
Questions? Comments?

[21:52] {ChrisMccandless} Les - How do you know you are off MSs black list :)?

[21:55] {LesPinter} I got a reputation for complaining about Microsoft and SQL. I NEVER disliked SQL. It's great, doesn't get trashed headers or indexes, and users can do their own backups and restores. What I didn't like was not seeing any FoxPro advertising in Visual Studio ads for three years. But that seems to have changed.

[21:53] {LesPinter} As to how I know, I'll leave that for public announcements. But it's good to be back.

[21:54] {ChrisMccandless} Les - And we are glad to have you :)

[21:51] {LarryMoody} Could you use .DBFs on the back end?

[21:52] {AlexFeldstein} Larry: Your back end is a VFP app too. So you can use anything.

[21:52] {LesPinter} Absolutely. In fact, in the article, I let you switch between .DBFs, XML from .DBFs, and XML from SQL, just to compare the implications. I spent about 40 hours writing that article. Please take a look at it. It's as good as I get.

[21:52] {ChrisMccandless} Larry - Have you taken a look at MSDE for data storage?

[21:53] {LesPinter} MSDE is Personal SQL, isn't it?

[21:53] {LarryMoody} No, I'm still lagging behind in the data storage arena, I'm afraid :(

[21:53] {AlejandroSosa} MSDE is SQL 7.0 Developer Edition.

[21:54] {LesPinter} Yup. Works fine. I actually had it installed on several machines without realizing that it was the personal edition. It's essential if you're going to practise.

[21:54] {AliceRiece} Yes, thanks and I'll check out your articles.

[21:54] {ChrisMccandless} Larry - MSDE (SQL Server Destop Edition) sounds like a great alternative to VFP data on the client.

[21:52] {DenisChasse} When should someone decide to go from .DBFs to SQL-Server on the back-end?

[21:55] {CarlKarsten} Look for an MSDE vs DBF Wiki page sometime next week, and perhaps even a Wednesday Night Lecture ;)

[21:55] {LarryMoody} I'll definitely look into it!

[21:56] {AlejandroSosa} Great lecture, Les. Thanks. Bye.

[21:56] {LesPinter} By the way, my ISP won't let me use VFP via ODBC to store data. I asked why. He said, "because I can charge you for SQL storage, but not for DBF storage." Duh...

[21:57] {LarryMoody} I agree! Great lecture. Thanks (not leaving yet, though)

[22:00] {Evan Delay} Anything else you want to cover?

[22:01] {LarryMoody} Les, could you say again when and where is your article?

[22:01] {LesPinter} So did that scratch anybody's itch?

[22:02] {Evan Delay} I am converting to Web Connect
Seriously, you have sold me on this. 30 minutes per form.

[22:02] {LarryMoody} Absolutely, Les!

[22:02] {SeanStenlund} I liked it a lot.

[22:02] {DenisChasse} Les: Thanks very much about this session. Before yours I saw another presentation on those tools. It looked to easy to be true. Tonight you proved that it really seems to be easy to use those tools.

[22:02] {FrankCamp} I'll put this knowledge in my backpack.

[22:02] {BarbaraPaltiel} Some new ideas, Les - all my Web Connect apps have been browser based, but this opens a new door.

[22:02] {LesPinter} Donde vives?

[22:03] {AlexFeldstein} Evan: Rick has a great support board with lots of "expert users".

[22:03] {LesPinter} Barbara, meet me at Peet's and I'll spill my guts for a decaf latte.

[22:04] {BarbaraPaltiel} Give me a call, Les - I'm in the book :-)

[22:04] {Evan Delay} BP and Les. How much more time is it to create a browser form that a VFP form with Web Connect?

[22:04] {LesPinter} Denis: Il n'y a pas de quoi

[22:05] {BarbaraPaltiel} Apples and oranges, Evan - can you design a screen faster in HTML or VFP Form Designer? The differences in capability between VFP and the browser are immense < mild understatement >

[22:05] {AlexFeldstein} Evan: You can create a browser form with any HTML visual generator. Rick has a great tool to convert to VFP text.

[22:05] {BarbaraPaltiel} I found I spent hours tweaking Java Script to validate fields that would take a minute or two in VFP.

[22:05] {LesPinter} Evan, it depends. Rick has a utility that will render a VFP form as HTML. But with HTML, if you request data, you get a completely new HTML form back. With a FoxPro app, you request data and get it while the form is up on the screen. So it's not a matter of whether or not it can be done in HTML, it's more about which is better for which applicaitons.

[22:06] {TonyReynolds} Great info tonight!! Bye all

[22:06] {LarryMoody} Les... so my client would need to house their data on/at an ISP server?

[22:07] {SeanStenlund} Larry: Preferably their own.

[22:07] {LarryMoody} But it could be on the nnn free megs of storage that they get from the ISP that hosts their web site, correct?

[22:07] {LesPinter} Larry, that's another issue. I finally got my own collocated server. ISPs don't like to run nonstandard software, and they definitely consider a FoxPro web server nonstandard.

[22:08] {LesPinter} Adios, yáll.

[22:08] {AlexFeldstein} Larry: There's several ISPs that are VFP friendly. Paul Mrozowski or Randy Pearson here can tell you more about it.

[22:08] {SeanStenlund} Les: You're very articulate and easy to understand. Thank you.

[22:08] {LesPinter} Evan, I'll be happy to do anything you think would be interesting and useful to the Forum.

[22:08] {Evan Delay} Les, thanks for giving the presentation tonight. *applause*

[22:08] {AlexFeldstein} Larry: I believe Rick has a listing in this site.

[22:08] {BarbaraPaltiel} It's not too hard to set up your own, either - took me about a day from a standing start - computer with NO operating system and an unformatted hard disk

[22:08] {PaulMrozowski} Rick has a list on his site (WC -friendly)

[22:10] {Evan Delay} Absolutely fantastic lecture. Easy squeezy

[22:10] {BarbaraPaltiel} That was very interesting. Something we can all dig into without a lot more training!

[22:11] {AlexFeldstein} Look at the samples Rick has in his site, www.west-wind.com. He also has a great whitepaper on using the Net as your LAN.

[22:12] {LarryMoody} Barbara, I may have some questions for you too later! :)

[22:12] {AlexFeldstein} G'nite everybody. See ya!

[22:12] {BarbaraPaltiel} Don't forget the hyphen in west-wind - otherwise you go someplace COMPLETELY different :-)

[22:12] {Evan Delay} Thanks everyone for showing up tonight.

[22:12] {BarbaraPaltiel} Larry, email is always open. Anything I can help with.
Carl - the SECOND time is easy. The first time setting up NTServer is the pits. Of course after that's done right then IIS is very simple.

[22:16] {LarryMoody} Correction... setting up a server is easy (if you know how)

[22:16] {CarlKarsten} Msde Setup
ahh, that kind of server
yea - IIS on NT (with ntfs security on the filesystem) is a pain

[22:17] {Evan Delay} Ah Larry. I see what you are talking about. A lecture on setting up NT Server right?

[22:19] {LarryMoody} Evan, yes, with the emphasis on storing data for internet apps as discussed here tonight.

[22:19] {LarryMoody} Which, I suppose means IIS as well.

[22:19] {Evan Delay} Carl did an IIS lecture last week.
Had you checked that out?

[22:20] {BarbaraPaltiel} Evan, there's a LOT still to learn - Carl only had 2 hours :-)

[22:20] {LarryMoody} Oops... maybe THAT should have been my first chat :)

[22:20] {Evan Delay} Okay, sounds like there is a need for parts 2 and 3

[22:21] {DenisChasse} Good night to you all

[22:21] {LarryMoody} I'll be watching for 'em. Thanks again and good night.

Session Close: Wed Nov 15 22:39:41 2000


Contributors: Les Pinter Evan Delay Cindy Winegarden
Category Wednesday Night Lectures Category Web Tools
( Topic last updated: 2000.11.25 01:00:31 PM )