MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

Web Services

SOAP IN Web services

SOAP Tutorial

Create a Web Service For Calculate Age when user input Date
Previous Home Next

Step 1: Open a new Web Site and click on

ASP.Net Web Services press on OK as shown below in fig.

Step 2: The code (Service.cs) written for Calculating Age , Calculate Factorial and Square Root of a Number.


using System;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Xml.Linq;
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Service : System.Web.Services.WebService
{[WebMethod (Description="Calculating Age")]
    public string calAge(DateTime date)
    {   DateTime nowDate = System.DateTime.Now;
        System.TimeSpan span = nowDate - date;
        int days = (int)span.TotalDays;
        int yea = days / 365;
        string age = yea.ToString() + " years ";
        return age;}
    [WebMethod(Description = "Calculating SquareRoot")]
    public double calSquareRoot(int a)
    {   double i = 0;
        double x1, x2=0;
        while ((i * i) <= a)
        i += 0.1;
        x1 = i;
        for (int j = 0; j < 10; j++)
        {   x2 = a;
            x2 /= x1;
            x2 += x1;
            x2 /= 2;
            x1 = x2;}
        return x2;}
    [WebMethod(Description = "Calculating Factorial")]
    public double calFactorial(int a)
    {if (a == 0)return 1;
        else return (a*calFactorial(a-1));}}

Step 3: Debug The service

Click on each link and check your service

Step 4: To use this service, go to your project solution right click and click on Add Web Reference. A new window open

Copy the URL of your running web service and paste it in the new window place as shown in below fig.
Note: Remember the web reference name, it will be added in your project (.cs ) file e.g. this reference help to call the method of your web services. You will call the methods to create an object of SERVICE.

To know more click Here

 

using localhost;

Click on Add Reference, The service will be added in your web site. It will be show on your page like below fig.

Previous Home Next