A Web Service example

In the following example we will use ASP.NET to create a simple Web Service that converts the temperature from Fahrenheit to Celsius, and vice versa:

<%@ 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

This document is saved as an .asmx file. This is the ASP.NET file extension for XML Web Services.

  • programming, web service
  • 2 Users Found This Useful
Was this answer helpful?

Related Articles

Connection string for Web.config

connectionString="Data Source=IP-ADDRESS;Initial Catalog=YOUR-DATABASE;User...

Crystal Reports version

We have upgraded SAP Crystal Reports 2013 SP25 (Runtime Engine for .NET Framework 4) to SP26 for...

Enable error message for Web.config

To enable the details of this specific error message to be viewable on remote machines, please...

Redirect to HTTPS using Web.config

Add the source code following in system.webServer section (web.config): <rewrite>...

Redirect to WWW using Web.config

Add the source code following in system.webServer section (web.config): <rewrite>...