INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

Internet

How to consume a web service in VFP by mgagnon
Posted: 30 Sep 03 (Edited 30 Sep 03)

Note: This requires VFP7.0 minimum and SOAP tool kit version 2.0 minimum.
"http://www.microsoft.com/downloads/details.aspx?FamilyId=147ED727-0BE8-48A1-B1DA-D50B1EA582CB&displaylang=en"

In order to consume a Web service, you first need an actual web service. This following example assumes you have a web service. (This FAQ is based on a web service in Visual Studio .NET and it works like a DLL where there is no interface). All it does it takes two paramaters, one being a postal code (like a zip code in the US) and the second paramter is a delimeter, in order to be able to parse the answer. In Canada we have a web site run by the Federal government, that if you type-in the postal code, it will return the range of possible addresses, the street name, the city, province. We use this as a validation for our customer service agent to "verify the customer's authenticity". So we wrote a webservice that "sends" postal codes to this site and retrieves the requested information.

  1. Once you have the path as to where the asmx file and the wsdl file (the actual web service files themselves), (the path has to be on a web server, not a regular server)you need to register it with VFP, in order to use it in an application. To register a web service, you go to tools->Intellisense Manager->Type->Webservices. The prompt will ask you for two values (ie. the name of the service, as in the code below the name is pcode2address, the actual web URL address, as in below "http://intranet/stgwebservices/pcode2address.asmx?wsdl", that points to the asmx and wsdl files.

  2. Once register, now you can used (in a similar fashion as a class or a DLL). But once registered Intellisense will actually produce the code for you to use to call the webservice. All you need to do is either create a program, or a function and type :
    LOCAL ow as
    After you hit the space bar after the 'as' intellisense kicks-in and show you the "class and services available". You select your services and VFP produces the rest of the code, like magic:

    LOCAL loWS
    loWS = NEWOBJECT("Wsclient",HOME()+"ffc\_webservices.vcx")
    loWS.cWSName = "pcode2address"
    ow = loWS.SetupClient("http://intranet/stgwebservices/pcode2address.asmx?wsdl", "PCode2Address", "PCode2AddressSoap")

So the complete code that I use to retrieve the information is:

LOCAL ow as pcode2address
LOCAL loWS
loWS = NEWOBJECT("Wsclient",HOME()+"ffc\_webservices.vcx")
loWS.cWSName = "pcode2address"
ow = loWS.SetupClient("http://intranet/stgwebservices/pcode2address.asmx?wsdl", "PCode2Address", "PCode2AddressSoap")
oResult = ow.getAddr("h9r3K8",":")
? oResult

Mike Gagnon

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close