What is Web Connection

Web Connection is a complete Web application framework for developing scalable Web applications with Visual FoxPro. It is a proven development platform with a 20 year history that has proven itself stable for a wide variety of Web and Service based applications from small to large scale.

Web Connection lets you use FoxPro code to respond to Web requests from a Windows based Web servers using the same language and development environment that you've always used to build other types of applications. Use the FoxPro IDE to develop your apps, use the FoxPro debugger to step through code and use just about any non-UI FoxPro code as part of your Web applications.

Web Connection builds either plain EXE files or COM Objects that are hosted by the Web server and fire request information into the Web Connection server.

Web Connection provides the following:

  • Low level Web Server Connector Interface to IIS, IIS Express and Apache
  • FoxPro Server implementation that captures Web requests
  • FoxPro abstractions to capture Web request data and produce HTTP output
  • Simple routing of Web requests to markup pages or methods in your classes
  • A number of frameworks to help you generate HTTP output
  • Tools to facilitate deploying your FoxPro Web applications

All FoxPro - All The Time

Once code hits the FoxPro server, everything else runs inside of FoxPro. The Web Connection framework is 100% written in FoxPro and comes with source code so you can step through the Web Connection code and even modify it if you choose. Web Connection is not a black box.

Web Server Integration

Web Connection ships with a number of connectors that interface with various Windows Web Servers. The primary interface is for IIS and IIS Express, but Apache is also support. These connectors are low level interfaces implemented at the Web Server that capture request information and forward it to the Web Connection FoxPro Server.

Web Connection FoxPro Server

The core framework provides a wwServer base class that you inherit from. This server knows how to communicate with the low level connector interface and is called whenever a request comes in. You can run multiple simultaneous instances of the servers you implement to handle simultaneous requests.

The core Web Connection framework provides a base level of abstraction that handles routing of requests to your custom classes, which you implement for HTTP endpoints. In essence you create a method in a class for each HTTP end point your want to handle. Web Connection provides you with intrinsic objects like Request, Response, Server, Session and Process that you can use to capture input information, server status and state, and generate output to send back to the server.

Web Connection then provides a number of different frameworks that sit on top of the core engine to provide tools to make it easier to generate HTTP and HTML output.

HTML Generation

Web Connection provides you with lots of choices for generating output from your application.

Code Level Html

At the lowest level you can do everything in code - respond to requests, picking up request data with pure code and running your own FoxPro code to generate HTML output using the raw Request and Response object. Generating HTML output is as simple using:

Response.Write("<h1>Hello World</h1>")

from a method.

Model, View, Controller with Scripts and Templates

Web Connection supports MVC (Model, View, Controller) style development using code based Controllers (Process Methods) combined with Views implemented in Scripts and Templates, which allow you to externalize the HTML output generation. Scripts and Templates allow you to HTML markup mixed with FoxPro expressions and code to produce data driven HTML output.

Here's a simple example. You can implement code based logic in a controller method inside of a Web Connection wwProcess class:

FUNCTION CustomerList
PRIVATE pcMessage

pcMessage = "Current time is: " + TIME()
SELECT * from Customers INTO Cursor TCustomers

*** Causes script page to be loaded and evaluated
Response.ExpandScript()  && loads CustomerList.wwd script

ExpandScript() then loads the following script page that renders the cursor (partial of relevant markup displayed):

<div class="alert alert-info">
    <i class="fa fa-info-circle"></i>
    <%= EncodeHtml(pcMessage) %>

<h2>Customer List</h2>
<hr />
  SELECT TCustomers
   <div class="customer-item">
        <div class="customer-header"><%= TCustomers.Company %></div>
            <%= DisplayMemo(Tcustomers.Address) %>

This allows you to manage business objects (Model) (or direct data access using FoxPro Commands), with the coordinating logic that sets up a model for rendering (Controller Code) and then delegate the actual HTML output generation to a script or template (View).

MVC is a popular development paradigm that's used in many other development environments like ASP.NET MVC, Ruby on Rails, or ExpressJs on Node and many more.

For more info see:
Templates and Scripts

Web Control Framework

Another UI framework in Web Connection is the Web Control Framework which provides a control based ASP.NET like environment for creating HTML layout. Using a control based framework allows you to drop controls onto an HTML page and then programmatically control various attributes of these control through the code behind these pages. There's also extensive databinding support in these controls to make it easy to hook up data.

WCF allows for visual integration with Visual Studio using the ASP.NET editors to drag and drop controls and use control editors to set properties and perform common operations.

The syntax for these controls looks something like this:

<ww:TextBox runat="server" id="txtCompany" 
            ControlSource="this.Page.oCustomer.oData.Company" />

and you can reference these controls via FoxPro code from the codebehind for a page:

*** Direct control access
this.txtCompany.Value = "New Company"
this.txtCompany.CssClass = "new-customer"

*** Databinding
this.oCustomer.oData.Company = "New Company"
this.Page.DataBind() && bind page controls

REST Services

Web Connection has built-in support for creating REST based JSON services that automatically produce JSON output. Using REST services you can easily build HTTP based endpoints that serve JSON data in response to requests. The framework makes it very simple to create methods that take a single input parameter that is parsed from JSON into a FoxPro object, and lets you return a result value or cursor that is turned into JSON. Building a service endpoint is essentially as easy as creating a method that returns data.

JSON Serialization and the JSON Service feature are also available individually so you can serialize and deserialize JSON manually, or add JSON Service like features to existing Web Connection applications.

Creating a REST service method that receives a JSON input and returns a JSON result is as simple as:


loQuoteServer = CREATEOBJECT("StockServer")
loQuote = loQuoteServer.GetQuote(lcSymbol)

RETURN loQuote

for more info see:
Using the wwRestProcess Class

PDF Output

You can generate output from FoxPro reports to PDF files using the wwPDF class. Using Ghostscript or a number of other third party PDF tools, you can generate PDF output from your Web Connection applications.

Build your own Framework

Web Connection provides both high level framework features as described in the previous sections, but it can also provide the tools to build a low level framework with your own custom behaviors. You can intercept requests at any level, right from when a requests hits Web Connection to right when it fires off into process classes. It's easy to create your own framework or rendering engine that can plug into Web Connection. A number of frameworks like FoxInCloud build ontop of Web Connection to provide high level features on top of what Web Connection provides.

Configuration Tools

Web Connection 6.0 and later includes a number of tools to help with server configuration and it generates a configuration script you can use to configure your Web Server. Using the new project structure in WC6 and later, projects are self-contained and mostly xcopy deployable, and using the configuration script makes it easy to deploy your server once it's ready.

Tools, Tools, Tools

Web Connection also comes with a large general purpose library of FoxPro utilities for general purpose development. It includes libraries for Internet Protocols including HTTP, FTP, SMTP, POP3 and more. There are libraries for interfacing cleanly with .NET, serializing JSON and XML, for creating multi-threaded FoxPro components, configuration, and much, much more.

For more info see Utility Classes

© West Wind Technologies, 1996-2018 • Updated: 03/05/16
Comment or report problem with topic