Microsoft KB Archive/307355

= HOW TO: Call a Web Service in Visual FoxPro 7.0 =

Article ID: 307355

Article Last Modified on 10/27/2002

-

APPLIES TO


 * Microsoft Visual FoxPro 7.0 Professional Edition

-



This article was previously published under Q307355





IN THIS TASK
SUMMARY How to Call the AirportWeather Web Service
 * Find the AirportWeather Web Service
 * Call the AirportWeather Web Service

REFERENCES



SUMMARY
This step-by-step article describes how to call the AirportWeather Web service by using Visual FoxPro 7.0.

back to the top

How to Call the AirportWeather Web Service
Visual FoxPro 7.0 contains several features that make working with Web services easier, including IntelliSense and a FoxPro Foundation Class to simplify working with the SOAP toolkit.

AirportWeather is a service that looks up the current weather at any NOAA airport observation post. This code sample displays a message box with the current weather conditions at Seattle-Tacoma International Airport.

NOTE: To call Web services in Visual FoxPro 7.0, you must have the Microsoft SOAP Toolkit version 2.0 installed. You can install the SOAP Toolkit from the Visual FoxPro 7.0 installation CD or by downloading it from the following Microsoft Developer Network (MSDN) Web site:

Microsoft SOAP Toolkit

http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/msdn-files/027/001/580/msdncompositedoc.xml

The client parts of the SOAP Toolkit come preinstalled on Microsoft Windows XP, so you don't need a separate download. If you are behind a firewall, you may have problems running this code.

back to the top

Find the AirportWeather Web Service
 Browse to the following Web site:

XMethods.com

http://xmethods.com/

 Scroll down to the AirportWeather service name (owned by Cape Clear). Click the service name to browse to the following Web site:

http://xmethods.com/detail.html?id=129

 Click the WSDL URL, to see the formal definition of the Web service at the following Web site:

http://www.capescience.com/webservices/airportweather/AirportWeather.wsdl

For help with the other features of the service, see the following Web site:

http://www.capescience.com/webservices/airportweather/index.html

 Copy the WSDL URL onto the clipboard.

back to the top

Call the AirportWeather Web Service
 In Visual FoxPro 7.0, start the IntelliSense Manager from the Tools menu.</li> On the Types tab, click Web Services. Note that you receive an error message if you do not have SOAP version 2.0 or later installed. You also receive a warning if you do not have Microsoft Internet Information Server (IIS) installed, but you can continue.</li> For Web Service Name, type AirportWeather .</li> For WDSL URL Location, paste the WSDL URL that you copied in step 5 of the previous section (http://www.capescience.com/webservices/airportweather/AirportWeather.wsdl).</li> Click Register, and the Web service information is saved in the IntelliSense FoxCode.dbf table.</li> Create a new program (for example, Aw.prg).</li> In the code window, type LOCAL loAW AS AirportWeather. Note that AirportWeather is included in the list of types that IntelliSense displays.</li>  Press ENTER. IntelliSense fills in the following code: LOCAL loWS loWS = NEWOBJECT(&quot;Wsclient&quot;,HOME+&quot;ffc\_webservices.vcx&quot;) loWS.cWSName = &quot;AirportWeather&quot; loAw = loWS.SetupClient(&quot;http://live.capescience.com/wsdl/AirportWeather.wsdl&quot;, &quot;AirportWeather&quot;, &quot;Station&quot;)

</li>  Paste the following code at the end of the program: LOCAL loAW as AirportWeather LOCAL loWS loWS = NEWOBJECT(&quot;Wsclient&quot;,HOME+&quot;ffc\_webservices.vcx&quot;) loWS.cWSName = &quot;AirportWeather&quot; loAW = loWS.SetupClient(&quot;http://live.capescience.com/wsdl/AirportWeather.wsdl&quot;, &quot;AirportWeather&quot;, &quot;Station&quot;) loAW.ConnectorProperty(&quot;Timeout&quot;) = 60 * 1000 && milliseconds LOCAL loSummary, lcMessage loSummary = loAW.getSummary(&quot;KSEA&quot;) WITH loSummary TEXT TO lcMessage NOSHOW Location: <<.Item(1).Text>> Wind: <<.Item(2).Text>> Sky Conditions: <<.Item(3).Text>> Temperature: <<.Item(4).Text>> Humidity: <<.Item(5).Text>> Barometer: <<.Item(6).Text>> Visibility: <<.Item(7).Text>> ENDTEXT MESSAGEBOX(TEXTMERGE(lcMessage), &quot;KSEA Weather Conditions&quot;) ENDWITH Note that after you type loAW. , IntelliSense displays the various methods of the Web service. After you select getSummary, IntelliSense displays a tooltip with its parameters and return value. Note that it returns a value of type WeatherSummary:. This is a complex type that is parsed into a COM object with the SOAP Toolkit.

The AirportWeather service has other methods that return simple strings, which can be displayed normally.

</li> Run the program.</li></ol>

The third-party products that are discussed in this article are manufactured by companies that are independent of Microsoft. Microsoft makes no warranty, implied or otherwise, regarding the performance or reliability of these products.

In particular, we cannot guarantee that this Web service will be available when you read this article. The principles in the article will apply to any Web service, so if necessary, choose another one to test against, and modify the display code accordingly.

back to the top

<div class="references_section">