Page 231 - DCAP312_WEB_TECHNOLOGIES_II
P. 231

Unit 11: Web Services in Visual Studio .NET



            A Web Service Example                                                                 Notes
            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
                     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
                     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.




                      Create a Web service.

                          The SOAP was designed as an object-access protocol in 1998 by Dave Winer,
                          Don Box, Bob Atkinson, and Mohsen Al-Ghosein for Microsoft, where Atkinson
                          and Al-Ghosein were working at the time.
            Self Assessment Questions

               1.  ASP.NET server side technology not allows developers to create web services.

                 (a)  True                       (b)  False
               2.  Web browsers are software applications that allow users to retrieve data and interact with
                 content located on web pages within a website.

                 (a)  True                       (b)  False
               3.  ………………………..is one form of client side script that permits dynamic elements on
                 each page.
                 (a)  Java                       (b)  PHP

                 (c)  JavaScript                 (d)  XML





                                             LOVELY PROFESSIONAL UNIVERSITY                                   225
   226   227   228   229   230   231   232   233   234   235   236