Professional Documents
Culture Documents
Vfpws
Vfpws
FoxPro
McAlister Merchant
Microsoft Corporation
Created: March 2001
Revised: March 2001
Applies To: Microsoft Visual FoxPro
Summary
Web Services can be available anywhere. You can create them yourself, or you can
access them over the Web from wherever they happen to be published. You can use
Visual FoxPro to create Web Services, and if you register them in IntelliSense, Visual
FoxPro makes it possible for you to access them almost automatically. You also can use
Visual FoxPro to access Web Services created in other languages.
Contents
Web Services
Establishing a Virtual Directory
Creating a Project
Creating a COM Server
Creating and Publishing a Web Service
Registering a Web Service
Using a Web Service
Introduction
Creating Web Services using Microsoft Visual FoxPro 7.0 is a complex process that
involves using Microsoft Internet Information Services (IIS), Visual FoxPro COM
servers, and Simple Object Access Protocols (SOAP). You use IIS to create a virtual
directory that references the location on your hard disk where you place your services.
IIS can be installed as part of the Microsoft Windows NT 4.0 Option Pack, with
Microsoft Windows 2000 Professional, or automatically with Windows 2000 Server.
Then, you can use the Project manager to create or to compile COM objects. When the
COM objects are created, you can use the Visual FoxPro Web Services wizard to publish
them in your virtual directory.
You can use the IntelliSense manager to register Web Services with Visual FoxPro, so
the placement of the Web Service and necessary calling routines in code is expedited.
This paper walks you through the processes involved in making Web Services of your
existing COM servers and preparing Web Services for use. You create, from a COM
server, a very simple Web Service that is accessible through HTTP by anyone. This Web
Service provides a simple report of the current directory and how many .jpg files are
there.
Web Services
Web Services extend the accessibility to your own COM servers, as well as making Web
Services from other developers accessible to you through your browser.
Web Services provide functionality and access to data between platforms and across
diverse connections. You create and use Web Services to provide or to gain functionality
from wherever it happens to reside. The most important aspect of Web Services is that,
because of the way they use the HTTP protocol and the SOAP proxy, functionality is
available through firewalls. Because HTTP and SOAP are platform agnostic, Web Services
are also platform agnostic. In some cases, this can provide functionality that was
unavailable under COM alone.
To publish a Web Service, you must create a virtual directory in IIS, and then create or
copy a COM server from which you generate a Web Service to your virtual directory.
Creating a Project
The Project manager is the most fundamental application-building tool in Visual FoxPro.
Within a Visual FoxPro project, you can assemble documents of all types, data, classes,
code, and other file types. A project provides access to all the components you might
want to include in a server and contains them for compilation. In this example, you use
the project to compile your Web Service.
To create a project
1. In the File menu, select New.
2. In the New dialog box, select Project, and click New file.
3. In the Create dialog box, select the Web Services folder you created earlier, and
name your project myWServ1.
4. Click Save.
Now, you have created your project in the Web Services folder. This makes it possible
for you to save and compile the project to the correct folder automatically when you
have finished adding components to it.
Name = "showem"
PROCEDURE justshow
howmany=ADIR(afilArry,"*.jpg")
IF howmany <1
fileNm="no"
ELSE
fileNm=ALLTRIM(STR(howmany))
ENDIF
This program defines one class, showem, which has one method, justshow.
5. Close the edit window, and in the Save As dialog box, name the program
myWServ1, and click Save.
6. Make sure myWServ1 is set to Main. (You can tell if it is set to Main, because it will
be in bold font.) If it is not, in the Project Manager, right-click myWServ1, and
click Set Main in the shortcut menu.
To compile the COM server
1. In the Project Manager, click the Build button.
2. Select Single-threaded COM server.
3. Click OK, and accept the name myWServ1.
Visual FoxPro will compile the myWServ1 file into a COM server, after which you can
turn this COM server into a Web Service.