[Mono-aspnet-list] How can I consume a web service with javascript and jquery?

LucaDev lucaserci at gmail.com
Thu Aug 4 16:35:10 EDT 2011


Hello everyone,
 
sorry for my English

I created a website with some aspx pages, for example, Default.aspx, and a
web service called DataService.asmx. From the Default.aspx page I would like
to call the web service using jquery.
The problem is that I can not call the web service using jquery


I'm using mono 2.4.4 on ubuntu server version 10.04.

How can I consume a web service with javascript and jquery?

Please help me, thanks



Using firebug I see

Object reference not set to an instance of an object
Description: HTTP 500. Error processing request.
Stack Trace: System.NullReferenceException: Object reference not set to an
instance of an object at
System.Web.Script.Services.WebServiceData.GetWebServiceData
(System.Web.HttpContext context, System.String virtualPath, Boolean
failIfNoData, Boolean PageMethods) [0x00000 ] at
System.Web.Script.Services.WebServiceData.GetWebServiceData
(System.Web.HttpContext context, System.String virtualPath) [0x00000] at
System.Web.Script.Services.RestHandler.CreateHandler (System.Web.HttpContext
context) [ 0x00000] at
System.Web.Script.Services.RestHandlerFactory.GetHandler
(System.Web.HttpContext context, RequestType System.String, System.String
url, pathTranslated System.String) [0x00000] at
System.Web.Script.Services.ScriptHandlerFactory . GetHandler
(System.Web.HttpContext context, RequestType System.String, System.String
url, pathTranslated System.String) [0x00000] at
System.Web.HttpApplication.GetHandler (System.Web.HttpContext context,
System.String url, Boolean ignoreContextHandler) [0x00000] at
System.Web.HttpApplication.GetHandler (System.Web.HttpContext context,
System.String url) [0x00000] + at System.Web.HttpApplication <Pipeline>
c__Iterator2.MoveNext () [0x00000]
Version Information: Runtime: Mono 2.4.4
ASP.NET Version: 2.0.50727.1433



Web Service Code (DataService.asmx)

    [WebService (Namespace = "http://tempuri.org/")]
    [WebServiceBinding (ConformsTo WsiProfiles.BasicProfile1_1 =)]
    [ScriptService ()]
    public class DataService: System.Web.Services.WebService
    {
        [WebMethod]
        [ScriptMethod (ResponseFormat = ResponseFormat.Json,
XmlSerializeString = false)]
        public string SayHello ()
        {
            return "Hello !!!";
        }
   }


Javascript (Default.aspx)

<script type="text/javascript">

  $ (Document). Ready (function () {

            $. Ajax ({
                type: "POST",
                url: _webServiceAddress + method,
                Date: parameters,
                contentType: "application / json, charset = utf-8",
                dataType: "json",
                success: function (data) {alert (data);}
                error: function () {alert ("Error");}
            });

        });
</ Script>

--
View this message in context: http://mono.1490590.n4.nabble.com/How-can-I-consume-a-web-service-with-javascript-and-jquery-tp3719799p3719799.html
Sent from the Mono - ASP.NET mailing list archive at Nabble.com.


More information about the Mono-aspnet-list mailing list