ok i’m in a bit of a pickle here.
When i try to call a webservice from a page that belongs to myproject.account.members namespace
to a webservice that belongs to myproject.services i get an error
///—–modified: added error message—–///
---------------------------
Message from webpage
---------------------------
responseText=
textStatus=error
errorThrown=Unknown
---------------------------
OK
---------------------------
eg.
The jquery ajax call from somepage.aspx that belongs to myproject.account.members
$.ajax({
type: "POST",
url: '<%=ResolveUrl("~/Services/productService.asmx/getSomething") %>',
data: '',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (result){
alert(result.d)
},
error: function(XMLHttpRequest, textStatus, errorThrown){
alert("responseText=" + XMLHttpRequest.responseText + "\ntextStatus=" + textStatus + "\nerrorThrown=" + errorThrown);
}
});
the webservice code belongs to myproject.Services
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
namespace myproject.Services
{
/// <summary>
/// Summary description for productService
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.ComponentModel.ToolboxItem(false)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
[System.Web.Script.Services.ScriptService]
public class productService : System.Web.Services.WebService
{
[WebMethod]
public String getSomething()
{
return "Hello World";
}
}
}
Basically if i change namespace of my webservice from myproject.Services to myproject.account.member it works if i call it from a page that belongs to myproject.account.members namespace… but it won’t work if set the namespace to myproject.Services
please help.. how do i get around this? what if i want to call same service from several different namespaces within my project?`enter code here
When you changed the namespace of the code behind class of the web service don’t forget to change it in the markup as well (
productService.asmx):Also replace:
with:
And to get a more meaningful error message than the one you have posted in your question use FireBug or Chrome Developer tools in order to see the exact AJAX request that it being sent. You will see the request and the response from the server. It will help you better understand what is wrong with your code.