A Web Services Example


Any application can have a web service component. Web services can be created regardless of programming language. The following example use ASP.NET to create a simple web service that converts the temperature from Fahrenheit to Celsius, and vice versa:

http://www.w3schools.com/xml/tempconvert.asmx
01<%@ WebService Language="VBScript" Class="TempConvert" %>
02 
03Imports System
04Imports System.Web.Services
05 
06Public Class TempConvert :Inherits WebService
07  <WebMethod( )> Public Function FahrenheitToCelsius(
08      ByVal Fahrenheit As String ) As String
09    dim fahr
10    fahr = trim( replace( Fahrenheit, "," , "." ) )
11    if fahr = "" or IsNumeric(fahr) = false then return "Error"
12    return ( ( ( ( fahr ) - 32 ) / 9 ) * 5 )
13  end Function
14 
15  <WebMethod( )> Public Function CelsiusToFahrenheit(
16      ByVal Celsius As String ) As String
17    dim cel
18    cel = trim( replace( Celsius, ",", "." ) )
19    if cel = "" or IsNumeric(cel) = false then return "Error"
20    return ( ( ( ( cel ) * 9 ) / 5 ) + 32 )
21  end Function
22end Class

Few comments about this web service: