Community discussion forum

AJAX: SimpleWebServices is not defined

  • 1 year ago

    Hi

    I have a webpage and webservice on localhost in different project. In different virtual directories. I want to call webservice function as follows and alert it onComplete.

    ---------------------------

    function Button1_onclick() {
        ret = SimpleWebServices.SimpleService.SayHello(document.getElementById('Text1').value, OnComplete, OnTimeOut, OnError);
    return(true);
    }

    function OnComplete(arg) {
    alert(arg);
    }


    -------------

    Webservice code is very simple..

    namespace SimpleWebServices
    {
        [WebService(Namespace = "http://tempuri.org/")]
        [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
        [System.Web.Script.Services.ScriptService()]
        public class SimpleService : System.Web.Services.WebService
        {
            [WebMethod]
            public string SayHello(String Name)
            {
                return "Hello : " + Name;
            }
        }
    }

    -----------------

    But, i get error : "SimpleWebServices is not defined"

    Not sure what I am missing. Please advise. Thanks

    Pankaj

  • 1 year ago

    It looks like you are using WCF

    You added the namespace after you made the web service I have been working on WCF and I think you have to also refer that namespace on another page. I will look it up tomorrow if I can get some free time and see what I can find out for you.

    In the mean time try removing the namespace SimpleWebServices and see if it will run for you.

  • 1 year ago

    Ok Had a few minute to look at this and it seem you are getting the error "SimpleWebServices is not defined" because I think you not set your service reference on the page.

    To do this will will need to get the address to the web service that you created and after that within the script mamager tag try this.

    <asp:ScriptManager ID="ScriptManager1" runat="server">

    <Services>

    <asp:ServiceReference Path="http://Your_address_to_your_WebService/Service.asmx" />

    </Services> </asp:ScriptManager>

    Hope this helps and I am use to calling web services within the same project. I have not done any remote web service calling.

Post a reply

Enter your message below

Sign in or Join us (it's free).

We'd love to hear what you think! Submit ideas or give us feedback