View
249
Download
4
Tags:
Embed Size (px)
Citation preview
Web-ServicesWeb-Servicesin Visual FoxPro 9.0in Visual FoxPro 9.0
FoxPro User Group of German languageFoxPro User Group of German language
Rainer BeckerRainer Becker
Presentation at SDN 15 Sep 2006Presentation at SDN 15 Sep 2006
WEB
Working with WebServicesWorking with WebServices
Friday, 15.09.2006, 13:00 – 14:15Friday, 15.09.2006, 13:00 – 14:15 Visual FoxPro is most often used for rapid application Visual FoxPro is most often used for rapid application
development of Desktop-applications but also for development of Desktop-applications but also for Client/Server applications, both sometimes running on Client/Server applications, both sometimes running on Terminal Services for ease of deployment.Terminal Services for ease of deployment.
But you can also create WebServices with this powerfull But you can also create WebServices with this powerfull development environment without any problems!development environment without any problems!
The fast database and string functions allow the creation of The fast database and string functions allow the creation of fast services for distributed applications.fast services for distributed applications.
Rainer BeckerRainer Becker
dFPUGdFPUG Online offersOnline offers Loose Leaf MagazineLoose Leaf Magazine
VFP-DevConVFP-DevCon VFP-Lokal/DevelopVFP-Lokal/Develop Framework Visual ExtendFramework Visual Extend MVP, MCP, ISVMVP, MCP, ISV Wizards & Builders GmbHWizards & Builders GmbH
Where do I get VFP ?Where do I get VFP ?
Update from 6.0, 7.0, 8.0 or VS 97Update from 6.0, 7.0, 8.0 or VS 97 Not for VFP 5.0 or olderNot for VFP 5.0 or older
International or US/Canada-VersionInternational or US/Canada-Version different pricingdifferent pricing technical identicaltechnical identical no problem in The Netherlandsno problem in The Netherlands
dFPUG offers localizationdFPUG offers localization we could create a Dutch version if someone is interested…we could create a Dutch version if someone is interested…
TopicsTopics
Existing WebServicesExisting WebServices Calling WebServicesCalling WebServices Definitions and versionsDefinitions and versions PreparationPreparation SOAP-ToolkitSOAP-Toolkit IIS-ConfigurationIIS-Configuration Additional hintsAdditional hints Other ways to skin a catOther ways to skin a cat
RemarksRemarks You always need a COM-Server!You always need a COM-Server!
Creating COM-Servers is a different session…Creating COM-Servers is a different session… Please create a COM-Server first and test it…Please create a COM-Server first and test it… and maybe have a look at existing WebServices…and maybe have a look at existing WebServices…
The calling logic in the Internet is different in general. The calling logic in the Internet is different in general. Therefore business objects are not really usable if they are not Therefore business objects are not really usable if they are not designed for one-time-calls. Separate COM-Servers are often designed for one-time-calls. Separate COM-Servers are often easier to use!easier to use!
WebServices have to be strongly typed which is only optional WebServices have to be strongly typed which is only optional for COM-Server, maybe create a separate PRG with for COM-Server, maybe create a separate PRG with
For deployment you always need a Windows Webserver in the For deployment you always need a Windows Webserver in the Internet…Internet…
Existing WebServices Existing WebServices Instead creating a WebService directly you should Instead creating a WebService directly you should
first have a look at existing WebServices, e.g.:first have a look at existing WebServices, e.g.: FoxWiki (http://fox.wikis.com)FoxWiki (http://fox.wikis.com) Universal Thread (http://www.universalthread.com)Universal Thread (http://www.universalthread.com) ProFox (http://www.leafe.com)ProFox (http://www.leafe.com) FoxCentral (http://www.foxcentral.com)FoxCentral (http://www.foxcentral.com) Google, Amazon, eBay, FedEx, WhoIs, Google, Amazon, eBay, FedEx, WhoIs,
CurrencyConverter, BabelFish, Headline NewsCurrencyConverter, BabelFish, Headline News dFPUG-Portal (see http://apf.dfpug.de)dFPUG-Portal (see http://apf.dfpug.de) dFPUG-Forum (see Visual Extend example)dFPUG-Forum (see Visual Extend example)
And Again: The TaskPane!And Again: The TaskPane!
Client for WebServicesClient for WebServices
Interactive Testing with the TaskpaneInteractive Testing with the Taskpane Integration into your own forms:Integration into your own forms:
Open the FormOpen the Form Open the ToolboxOpen the Toolbox Drag & Drop the class WebService onto the formDrag & Drop the class WebService onto the form Select the object with the mouseSelect the object with the mouse Right mouseclick for BuildersRight mouseclick for Builders Call the XML WebService BuildersCall the XML WebService Builders
WebService-class in your formWebService-class in your form
Enter parametersEnter parameters View results as XMLView results as XML View results in GridView results in Grid
Testing:Testing:
Match parameters and outputMatch parameters and output
Use complex dataUse complex data
Thats it for calling a WebServiceThats it for calling a WebService
Since Visual FoxPro 8.0 there are powerfull tools that Since Visual FoxPro 8.0 there are powerfull tools that support developers in calling WebServices…support developers in calling WebServices…
Before creating your first own WebSerivce have a Before creating your first own WebSerivce have a look…look…
This could easily fill a another complete session…This could easily fill a another complete session… There are multiple articles available as well as the There are multiple articles available as well as the
updatebook for Visual FoxPro 8.0!updatebook for Visual FoxPro 8.0!
DefinitionsDefinitions
WSDL: Web Service Description LanguageWSDL: Web Service Description Language XML-description similar to a COM-server definitionXML-description similar to a COM-server definition
WSML: Web Service Meta LanguageWSML: Web Service Meta Language COM-Reference, see Program Files\MSSOAP\COM-Reference, see Program Files\MSSOAP\
SOAP.CHMSOAP.CHM UDDI: Universal Description, Discovery, IntegrationUDDI: Universal Description, Discovery, Integration
List of available WebServices, seldomly really usedList of available WebServices, seldomly really used SOAP: Simple Object Access ProtocollSOAP: Simple Object Access Protocoll SOA: Service Oriented ArchitectureSOA: Service Oriented Architecture
Version HistoryVersion History
Introduction of WebServices in:Introduction of WebServices in:Visual FoxPro 7.0 with SOAP-Toolkit 2.0Visual FoxPro 7.0 with SOAP-Toolkit 2.0
Current: Visual FoxPro 9.0 mit SOAP-Toolkit 3.0Current: Visual FoxPro 9.0 mit SOAP-Toolkit 3.0 Lifecycle-SupportLifecycle-Support
Visual FoxPro 9.0 till 2014Visual FoxPro 9.0 till 2014 SOAP-Toolkit till 2013 (for VFP ONLY!)SOAP-Toolkit till 2013 (for VFP ONLY!)
In the future: WebServices via INDIGOIn the future: WebServices via INDIGO With WinFX as AddOn for XP as well as in VistaWith WinFX as AddOn for XP as well as in Vista encapsulates VFP-WebServices completly in .NET encapsulates VFP-WebServices completly in .NET
this even includes runtime file inclusion/distribution/registrationthis even includes runtime file inclusion/distribution/registration
Usefull WebServices in AppsUsefull WebServices in Apps
Examples from the Framework Visual Extend 9.5:Examples from the Framework Visual Extend 9.5: Posting of messages in Support-ForumPosting of messages in Support-Forum Sending of error messages to error databaseSending of error messages to error database Registration of users for trial versionRegistration of users for trial version Orders of users (update from trial to full version)Orders of users (update from trial to full version) Download of UpdatesDownload of Updates
If Internet or WebServices (Firewalls!!!) not available If Internet or WebServices (Firewalls!!!) not available eMail is used instead…eMail is used instead…
No WebService needed for VFX-Taskpane…No WebService needed for VFX-Taskpane… Active FoxPro Pages used instead, see http://afp.dfpug.deActive FoxPro Pages used instead, see http://afp.dfpug.de
Prepare a COM-ServerPrepare a COM-Server
Creation option: Creation option: Multi-Threaded Multi-Threaded COM-ServerCOM-Server
MinimumMinimum1x OLEPUBLIC1x OLEPUBLIC
1 WebService per1 WebService perOLEPUBLICOLEPUBLIC
Max. 1 WebserviceMax. 1 Webservice
WebService CreationWebService Creation
Projektinfo Servers:Projektinfo Servers: Multi-UseMulti-Use Project NameProject Name
Multi-Threaded and Multi-Threaded and Multi Use: needed Multi Use: needed for Internet due to for Internet due to RAM constraints!RAM constraints!
WebService Publishing WizardWebService Publishing Wizard
Call the WebService-Call the WebService-Builders in project Builders in project Check the pathCheck the path Opt. Select a classOpt. Select a class Opt. additional optionsOpt. additional options
Extended OptionsExtended Options
Optionally use Optionally use extended options:extended options:Switch to ASPSwitch to ASP
ProjectHookProjectHook Wsphook in Wsphook in
_webservices_webservices
Save in table Save in table FOXWS.DBF in FOXWS.DBF in _FOXCODE_FOXCODE
Create IntelliSense-Create IntelliSense-ScriptScript
Virtual directory in IISVirtual directory in IIS
Created auto-Created auto-matically for youmatically for you
Differences Differences between Path, between Path, virtual directory virtual directory and startup and startup directory!directory!
Ask you Ask you administrator <g>.administrator <g>.
Builder ResultsBuilder Results .WSDL .WSDL
(Description)(Description) .WSML .WSML
(Meta/COM)(Meta/COM) Opt. additional Opt. additional
ASP-pageASP-page will be called will be called
directlydirectly
ProjectHook for re-ProjectHook for re-generation each generation each time you changetime you change
Register at IntelliSenseRegister at IntelliSense
Register the class under Types / Web Services in the Register the class under Types / Web Services in the IntelliSense- ManagerIntelliSense- Manager
Call the WebServicesCall the WebServices IntelliSense creates the needed Code for you:IntelliSense creates the needed Code for you:
and shows all methods that can be called…and shows all methods that can be called…
What can go wrong?What can go wrong?
Potential problems (OLE-error messages):Potential problems (OLE-error messages): with paths:with paths:
Windows/System32Windows/System32(Runtime)(Runtime)
CD JUSTPATH(CD JUSTPATH(_VFP.ServerName)_VFP.ServerName)
Problemes with SOAPISAP.DLL (install or use ASP)Problemes with SOAPISAP.DLL (install or use ASP)
Registration of Listener (1)Registration of Listener (1) Registration of Registration of
SOAPISAP.DLL for SOAPISAP.DLL for performant ISAPI-performant ISAPI-Listeners:Listeners:
1.1. Default-Website, Default-Website, Properties, Home Properties, Home DirectoryDirectory
2.2. Button ConfigurationButton Configuration
3.3. Select the Select the extension .WSDLextension .WSDL
Registration of Listener (2)Registration of Listener (2)
Select C:\Program Files\Common Files\MSSoap\Select C:\Program Files\Common Files\MSSoap\Binaries\soapisap.dllBinaries\soapisap.dll
If not visible:If not visible:Select e.g. INISelect e.g. INIand change itand change it
NOT on WinXP…NOT on WinXP…
Alternate Call: SOAP-ClientAlternate Call: SOAP-Client
Instead of using the classes of Visual FoxPro you can Instead of using the classes of Visual FoxPro you can also directly access WebServices via SOAP-Client:also directly access WebServices via SOAP-Client:
Code example:Code example:
lows = NEWOBJECT("MSSOAP.SoapClient30")lows = NEWOBJECT("MSSOAP.SoapClient30")
lows.MSSoapInit(lows.MSSoapInit("http://dlab.homeip.net/webservices/dlab.wsdl")"http://dlab.homeip.net/webservices/dlab.wsdl")
? lows.timechecker()? lows.timechecker()
Much easier way to call but you have to do it yourselfMuch easier way to call but you have to do it yourself
Integrating minimum securityIntegrating minimum security
Internet Information ServicesInternet Information Services Properties of virtual directoryProperties of virtual directory Page Directory SecurityPage Directory Security
Disable anonymous accessDisable anonymous access Enable standard authenticationEnable standard authentication
Or extend the above code example:Or extend the above code example:
lows.lows.ConnectorProperty("AuthUser") = "username"ConnectorProperty("AuthUser") = "username"
lows.lows.ConnectorProperty("AuthPassword")= "password"ConnectorProperty("AuthPassword")= "password"
Type declaration important!Type declaration important!
Strong typing required for parameters/return valueStrong typing required for parameters/return value can only be done programmatically, see COMcan only be done programmatically, see COM FUNCTION getnews (ldDate as Date) as StringFUNCTION getnews (ldDate as Date) as String
Re-Publish via Wizard necessary so thatRe-Publish via Wizard necessary so that<message name='hwpclass.getnews'><message name='hwpclass.getnews'>
</message></message>
is changed to the correct new definition for you:is changed to the correct new definition for you:<message name='hwpclass.getnews'><message name='hwpclass.getnews'>
<part name='ldDate' type='xsd:dateTime'/><part name='ldDate' type='xsd:dateTime'/>
</message></message>
Call COM-Server indirectlyCall COM-Server indirectly
Create a programm to call the COM-ServerCreate a programm to call the COM-Server
DEFINE CLASS MyCOMInterface AS Custom OLEPUBLICDEFINE CLASS MyCOMInterface AS Custom OLEPUBLIC
FUNCTION MyMethod (MyParm AS String) AS StringFUNCTION MyMethod (MyParm AS String) AS String
LOCAL o AS myclassLOCAL o AS myclass
o = CREATEOBJECT("myclass")o = CREATEOBJECT("myclass")
RETURN o.MyMethod(MyParm)RETURN o.MyMethod(MyParm)
ENDDEFINEENDDEFINE
Now you can change the COM-Server as often as you like Now you can change the COM-Server as often as you like without having to republish it (if interface remains the same) without having to republish it (if interface remains the same)
Creation: Release the DLLCreation: Release the DLL
Computer Mgmt: Computer Mgmt: Restart IISRestart IIS
or: IISRESET at the or: IISRESET at the DOS-PromptDOS-Prompt
or: KILL.EXE to or: KILL.EXE to remove DLL from remove DLL from memory without memory without questions askedquestions asked
In a lot of case you can have In a lot of case you can have an easier startan easier start
Multiple examples available at Multiple examples available at http://afp.dfpug.dehttp://afp.dfpug.de
Creation of AFP-PagesCreation of AFP-Pages
Using Visual FoxPro as a script language in HTML-Using Visual FoxPro as a script language in HTML-Pages with Active FoxPro Pages (AFP/AFX): Pages with Active FoxPro Pages (AFP/AFX):
<% FoxPro-Code %><% FoxPro-Code %>
See examples at http://afp.dfpug.deSee examples at http://afp.dfpug.de Create pre-formatted HTML-tables with parametersCreate pre-formatted HTML-tables with parameters Return RSSReturn RSS Return XMLReturn XML
See usage examples at http://portal.dfpug.de See usage examples at http://portal.dfpug.de
Web applications:Web applications:VFX–AFX WizardVFX–AFX Wizard
Internet-forms via mouse click!Internet-forms via mouse click!
Prerequisites:Prerequisites: VFX 9.5 and VFP 9.0 SP1VFX 9.5 and VFP 9.0 SP1 AFXAFX
like ASP, but based on VFPlike ASP, but based on VFP
IISIIS FoxPro-version under creation for AFXFoxPro-version under creation for AFX
Scalability:Scalability: via AFP for multipel parallel users / AFX for 10 usersvia AFP for multipel parallel users / AFX for 10 users
ArticlesArticles 02-16 Creation of WebServices in Visual FoxPro02-16 Creation of WebServices in Visual FoxPro 06-15 Program your Data06-15 Program your Data 06-32 Searching with WebServices06-32 Searching with WebServices 06-35 Publish your first WebService 1 06-35 Publish your first WebService 1 06-36 Publish your first WebService 2 06-36 Publish your first WebService 2 06-37 Publish your first WebService 3 06-37 Publish your first WebService 3 07-16 Search with VFP in Google07-16 Search with VFP in Google 01-03 Working with WebServices in VFP7 (New18)01-03 Working with WebServices in VFP7 (New18) Extensions of COM and WebServices in VFP 8.0 Extensions of COM and WebServices in VFP 8.0 Whats New in Visual FoxPro 7.0 Chapter 15 Whats New in Visual FoxPro 7.0 Chapter 15
Additional materialAdditional material
Visual FoxPro 9.0Visual FoxPro 9.0 Update bookUpdate book
Visual FoxPro 8.0Visual FoxPro 8.0 Update bookUpdate book
ArticlesArticles FoxTalkFoxTalk FoxPro AdvisorFoxPro Advisor FoxX Professional (German)FoxX Professional (German)
Thank you very much!Thank you very much!
Send questions [email protected] questions [email protected] (better) http://forum.dfpug.de or (better) http://forum.dfpug.de
Visit our websites: Visit our websites: http://www.dfpug.dehttp://www.dfpug.de, , http://portal.dfpug.dehttp://portal.dfpug.de, , http://forum.dfpug.dehttp://forum.dfpug.de, , http://newsletter.dfpug.dehttp://newsletter.dfpug.de, , http://devcon.dfpug.dehttp://devcon.dfpug.de, , http://roadshow.dfpug.dehttp://roadshow.dfpug.de, ,
http://www.visualextend.dehttp://www.visualextend.de, , http://www.linuxtransfer.dehttp://www.linuxtransfer.de, , http://www.visualfoxpro.dehttp://www.visualfoxpro.de
Riddle of the dayRiddle of the day
? CHRTRAN(CHRTRAN('S6O1 W2S634G 5789', ? CHRTRAN(CHRTRAN('S6O1 W2S634G 5789', '6789', 'TIME()'), '12345','PAINT()')'6789', 'TIME()'), '12345','PAINT()')