Hi I Have a web method on the Server. Below Is My Web Method.
ASP.NET Syntax (Toggle Plain Text)

    public string GetAge(int year, int month, int day)
        DateTime birthDate = new DateTime(year, month, day);
        long age = new DateTime(DateTime.Now.Ticks - birthDate.Ticks).Year - 1;
        return "You are " + age.ToString() + " years old.";

    //This method caches the datetime for 4 seconds. 
    //also a simple cache implementation. 
    private const int CacheTime = 4; // seconds
    [WebMethod(CacheDuration = CacheTime,
    Description = "As simple as it gets - the ubiquitous Get Date Time.")]
    public string GetDateTime()
        return DateTime.Now.ToString();

Now I Want To run This Webmethod Through HTML Page which is on my system.

This Is my Code. But I am not getting the application run.

Below I have given my code.

ASP.NET Syntax (Toggle Plain Text)

        <script language="JavaScript">
            function InitializeService()
                service.useService("http://localhost:1394/MyWebService.asmx?wsdl",  "GetAgeService");

               // [url]http://localhost:3330/EIMBA/ServiceEIMBA.asmx[/url]
            var StrYear, StrMonth, StrDay;
            function GetAge()
                StrYear = document.DemoForm.StringYear.value;
                StrMonth = document.DemoForm.StringMonth.value;
                StrDay = document.DemoForm.StringDay.value; 

                service.GetAgeService.callService("GetAge", StrYear, StrMonth, StrDay);
            function ShowResult()
    <body onload="InitializeService()"  id="service" style="behavior:url(webservice.htc)"  onresult="ShowResult()">
        <form name="DemoForm">
            Year : <input type="text" name="StringYear"/><br />
            Month : <input type="text" name="StringMonth"/><br />
            Day : <input type="text" name="StringDay"/><br /> 
            <button onclick="GetAge()">Get Age</button><br />

Can any one tell me how to execute the webservice from my HTML code. any changes needed from my HTML Code.

Edited by mike_2000_17: Fixed formatting

6 Years
Discussion Span
Last Post by Andrey Luiz

Please wrap code in code-tag.
We will understando more your problem.

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.