locked
Web Service method Name is not valid RRS feed

  • Question

  • User-85380046 posted

    Calling a webservice from script manager via

    LocqusService.GetTaskV2() in Javascript

    The method shows up in LocqusService.asmx

    and is 

    [WebMethod]
    public lTaskList GetTaskV2(int uname, string token, string gname, DateTimeOffset Day)
    {
    var response = apiFactory.getTaskV2(gname, token, uname, Day);
    return response;
    }

    web.config is

    <httpHandlers>
    <remove path="*.asmx" verb="*"/>
    <add path="*.asmx" verb="*" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add verb="GET,HEAD" path="ScriptResource.axd" validate="false" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    <add path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet"/>
    </httpHandlers>

    <httpModules>
    <add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet"/>
    <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </httpModules>

    The web method call works from javadscript and no other methods give the error.

    Yet I get the server error: what could cause this error?

    System.InvalidOperationException: GetTaskV2 Web Service method name is not valid.
       at System.Web.Services.Protocols.HttpServerProtocol.Initialize()
       at System.Web.Services.Protocols.ServerProtocol.SetContext(Type type, HttpContext context, HttpRequest request, HttpResponse response)
       at System.Web.Services.Protocols.ServerProtocolFactory.Create(Type type, HttpContext context, HttpRequest request, HttpResponse response, Boolean& abortProcessing)
    Tuesday, December 17, 2013 5:14 PM

All replies

  • User-745611520 posted

    Hi,

        Post ur Javascript code for understanding completly.

    Thanks,

    Selvakumar.S

    Wednesday, December 18, 2013 8:46 AM
  • User-85380046 posted
    function EditEvent(i) {
                    //get Tasks
                    LocqusService.GetTaskV2($("#DOMuid").val(), $("#DOMtoken").val(), $("#DOMgroup").val(), $("#TasksV2EditDate").val(), function (TaskList) {
                        if (TaskList.tasks != null) {
                            CreateTaskTab();
                            $("#TasksV2CreateNewBut").attr("onclick", "EditTaskSubmit(" + TaskList.tasks[i].tid + ");return false;");
                            $("#TasksV2EmployeeDDL").attr("onchange", "ChangeUser(" + TaskList.tasks[i].tid + ")");
                            $("#TaskHeader").html("Edit Job");
                            $("#TaskBack").show();
                            //populate edit fields
                            $("#TasksV2Name").val(TaskList.tasks[i].name);
                            $("#TasksV2EmployeeDDL").val(TaskList.tasks[i].users[0]);
                            if (TaskList.tasks[i].customer_title != null && TaskList.tasks[i].customer_title != "") {
                                $("#TasksV2CustomerDDL").val(TaskList.tasks[i].customer_title);
                                GetEmailPhone("Task");
                                $("#TaskAlert").show();
                            }
                            $("#TasksV2StartTime").val(friendlyTime(TaskList.tasks[i].start));
                            $("#TasksV2StartDate").val(getDate(TaskList.tasks[i].start));
                            $("#TasksV2EndTime").val(friendlyTime(TaskList.tasks[i].end));
                            $("#TasksV2EndDate").val(getDate(TaskList.tasks[i].end));
                            $("#TasksV2Address").val(TaskList.tasks[i].address);
                            $("#TasksV2Description").val(TaskList.tasks[i].description);
                        }
                    }, function () {
                        toastr.error("Could Not Get Jobs");
                    })
                }

    This is one of a few functions that call the service.

    Wednesday, December 18, 2013 10:15 AM
  • User-1993059563 posted

    can you please try without DateTimeOffset  ?

    Wednesday, December 18, 2013 10:46 AM
  • User-85380046 posted

    still have the error :\

    occurs at 

    /System.Web.Script.Services. RestHandler/ProcessRequestHttp

    Uncaught TypeError: Object function () {
    LocqusService.initializeBase(this);
    this._timeout = 0;
    this._userContext = null;
    this._succeeded = null;
    this._failed = null; } has no method 'GetTaskV2'

    if that helps.

    Wednesday, December 18, 2013 11:20 AM
  • User-417640953 posted

    Hi DStrong,

    Thank you post the issue to asp.net forum.

    Your web.config looks fine. And using the scriptmanager to call web service should like below.

        [System.Web.Script.Services.ScriptService]
        public class MyWebService : System.Web.Services.WebService
        {   [WebMethod]
            public string GetTaskV2(int uname, string token, string gname, DateTimeOffset Day)
            {
                return "Hi";
            
            }
        }

    aspx:

    <script type="text/javascript"> 
                // This function calls the Web Service method.  
                function EchoUserInput() {
                      WebApplicationCsharp._12_month._12_19.MyWebService.GetTaskV2(1,"1","2","2013/12/19",SucceededCallback);
                }
    
                // This is the callback function that 
                // processes the Web Service return value.
                function SucceededCallback(result) {
                    alert(result);
                    
                }
    </script>
     <asp:ScriptManager ID="ScriptManager1" runat="server">
                <Services>
                    <asp:ServiceReference Path="~/12-month/12-19/MyWebService.asmx" />
                </Services>
     </asp:ScriptManager>
     <input id="EchoButton" type="button" value="Echo" onclick="EchoUserInput()" /> 

    If your code look fine like above, I suggest you try to use the jquery $.ajax to call the web service and see if it works fine.

    If $.ajax cannot call the web service as well, I think you should consider the return value type "lTaskList" of web method "GetTaskV2" whether valid.

    Besides, I'd like to suggest checking below similar issue.

    http://stackoverflow.com/questions/2225781/asp-net-web-method-that-accepts-a-listcustomobject-is-failing-with-web-servic

    Hope this helps, Thanks.

    Best Regards!

    Thursday, December 19, 2013 2:57 AM