Slide 16.3: Web services (cont.)
Slide 16.5: How to use web services
Home

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
<%@ WebService Language="VBScript" Class="TempConvert" %>

Imports System
Imports System.Web.Services

Public Class TempConvert :Inherits WebService
  <WebMethod( )> Public Function FahrenheitToCelsius(
      ByVal Fahrenheit As String ) As String
    dim fahr
    fahr = trim( replace( Fahrenheit, "," , "." ) )
    if fahr = "" or IsNumeric(fahr) = false then return "Error"
    return ( ( ( ( fahr ) - 32 ) / 9 ) * 5 )
  end Function

  <WebMethod( )> Public Function CelsiusToFahrenheit(
      ByVal Celsius As String ) As String
    dim cel
    cel = trim( replace( Celsius, ",", "." ) )
    if cel = "" or IsNumeric(cel) = false then return "Error"
    return ( ( ( ( cel ) * 9 ) / 5 ) + 32 )
  end Function
end Class

Few comments about this web service: