In this article, we will be consuming the CDYNE free weather service. We will be using the following resources:
Weather Service WIKI
Weather service Specification Sheet
Use WSDL.exe to generate the source code for the proxy class in one of the Visual Studio languages.
WSDL is a tool provided by Microsoft for the generation of Web Services proxy classes. The help file for the tool is located here.
The weather service specification sheet provides us with a listing of functions and parameters as well as the location of the WSDL formatted files. Type the following into your command prompt to generate the proxy class code in Visual Basic and save the output to "C:\Temp\myProxyClass.vb".
>WSDL /L:VB /O:C:\Temp\myProxyClass.vb HTTP://wsf.cdyne.com/WeatherWS/Weather.asmx?wsdl
Use Visual Studio to generate a .Net assembly from the source code.
Launch Visual Studio and create a class library project and import the code generated by WSDL.exe. User Project | Add Reference to add System.Web.Services to your project. Build the project and locate the compiled library.
Download Visual Basic project
Import the .NET library into ATEasy.
Create a new ATEasy application and a new driver. Rename the new driver to WeatherSvc. Import the .NET library into the new driver. For convenience, you can also move the DLL file into the ATEasy application directory.
Instantiate the proxy class with ATEasy.
Create a driver procedure GetWeather(). This procedure will allow us to retrieve the city, state and current temperature for the provided zip code.
Procedure GetWeather(zipcode, temperature, state, city): Void
--------------------------------------------------------------------------------
zipcode: Val BString
temperature: Var BString
state: Var BString
city: Var BString
WeatherReturn: WeatherProxyClass.WeatherReturn
weather: WeatherProxyClass.Weather
{
weather=new WeatherProxyClass.Weather()
WeatherReturn=weather.GetCityWeatherByZIP(zipcode)
city=WeatherReturn.City
state=WeatherReturn.State
temperature=WeatherReturn.Temperature
}
Create a command tree within your driver to link to this procedure. Attach this procedure to the "Driver Get Weather" command.
To test this, create a series of variables and tests in the program module.
weatherCity: BString
weatherState: BString
weatherTemperature: BString
Task 1 : "Perform Weather Operations"
--------------------------------------------------------------------------------
Id = Perform_Weather_Operations
Test 1.1 : "Request information"
--------------------------------------------------------------------------------
Id = Request_information
Type = Other
{
WeatherSvc Get Weather("92614", weatherTemperature, weatherState, weatherCity)
}
Test 1.2 : "Check City"
--------------------------------------------------------------------------------
Id = Check_City
Type = String
String = "Irvine"
{
TestResult=weatherCity
}
Test 1.3 : "Check State"
--------------------------------------------------------------------------------
Id = Check_State
Type = String
String = "CA"
{
TestResult=weatherState
}
Test 1.4 : "Check Temp"
--------------------------------------------------------------------------------
Id = Check_Temp
Unit = "Fahrenheit"
Type = MinMax
Min = 30
Max = 120
{
TestResult=Val(weatherTemperature)
}
Download ATEasy project