locked
Web Service method Name is not valid RRS feed

  • Question

  • User1864611142 posted

    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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</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.

    Does anyone know what is happening with this one?

    Thanks,

    Chris

    Thursday, January 17, 2013 4:10 PM

Answers

  • User1864611142 posted

    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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 18, 2013 1:05 PM

All replies

  • User1864611142 posted

    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

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, January 18, 2013 1:05 PM
  • User-1000095884 posted

    Hi,

    Glad to hear the the issue solved by yourself and shared the solution here. Thanks.

    Best Regards.

    Monday, January 21, 2013 4:18 AM