Anda di halaman 1dari 40

Web-Services

in Visual FoxPro 9.0


FoxPro User Group of German language
Rainer Becker
Presentation at SDN 15 Sep 2006
WEB
Working with WebServices
Friday, 15.09.2006, 13:00 14:15
Visual FoxPro is most often used for rapid application
development of Desktop-applications but also for
Client/Server applications, both sometimes running on
Terminal Services for ease of deployment.
But you can also create WebServices with this powerfull
development environment without any problems!
The fast database and string functions allow the creation of
fast services for distributed applications.
Rainer Becker

dFPUG
Online offers
Loose Leaf Magazine
VFP-DevCon
VFP-Lokal/Develop
Framework Visual Extend
MVP, MCP, ISV
Wizards & Builders GmbH
Where do I get VFP ?
Update from 6.0, 7.0, 8.0 or VS 97
Not for VFP 5.0 or older
International or US/Canada-Version
different pricing
technical identical
no problem in The Netherlands
dFPUG offers localization
we could create a Dutch version if someone is interested
Topics
Existing WebServices
Calling WebServices
Definitions and versions
Preparation
SOAP-Toolkit
IIS-Configuration
Additional hints
Other ways to skin a cat
Remarks
You always need a COM-Server!
Creating COM-Servers is a different session
Please create a COM-Server first and test it
and maybe have a look at existing WebServices
The calling logic in the Internet is different in general.
Therefore business objects are not really usable if they are not
designed for one-time-calls. Separate COM-Servers are often
easier to use!
WebServices have to be strongly typed which is only optional
for COM-Server, maybe create a separate PRG with
For deployment you always need a Windows Webserver in the
Internet
Existing WebServices
Instead creating a WebService directly you should
first have a look at existing WebServices, e.g.:
FoxWiki (http://fox.wikis.com)
Universal Thread (http://www.universalthread.com)
ProFox (http://www.leafe.com)
FoxCentral (http://www.foxcentral.com)
Google, Amazon, eBay, FedEx, WhoIs,
CurrencyConverter, BabelFish, Headline News
dFPUG-Portal (see http://apf.dfpug.de)
dFPUG-Forum (see Visual Extend example)
And Again: The TaskPane!
Client for WebServices
Interactive Testing with the Taskpane
Integration into your own forms:
Open the Form
Open the Toolbox
Drag & Drop the class WebService onto the form
Select the object with the mouse
Right mouseclick for Builders
Call the XML WebService Builders
WebService-class in your form
Enter parameters
View results as XML
View results in Grid
Testing:
Match parameters and output
Use complex data
Thats it for calling a WebService
Since Visual FoxPro 8.0 there are powerfull tools that
support developers in calling WebServices
Before creating your first own WebSerivce have a
look
This could easily fill a another complete session
There are multiple articles available as well as the
updatebook for Visual FoxPro 8.0!
Definitions
WSDL: Web Service Description Language
XML-description similar to a COM-server definition
WSML: Web Service Meta Language
COM-Reference, see Program
Files\MSSOAP\SOAP.CHM
UDDI: Universal Description, Discovery, Integration
List of available WebServices, seldomly really used
SOAP: Simple Object Access Protocoll
SOA: Service Oriented Architecture
Version History
Introduction of WebServices in:
Visual FoxPro 7.0 with SOAP-Toolkit 2.0
Current: Visual FoxPro 9.0 mit SOAP-Toolkit 3.0
Lifecycle-Support
Visual FoxPro 9.0 till 2014
SOAP-Toolkit till 2013 (for VFP ONLY!)
In the future: WebServices via INDIGO
With WinFX as AddOn for XP as well as in Vista
encapsulates VFP-WebServices completly in .NET
this even includes runtime file inclusion/distribution/registration
Usefull WebServices in Apps
Examples from the Framework Visual Extend 9.5:
Posting of messages in Support-Forum
Sending of error messages to error database
Registration of users for trial version
Orders of users (update from trial to full version)
Download of Updates
If Internet or WebServices (Firewalls!!!) not available
eMail is used instead
No WebService needed for VFX-Taskpane
Active FoxPro Pages used instead, see http://afp.dfpug.de
Prepare a COM-Server
Creation option:
Multi-Threaded
COM-Server

Minimum
1x OLEPUBLIC
1 WebService per
OLEPUBLIC
Max. 1 Webservice
WebService Creation
Projektinfo Servers:
Multi-Use
Project Name

Multi-Threaded and
Multi Use: needed
for Internet due to
RAM constraints!
WebService Publishing Wizard
Call the WebService-
Builders in project
Check the path
Opt. Select a class
Opt. additional options
Extended Options
Optionally use
extended options:
Switch to ASP
ProjectHook
Wsphook in
_webservices
Save in table
FOXWS.DBF in
_FOXCODE
Create IntelliSense-
Script
Virtual directory in IIS
Created auto-
matically for you
Differences
between Path,
virtual directory
and startup
directory!
Ask you
administrator <g>.
Builder Results
.WSDL
(Description)
.WSML
(Meta/COM)
Opt. additional
ASP-page
will be called
directly
ProjectHook for re-
generation each
time you change
Register at IntelliSense
Register the class under Types / Web Services in the
IntelliSense- Manager

Call the WebServices
IntelliSense creates the needed Code for you:






and shows all methods that can be called
What can go wrong?
Potential problems (OLE-error messages):
with paths:
Windows/System32
(Runtime)
CD JUSTPATH(
_VFP.ServerName)
Problemes with SOAPISAP.DLL (install or use ASP)
Registration of Listener (1)
Registration of
SOAPISAP.DLL for
performant ISAPI-
Listeners:

1. Default-Website,
Properties, Home
Directory
2. Button Configuration
3. Select the extension
.WSDL
Registration of Listener (2)
Select C:\Program Files\Common
Files\MSSoap\Binaries\soapisap.dll
If not visible:
Select e.g. INI
and change it


NOT on WinXP

Alternate Call: SOAP-Client
Instead of using the classes of Visual FoxPro you can
also directly access WebServices via SOAP-Client:
Code example:

lows = NEWOBJECT("MSSOAP.SoapClient30")
lows.MSSoapInit(
"http://dlab.homeip.net/webservices/dlab.wsdl")
? lows.timechecker()

Much easier way to call but you have to do it yourself
Integrating minimum security
Internet Information Services
Properties of virtual directory
Page Directory Security
Disable anonymous access
Enable standard authentication

Or extend the above code example:
lows.ConnectorProperty("AuthUser") = "username"
lows.ConnectorProperty("AuthPassword")= "password"
Type declaration important!
Strong typing required for parameters/return value
can only be done programmatically, see COM
FUNCTION getnews (ldDate as Date) as String
Re-Publish via Wizard necessary so that
<message name='hwpclass.getnews'>
</message>
is changed to the correct new definition for you:
<message name='hwpclass.getnews'>
<part name='ldDate' type='xsd:dateTime'/>
</message>
Call COM-Server indirectly
Create a programm to call the COM-Server

DEFINE CLASS MyCOMInterface AS Custom OLEPUBLIC
FUNCTION MyMethod (MyParm AS String) AS String
LOCAL o AS myclass
o = CREATEOBJECT("myclass")
RETURN o.MyMethod(MyParm)
ENDDEFINE

Now you can change the COM-Server as often as you like
without having to republish it (if interface remains the same)
Creation: Release the DLL

Computer Mgmt:
Restart IIS
or: IISRESET at the
DOS-Prompt
or: KILL.EXE to
remove DLL from
memory without
questions asked
In a lot of case you can have
an easier start
Multiple examples available at
http://afp.dfpug.de
Creation of AFP-Pages
Using Visual FoxPro as a script language in HTML-
Pages with Active FoxPro Pages (AFP/AFX):
<% FoxPro-Code %>

See examples at http://afp.dfpug.de
Create pre-formatted HTML-tables with parameters
Return RSS
Return XML
See usage examples at http://portal.dfpug.de
Web applications:
VFXAFX Wizard
Internet-forms via mouse click!
Prerequisites:
VFX 9.5 and VFP 9.0 SP1
AFX
like ASP, but based on VFP
IIS
FoxPro-version under creation for AFX
Scalability:
via AFP for multipel parallel users / AFX for 10 users
Articles
02-16 Creation of WebServices in Visual FoxPro
06-15 Program your Data
06-32 Searching with WebServices
06-35 Publish your first WebService 1
06-36 Publish your first WebService 2
06-37 Publish your first WebService 3
07-16 Search with VFP in Google
01-03 Working with WebServices in VFP7 (New18)
Extensions of COM and WebServices in VFP 8.0
Whats New in Visual FoxPro 7.0 Chapter 15
Additional material
Visual FoxPro 9.0
Update book
Visual FoxPro 8.0
Update book
Articles
FoxTalk
FoxPro Advisor
FoxX Professional (German)

Thank you very much!
Send questions hotline@dfpug.de
or (better) http://forum.dfpug.de

Visit our websites: http://www.dfpug.de, http://portal.dfpug.de,
http://forum.dfpug.de, http://newsletter.dfpug.de,
http://devcon.dfpug.de, http://roadshow.dfpug.de,
http://www.visualextend.de, http://www.linuxtransfer.de,
http://www.visualfoxpro.de
Riddle of the day
? CHRTRAN(CHRTRAN('S6O1 W2S634G 5789',
'6789', 'TIME()'), '12345','PAINT()')

Anda mungkin juga menyukai