I have an Jquery .ajax call that is making a call to a web service. When doing so, in fiddler I am getting the following error
System.InvalidOperationException: GetReservesTable Web Service method name is not valid.
My Code Looks like this:
Jquery:
function GetReserves() {
var clt = $("select[id$='lstClt'] option:selected").val();
var LACov = $("select[id$='lstExCov'] option:selected").val();
var Loss = $("select[id$='lstLoss'] option:selected").val();
var IDControl = '#<%=ID.ClientID %>';
var ID = $(IDControl).val();
var tableID = '#<%= resultsTbl.ClientID %>';
var url = "/autocomplete.asmx/GetReservesTable"; //
$.ajax({
type: "POST",
url: url,
data: { ID: ID, Clt: clt, LACov: LACov, Loss: Loss },
success: function (data) {
$(tableID).replaceWith(data);
}
});
return false;
}
And then my Web Service
<WebService(Namespace:="http://tempuri.org/")> _
<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
<System.Web.Script.Services.ScriptService()> _
Public Class AutoComplete
Inherits System.Web.Services.WebService
<WebMethod()> _
<ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _
Public Function GetReservesTable(ByVal ID As Integer, ByVal Clt_ID As Integer, ByVal LACov As Nullable(Of Integer), _
ByVal Loss As Nullable(Of Integer)) As String
Dim strWriter As String = ""
Dim ExpIn As String
Dim ExpPa As String
Dim ExpRec As String
Using Command As New SqlCommand("GetForm", Connection)
Command.CommandType = CommandType.StoredProcedure
Command.Parameters.Add(New SqlParameter("@pID", SqlDbType.Int)).Value = ID
Command.Parameters.Add(New SqlParameter("@Clt_ID", SqlDbType.Int)).Value = Clt_ID
Command.Parameters.Add(New SqlParameter("@LACov_ID", SqlDbType.Int)).Value = LACov
Command.Parameters.Add(New SqlParameter("@Loss", SqlDbType.Int)).Value = Loss
Using Reader As SqlDataReader = Command.ExecuteReader()
While Reader.Read
strWriter = strWriter + "<table ID='resultsTbl' runat='server'>"
strWriter = strWriter + "<tr>"
strWriter = strWriter + "<td><input type='text' id='txtExpIn' width='142px' stype='margin:3px' disabled='disabled' value='" & ExpTotIncur & "'></td>"
strWriter = strWriter + "<td> </td>"
.
.
.
End While
End Using
End Using
Return strWriter
End Function
Please note the Web service is truncated as I am creating a long html string in there.
I have other web services that are running with autocomplete and everything is working fine.
Wozer
Member
390 Points
266 Posts
Web Service method Name is not valid
Jan 17, 2013 08:10 PM|LINK
Hi,
I have an Jquery .ajax call that is making a call to a web service. When doing so, in fiddler I am getting the following error
System.InvalidOperationException: GetReservesTable Web Service method name is not valid.
My Code Looks like this:
Jquery:
function GetReserves() { var clt = $("select[id$='lstClt'] option:selected").val(); var LACov = $("select[id$='lstExCov'] option:selected").val(); var Loss = $("select[id$='lstLoss'] option:selected").val(); var IDControl = '#<%=ID.ClientID %>'; var ID = $(IDControl).val(); var tableID = '#<%= resultsTbl.ClientID %>'; var url = "/autocomplete.asmx/GetReservesTable"; // $.ajax({ type: "POST", url: url, data: { ID: ID, Clt: clt, LACov: LACov, Loss: Loss }, success: function (data) { $(tableID).replaceWith(data); } }); return false; }And then my Web Service
<WebService(Namespace:="http://tempuri.org/")> _ <WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _ <Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _ <System.Web.Script.Services.ScriptService()> _ Public Class AutoComplete Inherits System.Web.Services.WebService <WebMethod()> _ <ScriptMethod(ResponseFormat:=ResponseFormat.Json)> _ Public Function GetReservesTable(ByVal ID As Integer, ByVal Clt_ID As Integer, ByVal LACov As Nullable(Of Integer), _ ByVal Loss As Nullable(Of Integer)) As String Dim strWriter As String = "" Dim ExpIn As String Dim ExpPa As String Dim ExpRec As String Using Command As New SqlCommand("GetForm", Connection) Command.CommandType = CommandType.StoredProcedure Command.Parameters.Add(New SqlParameter("@pID", SqlDbType.Int)).Value = ID Command.Parameters.Add(New SqlParameter("@Clt_ID", SqlDbType.Int)).Value = Clt_ID Command.Parameters.Add(New SqlParameter("@LACov_ID", SqlDbType.Int)).Value = LACov Command.Parameters.Add(New SqlParameter("@Loss", SqlDbType.Int)).Value = Loss Using Reader As SqlDataReader = Command.ExecuteReader() While Reader.Read strWriter = strWriter + "<table ID='resultsTbl' runat='server'>" strWriter = strWriter + "<tr>" strWriter = strWriter + "<td><input type='text' id='txtExpIn' width='142px' stype='margin:3px' disabled='disabled' value='" & ExpTotIncur & "'></td>" strWriter = strWriter + "<td> </td>" . . . End While End Using End Using Return strWriter End FunctionPlease note the Web service is truncated as I am creating a long html string in there.
I have other web services that are running with autocomplete and everything is working fine.
Does anyone know what is happening with this one?
Thanks,
Chris
Wozer
Member
390 Points
266 Posts
Re: Web Service method Name is not valid
Jan 18, 2013 05:05 PM|LINK
Got it working I was missing some stuff in the .ajax call where the service didnt know it if it was getting JSON or not
specifically:
JSON.stringify({})
dataType: "json",
contentType: "application/json; charset=utf-8",
Chris
Haixia Xie -...
Contributor
3022 Points
294 Posts
Microsoft
Re: Web Service method Name is not valid
Jan 21, 2013 08:18 AM|LINK
Hi,
Glad to hear the the issue solved by yourself and shared the solution here. Thanks.
Best Regards.
Feedback to us
Develop and promote your apps in Windows Store